-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cac0737
commit ca58bbd
Showing
12 changed files
with
326 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Mapping Examples | ||
This directory contains different examples of HTTP request/response. | ||
|
||
Once you start the `mimic` with these examples(simply downmload and point `mimic` to directory), content of each JSON file will turn be used to create appropiate HTTP endpoint. | ||
|
||
### GitHub User API Examples | ||
Some examples from GitHub user API which can be tested via following commands | ||
|
||
```` | ||
# Will return 200 with a user response in get-authenticated-user.json file | ||
curl -i http://localhost:8080/user -H "Authorization: token someValidToken" | ||
# Will return 401 with a response in get-authenticated-user-fails.json file | ||
curl -i http://localhost:8080/user -H "Authorization: token someInvalidToken" | ||
# Will return 200 with a response in get-user.json file | ||
curl -i http://localhost:8080/user/octocat | ||
# username is dynamic, which means following example will return the same response | ||
curl -i http://localhost:8080/user/someotheruser | ||
```` | ||
|
||
For more details check out the JSON files. | ||
|
||
|
||
### Fault Simulation | ||
Purpose of fault simulation is to create artificial failures in responses. At this stage only supported failure is response-delay. | ||
|
||
```` | ||
{ | ||
"request":{ | ||
"url": "/health", | ||
"method" : "GET" | ||
}, | ||
"response":{ | ||
"status": 200, | ||
"body": "All healthy", | ||
"headers":{ | ||
"Content-Type":"text/plain" | ||
}, | ||
"withDelay": 4000 | ||
} | ||
} | ||
```` | ||
The mapping above, will delay the response for 4 seconds, try it out with: | ||
|
||
```` | ||
curl -i http://localhost:8080/health | ||
```` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,6 @@ | |
"headers":{ | ||
"Content-Type":"text/plain" | ||
}, | ||
"withDelay": 2000 | ||
"withDelay": 4000 | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
examples/github-user-api/get-authenticated-user-fails.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"request":{ | ||
"url": "/user", | ||
"method" : "GET", | ||
"headers":{ | ||
"Authorization": "token someInvalidToken" | ||
} | ||
}, | ||
"response":{ | ||
"status": 401, | ||
"body": { | ||
"message": "Requires authentication", | ||
"documentation_url": "https://docs.github.com/rest/reference/users#get-the-authenticated-user" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
{ | ||
"request":{ | ||
"url": "/user", | ||
"method" : "GET", | ||
"headers":{ | ||
"Authorization": "token someValidToken" | ||
} | ||
}, | ||
"response":{ | ||
"status": 200, | ||
"body": { | ||
"login": "octocat", | ||
"id": 1, | ||
"node_id": "MDQ6VXNlcjE=", | ||
"avatar_url": "https://github.com/images/error/octocat_happy.gif", | ||
"gravatar_id": "", | ||
"url": "https://api.github.com/users/octocat", | ||
"html_url": "https://github.com/octocat", | ||
"followers_url": "https://api.github.com/users/octocat/followers", | ||
"following_url": "https://api.github.com/users/octocat/following{/other_user}", | ||
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", | ||
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", | ||
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions", | ||
"organizations_url": "https://api.github.com/users/octocat/orgs", | ||
"repos_url": "https://api.github.com/users/octocat/repos", | ||
"events_url": "https://api.github.com/users/octocat/events{/privacy}", | ||
"received_events_url": "https://api.github.com/users/octocat/received_events", | ||
"type": "User", | ||
"site_admin": false, | ||
"name": "monalisa octocat", | ||
"company": "GitHub", | ||
"blog": "https://github.com/blog", | ||
"location": "San Francisco", | ||
"email": "[email protected]", | ||
"hireable": false, | ||
"bio": "There once was...", | ||
"twitter_username": "monatheoctocat", | ||
"public_repos": 2, | ||
"public_gists": 1, | ||
"followers": 20, | ||
"following": 0, | ||
"created_at": "2008-01-14T04:33:35Z", | ||
"updated_at": "2008-01-14T04:33:35Z", | ||
"private_gists": 81, | ||
"total_private_repos": 100, | ||
"owned_private_repos": 100, | ||
"disk_usage": 10000, | ||
"collaborators": 8, | ||
"two_factor_authentication": true, | ||
"plan": { | ||
"name": "Medium", | ||
"space": 400, | ||
"private_repos": 20, | ||
"collaborators": 0 | ||
} | ||
}, | ||
"headers":{ | ||
"Content-Type":"application/json" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"request":{ | ||
"url": "/users/{username}/hovercard", | ||
"method" : "GET" | ||
}, | ||
"response":{ | ||
"status": 200, | ||
"body": { | ||
"contexts": [ | ||
{ | ||
"message": "Owns this repository", | ||
"octicon": "repo" | ||
} | ||
] | ||
}, | ||
"headers":{ | ||
"Content-Type":"application/json" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
{ | ||
"request":{ | ||
"url": "/user/{username}", | ||
"method" : "GET" | ||
}, | ||
"response":{ | ||
"status": 200, | ||
"body": { | ||
"login": "octocat", | ||
"id": 1, | ||
"node_id": "MDQ6VXNlcjE=", | ||
"avatar_url": "https://github.com/images/error/octocat_happy.gif", | ||
"gravatar_id": "", | ||
"url": "https://api.github.com/users/octocat", | ||
"html_url": "https://github.com/octocat", | ||
"followers_url": "https://api.github.com/users/octocat/followers", | ||
"following_url": "https://api.github.com/users/octocat/following{/other_user}", | ||
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", | ||
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", | ||
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions", | ||
"organizations_url": "https://api.github.com/users/octocat/orgs", | ||
"repos_url": "https://api.github.com/users/octocat/repos", | ||
"events_url": "https://api.github.com/users/octocat/events{/privacy}", | ||
"received_events_url": "https://api.github.com/users/octocat/received_events", | ||
"type": "User", | ||
"site_admin": false, | ||
"name": "monalisa octocat", | ||
"company": "GitHub", | ||
"blog": "https://github.com/blog", | ||
"location": "San Francisco", | ||
"email": "[email protected]", | ||
"hireable": false, | ||
"bio": "There once was...", | ||
"twitter_username": "monatheoctocat", | ||
"public_repos": 2, | ||
"public_gists": 1, | ||
"followers": 20, | ||
"following": 0, | ||
"created_at": "2008-01-14T04:33:35Z", | ||
"updated_at": "2008-01-14T04:33:35Z", | ||
"private_gists": 81, | ||
"total_private_repos": 100, | ||
"owned_private_repos": 100, | ||
"disk_usage": 10000, | ||
"collaborators": 8, | ||
"two_factor_authentication": true, | ||
"plan": { | ||
"name": "Medium", | ||
"space": 400, | ||
"private_repos": 20, | ||
"collaborators": 0 | ||
} | ||
}, | ||
"headers":{ | ||
"Content-Type":"application/json" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"request":{ | ||
"url": "/users", | ||
"method" : "GET" | ||
|
||
}, | ||
"response":{ | ||
"status": 200, | ||
"body": [ | ||
{ | ||
"login": "octocat", | ||
"id": 1, | ||
"node_id": "MDQ6VXNlcjE=", | ||
"avatar_url": "https://github.com/images/error/octocat_happy.gif", | ||
"gravatar_id": "", | ||
"url": "https://api.github.com/users/octocat", | ||
"html_url": "https://github.com/octocat", | ||
"followers_url": "https://api.github.com/users/octocat/followers", | ||
"following_url": "https://api.github.com/users/octocat/following{/other_user}", | ||
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", | ||
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", | ||
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions", | ||
"organizations_url": "https://api.github.com/users/octocat/orgs", | ||
"repos_url": "https://api.github.com/users/octocat/repos", | ||
"events_url": "https://api.github.com/users/octocat/events{/privacy}", | ||
"received_events_url": "https://api.github.com/users/octocat/received_events", | ||
"type": "User", | ||
"site_admin": false | ||
} | ||
] | ||
, | ||
"headers":{ | ||
"Content-Type":"application/json" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
{ | ||
"request":{ | ||
"url": "/user", | ||
"method" : "PATCH", | ||
"body":{ | ||
"name":"La Gioconda" | ||
} | ||
}, | ||
"response":{ | ||
"status": 200, | ||
"body": { | ||
"login": "octocat", | ||
"id": 1, | ||
"node_id": "MDQ6VXNlcjE=", | ||
"avatar_url": "https://github.com/images/error/octocat_happy.gif", | ||
"gravatar_id": "", | ||
"url": "https://api.github.com/users/octocat", | ||
"html_url": "https://github.com/octocat", | ||
"followers_url": "https://api.github.com/users/octocat/followers", | ||
"following_url": "https://api.github.com/users/octocat/following{/other_user}", | ||
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", | ||
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", | ||
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions", | ||
"organizations_url": "https://api.github.com/users/octocat/orgs", | ||
"repos_url": "https://api.github.com/users/octocat/repos", | ||
"events_url": "https://api.github.com/users/octocat/events{/privacy}", | ||
"received_events_url": "https://api.github.com/users/octocat/received_events", | ||
"type": "User", | ||
"site_admin": false, | ||
"name": "La Gioconda", | ||
"company": "GitHub", | ||
"blog": "https://github.com/blog", | ||
"location": "San Francisco", | ||
"email": "[email protected]", | ||
"hireable": false, | ||
"bio": "There once was...", | ||
"twitter_username": "monatheoctocat", | ||
"public_repos": 2, | ||
"public_gists": 1, | ||
"followers": 20, | ||
"following": 0, | ||
"created_at": "2008-01-14T04:33:35Z", | ||
"updated_at": "2008-01-14T04:33:35Z", | ||
"private_gists": 81, | ||
"total_private_repos": 100, | ||
"owned_private_repos": 100, | ||
"disk_usage": 10000, | ||
"collaborators": 8, | ||
"two_factor_authentication": true, | ||
"plan": { | ||
"name": "Medium", | ||
"space": 400, | ||
"private_repos": 20, | ||
"collaborators": 0 | ||
} | ||
}, | ||
"headers":{ | ||
"Content-Type":"application/json" | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,6 @@ | |
"url": "/tell-me", | ||
"method" : "POST", | ||
"body": "Some message" | ||
|
||
}, | ||
"response":{ | ||
"status": 200, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"request":{ | ||
"url": "/json-response", | ||
"method" : "GET" | ||
|
||
}, | ||
"response":{ | ||
"status": 200, | ||
"body": { | ||
"id": 1, | ||
"node_id": "MDQ6VXNlcjE=", | ||
"avatar_url": "https://github.com/images/error/octocat_happy.gif" | ||
}, | ||
"headers":{ | ||
"Content-Type":"application/json" | ||
} | ||
} | ||
} |
Oops, something went wrong.