Created
January 8, 2021 16:43
-
-
Save zgiber/10a47c704992001190245a8df904bb3d to your computer and use it in GitHub Desktop.
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
# Such manifests may be broken up to any number of multiple files. | |
# Using map vs slice to enable referencing scenarios by ID in a dynamic structure. | |
# (TBD; there might be a neater solution but i'm happy with this so far) | |
--- | |
scenarios: | |
S000: | |
description: some http call to some endpoint where we expects some response values | |
request: | |
uri: "/fakeauth" | |
method: post | |
headers: | |
set: | |
Content-Type: application/json | |
X-whatever-value: hello | |
# X-current-time-custom: ["$fn:now", "$references.customTimeFormat"] | |
X-current-time: ["$fn:now"] | |
someValue: ["$fn:uuid"] | |
someOtherValue: ["$fn:uuid"] | |
# body sets the contents for the request body | |
body: "$references.authBody" | |
# patchBody is an optional field, providing a mechanism to modify smaller details the request body | |
patchBody: | |
set: | |
path1.to.set: "$references.someValue0" | |
path2.to.set: "$references.someValue1" | |
assertions: | |
# all assertions are evaluated (and) | |
# oneOf assertions can be defined in the assertions section implementing (or) relations. | |
- responseCreatedOK | |
- isValidHeaderForSomeCases | |
# - isValidResponseBodyForThisScenario | |
S001: | |
description: another http call to some endpoint where we expects some response values | |
request: | |
uri: "/path" | |
method: post | |
headers: | |
set: | |
Content-Type: application/json | |
X-whatever-value: hello | |
X-current-time-custom: ["$fn:now", "$references.customTimeFormat"] | |
X-current-time: ["$fn:now"] | |
someValue: ["$fn:uuid"] | |
someOtherValue: ["$fn:uuid"] | |
Authorization: ["$fn:join", "Bearer ", "$scenarios.S000.response.body.token"] | |
remove: | |
- header1-to-remove | |
- header2-to-remove | |
# body sets the contents for the request body | |
body: {} | |
# patchBody is an optional field, providing a mechanism to modify smaller details the request body | |
patchBody: | |
set: | |
path1.to.set: "$references.someValue1" | |
path2.to.set: "$references.someValue2" | |
# not implemented | |
# remove: | |
# - path1.to.remove | |
# - path2.to.remove | |
assertions: | |
# all assertions are evaluated (and) | |
# oneOf assertions can be defined in the assertions section implementing (or) relations. | |
- responseCreatedOK | |
- isValidHeaderForSomeCases | |
# - isValidResponseBodyForThisScenario | |
assertions: | |
# An assertion is a named list of objects, where each list item is {functionName: [params...]} | |
# the functions are evaluated in order, and the response is fn0 && fn1 && ... fnN | |
# '$response' references would be local to the scenario the assertion is performed on. | |
# (if there is a neat way to do that :)) | |
responseOK: | |
- isEqual: ["$response.statusCode", 200] | |
# alternatively use the function syntax? | |
# ["$fn:isEqual", "$response.statusCode", "200"] | |
# or as yaml: | |
# - $fn:isEqual | |
# - $response.statusCode | |
# - 200 | |
responseCreated: | |
- isEqual: ["$response.statusCode", 201] | |
responseCreatedOK: | |
# isOneOf references other assertions by name | |
- isOneOf: ["$responseOK", "$responseCreated"] | |
isValidHeaderForSomeCases: | |
# - isValidJSONSchema: ["$response.header.something", "$JSONSchemas.path"] | |
- isEqual: ["$response.header.something", "expected-value"] | |
isValidResponseBodyForCaseA: | |
- isValidJSONSchema: ["$response.body", "$JSONSchemas.mySchema1.path.to.bodyA"] | |
isValidResponseBodyForCaseB: | |
- isValidJSONSchema: ["$response.body", "$JSONSchemas.mySchema1.path.to.bodyB"] | |
references: | |
# Named values which can freely be reused among scenarios | |
authBody: {"i am":"z"} | |
customTimeFormat: "2006-01-02 15:04:05Z" | |
someValue0: {"answer": "value1"} | |
someValue1: {"answer": "value2"} | |
someValue2: {"answer": "value3"} | |
JSONSchemas: | |
# a named collection of links to jsonschema objects or actual jsonschemas embedded | |
mySchema1: http://somelocation.org.uk/something.json | |
mySchema2: http://somelocation.org.uk/anotherthing.json | |
configuration: | |
# configuration values which are global to all scenarios and are required to be set by the tester | |
# (certificates, base url, etc.) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment