Skip to content

Instantly share code, notes, and snippets.

@gaieges
Created April 9, 2018 22:01
Show Gist options
  • Save gaieges/f08657ea0bde8145030b2d3335263a20 to your computer and use it in GitHub Desktop.
Save gaieges/f08657ea0bde8145030b2d3335263a20 to your computer and use it in GitHub Desktop.
weird
$ docker run -i --rm -v $(pwd):/app -w /app stoplight/prism conduct -e host=https://my.host.com -e token=$TOKEN scenario.yml
Prism version is 2.0.5
[Conductor] Stoplight Exporter Host is https://exporter.stoplight.io
[Conductor] Stoplight API Host is https://next-api.stoplight.io
different scenario Scenario (0.005s)
check if vars work in different scenario, (0.005s)
before.script.info ⁃
before.script.info ⁃
0 - Common Auth Scenario (1.177s)
Setup Script, (0.006s)
Create User, POST https://my.host.com/v1/auth/register/ (0.981s)
✓ output.status (eq) 200
✓ output.body.data.accountId (exists) <nil>
Get users token via bulk token, GET https://my.host.com/v1/auth/get-user-token/?email=c9967b@my.test&ttl=86400 (0.188s)
✓ output.status (eq) 200
✓ output.body.data.accountId (eq) bcb04504c5f44a049cf87e5b06c57b73
check if vars exist in same scenario, (0.002s)
before.script.info ⁃ bcb04504c5f44a049cf87e5b06c57b73
before.script.info ⁃ bcb04504c5f44a049cf87e5b06c57b73
✓ 4 tests passed
scenarios:
sjvmt:
name: 0 - Common Auth
steps:
- type: script
name: Setup Script
input:
script: >-
$.ctx.set('email', Math.random().toString(16).slice(2,8) +
"@my.test");
$.ctx.set('phone', "+47222" + Math.random().toString().slice(2,7));
$.ctx.set('firstName', "TestFirstName");
$.ctx.set('lastName', "TestLastName");
$.ctx.set('country', "NO");
$.ctx.set('locale', "nb-NO");
- type: http
name: Create User
input:
method: post
url: '{$$.env.host}/auth/register/'
headers:
Accept: application/json
Content-Type: application/json
body: |-
{
"firstName": "{$.ctx.firstName}",
"lastName": "{$.ctx.lastName}",
"phoneNumber": "{$.ctx.phone}",
"email": "{$.ctx.email}",
"country": "{$.ctx.country}",
"locale": "{$.ctx.locale}",
"acceptanceTags": [
"fun_tag_here:2017-10-31:"
]
}
after:
transforms:
- target: $.ctx.accountId
source: output.body.data.accountId
assertions:
- target: output.status
op: eq
expected: 200
- target: output.body.data.accountId
op: exists
- type: http
name: Get users token via bulk token
input:
method: get
url: '{$$.env.host}/auth/get-user-token/'
headers:
Accept: application/json
Authorization: 'Bearer {$$.env.token}'
Content-Type: application/json
query:
email: '{$.ctx.email}'
ttl: '86400'
after:
assertions:
- target: output.status
op: eq
expected: 200
- target: output.body.data.accountId
op: eq
expected: '{$.ctx.accountId}'
script: >
$$.env.set('testScript',output.body.get('data').accountId);
transforms:
- target: $$.env.testTransform
source: output.body.data.accountId
- type: script
name: check if vars exist in same scenario
input:
script: >
console.log($$.env.get('testScript'));
console.log($$.env.get('testTransform'));
hjkr5:
name: different scenario
steps:
- type: script
name: check if vars work in different scenario
input:
script: >
console.log($$.env.get('testScript'));
console.log($$.env.get('testTransform'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment