Skip to content

Commit

Permalink
extend overwrites for handling overwriteRequestSecurity (#124)
Browse files Browse the repository at this point in the history
* extend overwrites for handling overwriteRequestSecurity

* add example and update tests

* add "other" for fallback auth definition
  • Loading branch information
nicklloyd authored Aug 2, 2021
1 parent 7a60d08 commit d462a7f
Show file tree
Hide file tree
Showing 16 changed files with 7,410 additions and 156 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## v1.7.0 - (2021-08-02)

### Enhancement

- Added overwrite `overwriteRequestSecurity` to be able to fine tune auth on a request level. This allows you to (for example) ensure all operations are authenticated via variation tests.

## v1.6.2 - (2021-08-02)

### Housekeeping
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,10 @@ To facilitate automation, you might want to modify properties with "randomized"
- **overwrite (Boolean true/false | Default: true)** : Overwrites the request body value OR attaches the value to the original request body value.
- **remove (Boolean true/false | Default: false)** : Removes the request body property, including the value.

- **overwriteRequestSecurity (Object)** :

A Postman RequestAuthDefinition object that will be applied to the request.

For more details, review the [overwrites example](https://github.com/apideck-libraries/portman/tree/main/examples/testsuite-overwrites).

<hr>
Expand Down
29 changes: 26 additions & 3 deletions __tests__/fixtures/portman-variations.crm.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
"contractTests": [
{
"openApiOperation": "*::/crm/*",
"excludeForOperations": [
"GET::/crm/companies"
],
"excludeForOperations": ["GET::/crm/companies"],
"statusSuccess": {
"enabled": true
}
Expand Down Expand Up @@ -63,6 +61,31 @@
}
],
"variationTests": [
{
"openApiOperationId": "leadsAdd",
"variations": [
{
"openApiResponse": "403",
"name": "InvalidAuth",
"overwrites": [
{
"overwriteRequestSecurity": {
"bearer": { "token": "not_a_real_token" }
}
}
],
"tests": {
"contractTests": [
{
"statusCode": {
"enabled": true
}
}
]
}
}
]
},
{
"openApiOperationId": "leadsAdd",
"variations": [
Expand Down
97 changes: 92 additions & 5 deletions examples/cli-filtering/filtered-crm.leads.yml

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion examples/testsuite-overwrites/portman-config.crm.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,12 @@
"remove": true
}
]
},
{
"openApiOperationId": "leadsAll",
"overwriteRequestSecurity": {
"bearer": { "token": "{{managementToken}}" }
}
}
]

}
25 changes: 25 additions & 0 deletions examples/testsuite-variation-tests/portman-config.crm.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,31 @@
}
],
"variationTests": [
{
"openApiOperation": "*::/crm/*",
"variations": [
{
"openApiResponse": "401",
"name": "Unauthorized",
"overwrites": [
{
"overwriteRequestSecurity": {
"bearer": { "token": "bogus_token" }
}
}
],
"tests": {
"contractTests": [
{
"statusCode": {
"enabled": true
}
}
]
}
}
]
},
{
"openApiOperationId": "leadsAdd",
"variations": [
Expand Down
Loading

0 comments on commit d462a7f

Please sign in to comment.