-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from bavix/headers-support
[2.1] Add headers support
- Loading branch information
Showing
32 changed files
with
653 additions
and
229 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
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
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
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
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
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
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,66 @@ | ||
## Headers Matching | ||
Stub will respond with the expected response only if the request matches any rule. Stub service will serve `/api/stubs/search` endpoint with format: | ||
```json | ||
{ | ||
"service":"<service name>", | ||
"method":"<method name>", | ||
"data":{ | ||
// input that suppose to match with stored stubs | ||
} | ||
} | ||
``` | ||
So if you do a `curl -X POST -d '{"service":"Greeter","method":"SayHello","data":{"name":"gripmock"}}' localhost:4771/api/stubs/search` stub service will find a match from listed stubs stored there. | ||
|
||
### Headers Matching Rule | ||
Headers matching has 3 rules to match an input: **equals**,**contains** and **matches** | ||
<br> | ||
Headers can consist of a key and a value. If there are several values, then you need to list them separated by ";". Data type string. | ||
<br> | ||
**Gripmock** recursively goes over the fields and tries to match with given input. | ||
<br> | ||
**equals** will match the exact field name and value of input into expected stub. example stub JSON: | ||
```json | ||
{ | ||
. | ||
. | ||
"headers":{ | ||
"equals":{ | ||
"authorization": "mytoken", | ||
"system": "ec071904-93bf-4ded-b49c-d06097ddc6d5" | ||
} | ||
} | ||
. | ||
. | ||
} | ||
``` | ||
|
||
**contains** will match input that has the value declared expected fields. example stub JSON: | ||
```json | ||
{ | ||
. | ||
. | ||
"headers":{ | ||
"contains":{ | ||
"field2":"hello" | ||
} | ||
} | ||
. | ||
. | ||
} | ||
``` | ||
|
||
**matches** using regex for matching fields expectation. example: | ||
|
||
```json | ||
{ | ||
. | ||
. | ||
"headers":{ | ||
"matches":{ | ||
"name":"^grip.*$" | ||
} | ||
} | ||
. | ||
. | ||
} | ||
``` |
Oops, something went wrong.