Last active
May 17, 2021 22:22
-
-
Save mertyildiran/104379ace5f123a28bf2023aa36b8646 to your computer and use it in GitHub Desktop.
Mockintosh: mocks for microservice environments - Part 2: HTTP Request Matching
This file contains hidden or 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
| services: | |
| - port: 8081 | |
| endpoints: | |
| - path: "/example/path/{{my_variable}}/lastsegment" | |
| response: "my_variable is captured: {{my_variable}}" |
This file contains hidden or 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
| services: | |
| - port: 8081 | |
| endpoints: | |
| - path: "/example/path/{{x}}-middle-{{y}}/lastsegment" | |
| response: "x is: {{x}} and y is: {{y}}" |
This file contains hidden or 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
| services: | |
| - port: 8081 | |
| endpoints: | |
| - path: "/example/path/{{regEx '(\\d)' 'x'}}/lastsegment" | |
| response: "x is: {{x}}" |
This file contains hidden or 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
| services: | |
| - port: 8081 | |
| endpoints: | |
| - path: "/example" | |
| method: GET | |
| response: "Matched to GET /example" | |
| - path: "/example" | |
| method: POST | |
| response: "Matched to POST /example" | |
| - path: "/example" | |
| method: PUT | |
| response: "Matched to PUT /example" | |
| - path: "/example" | |
| method: PATCH | |
| response: "Matched to PATCH /example" |
This file contains hidden or 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
| services: | |
| - port: 8081 | |
| endpoints: | |
| - path: "/static-value" | |
| method: GET | |
| queryString: | |
| param1: my Value | |
| response: | |
| body: 'matched with static value: {{request.queryString.param1}}' | |
| status: 200 | |
| - path: "/alternative" | |
| method: GET | |
| queryString: | |
| param1: my Value | |
| param2: "{{myVar}}" | |
| param3: "{{regEx 'prefix-(.+)-suffix' 'myCapturedVar'}}" | |
| response: | |
| body: 'query string match: {{request.queryString.param1}} {{myVar}} {{myCapturedVar}}' | |
| status: 201 | |
| - path: "/alternative" | |
| method: GET | |
| queryString: | |
| param4: another query string | |
| response: | |
| body: 'param4 request query string: {{request.queryString.param4}}' |
This file contains hidden or 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
| services: | |
| - port: 8081 | |
| endpoints: | |
| - path: "/alternative" | |
| method: GET | |
| headers: | |
| hdr1: myValue | |
| hdr2: "{{myVar}}" | |
| hdr3: "{{regEx 'prefix-(.+)-suffix' 'myCapturedVar'}}" | |
| response: | |
| body: 'headers match: {{request.headers.hdr1}} {{myVar}} {{myCapturedVar}}' | |
| status: 201 | |
| headers: | |
| Set-Cookie: | |
| - name1={{request.headers.hdr2}} | |
| - name2={{request.headers.hdr3}} | |
| - path: "/alternative" | |
| headers: | |
| hdr4: another header | |
| response: | |
| body: 'hdr4 request header: {{request.headers.hdr4}}' | |
| headers: | |
| hdr4: 'hdr4 request header: {{request.headers.hdr4}}' |
This file contains hidden or 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
| services: | |
| - name: Mock for Service1 | |
| port: 8081 | |
| endpoints: | |
| - path: "/example" | |
| method: POST | |
| body: | |
| text: {{regEx 'expectedval-(.+)' 'namedValue'}} |
This file contains hidden or 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
| services: | |
| - port: 8081 | |
| endpoints: | |
| - path: "/body-urlencoded" | |
| method: POST | |
| body: | |
| urlencoded: | |
| param1: myValue | |
| param2: "{{myVar}}" | |
| param3: "{{regEx 'prefix-(.+)-suffix' 'myCapturedVar'}}" | |
| - path: "/body-multipart" | |
| method: POST | |
| body: | |
| multipart: | |
| param1: myValue | |
| param2: "{{myVar}}" | |
| param3: "{{regEx 'prefix-(.+)-suffix' 'myCapturedVar'}}" |
This file contains hidden or 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
| services: | |
| - name: Mock for Service1 | |
| port: 8081 | |
| endpoints: | |
| - path: "/example" | |
| method: POST | |
| body: | |
| schema: | |
| type: object | |
| properties: | |
| somekey: { } | |
| required: | |
| - somekey | |
| response: 'example: body JSON schema matched' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment