forked from apickli/apickli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
injecting-variables.feature
133 lines (113 loc) · 5.95 KB
/
injecting-variables.feature
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
@core
Feature:
As Httpbin client I want to use variables in my feature files
#test variable injection logic
Scenario: using unknown variable in request path
When I GET /get?foo=`UNKNOWN_VARIABLE`
#replace unknown variables with empty string
Then response body path $.args.foo should not be UNKNOWN_VARIABLE
Scenario: using scenario variable
Given I store the raw value bar as value1 in scenario scope
When I GET /get?foo=`value1`
Then response body path $.args.foo should be bar
@jarl
Scenario: using long named variables
Given I store the raw value A as variableWithAVeryVeryVeryLongNameAndAShortValueA in scenario scope
And I store the raw value B as v2 in scenario scope
When I GET /get?var1=`variableWithAVeryVeryVeryLongNameAndAShortValueA`&var2=`v2`
Then response body path $.args.var1 should be A
And response body path $.args.var2 should be B
#test injection logic with other step definitions
Scenario: Setting headers with variables
Given I store the raw value apickli as foo in scenario scope
And I set User-Agent header to `foo`
When I GET /get
Then response body path $.headers.User-Agent should be apickli
Scenario: Calling a resource with variables
Given I store the raw value /get as myResourcePath in scenario scope
When I GET `myResourcePath`
Then response body path $.url should be (.*)/get
Scenario: Setting headers in datatable with variables
Given I store the raw value apickli as foo in scenario scope
And I store the raw value Accept as bar in scenario scope
And I set headers to
|name|value|
|User-Agent|`foo`|
|`bar`|application/json|
When I GET /get
Then response body path $.headers.Accept should be application/json
And response body path $.headers.User-Agent should be apickli
Scenario: Setting body payload using variables
Given I store the raw value {"key":"hello-world"} as myPayload in scenario scope
And I set body to `myPayload`
When I POST to /post
Then response body should contain hello-world
Scenario: Setting body payload from file using variable
Given I store the raw value ./test/features/fixtures/requestBody.xml as myFilePath in scenario scope
And I pipe contents of file `myFilePath` to body
When I POST to /post
Then response body should contain "<a>b</a>"
Scenario: Sending request with basic auth authentication using variables
Given I store the raw value username as myUsername in scenario scope
And I store the raw value password as myPassword in scenario scope
Given I have basic authentication credentials `myUsername` and `myPassword`
When I POST to /post
Then response body path $.headers.Authorization should be Basic dXNlcm5hbWU6cGFzc3dvcmQ=
Scenario: Response code checks
Given I store the raw value 200 as myCode in scenario scope
And I store the raw value 404 as myIncorrectCode in scenario scope
When I GET /xml
Then response code should be `myCode`
And response code should not be `myIncorrectCode`
Scenario: Response header value assertions
Given I store the raw value Content-Type as myHeaderName in scenario scope
And I store the raw value [a-z]/xml as myHeaderValue in scenario scope
And I store the raw value boo as myHeaderIncorrectValue in scenario scope
When I GET /xml
Then response header `myHeaderName` should be application/xml
And response header Content-Type should be `myHeaderValue`
And response header Connection should not be `myHeaderIncorrectValue`
Scenario: Response body text assertions
Given I store the raw value WonderWidgets as correctValue in scenario scope
And I store the raw value boo as incorrectValue in scenario scope
When I GET /xml
Then response body should contain `correctValue`
And response body should not contain `incorrectValue`
Scenario: Response body xpath assertions
Given I store the raw value /slideshow/slide[2]/title as myPath in scenario scope
Given I store the raw value [a-z]+ as correctValue in scenario scope
And I store the raw value \d+ as incorrectValue in scenario scope
When I GET /xml
Then response body path `myPath` should be `correctValue`
And response body path `myPath` should not be `incorrectValue`
Scenario: Access token retrieval from response body (authorization code grant, password, client credentials)
Given I store the raw value $.headers.Token as myTokenPath in scenario scope
And I set Token header to token123
When I GET /get
Then I store the value of body path `myTokenPath` as access token
Given I set bearer token
When I GET /get
Then response body path $.headers.Authorization should be Bearer token123
Scenario: checking values of query parameter passed as datatable
Given I store the raw value argument1 as myParam in scenario scope
And I store the raw value test as myVal in scenario scope
And I set query parameters to
|parameter|value|
|argument1|`myParam`|
|argument2|`myVal`|
When I GET /get
Then response body path $.args.argument1 should be 1
And response body path $.args.argument2 should be test
Scenario: should successfully validate json using schema
Given I store the raw value ./test/features/fixtures/get-simple.schema as schemaPath in scenario scope
When I GET /get
Then response body should be valid according to schema file `schemaPath`
Scenario: should successfully validate json using the OpenAPI spec description
Given I store the raw value ./test/features/fixtures/get-simple-swagger-spec.json as swaggerSpecPath in scenario scope
When I GET /get
Then response body should be valid according to schema file `swaggerSpecPath`
Scenario: should successfully validate json array
Given I store the raw value 3 as myLength in scenario scope
And I set body to ["a","b","c"]
When I POST to /post
And response body path $.json should be of type array with length `myLength`