forked from karatelabs/karate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathheaders.feature
86 lines (57 loc) · 2.09 KB
/
headers.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
Feature: multiple header management approaches
Background:
Given url demoBaseUrl
And path 'headers'
When method get
Then status 200
# even the responseCookies can be validated using 'match'
And match responseCookies contains { time: '#notnull' }
# example of how to check that a cookie does NOT exist
And match responseCookies !contains { blah: '#notnull' }
And def time = responseCookies.time.value
And def token = response
# note that the responseCookies will be auto-sent as cookies for all future requests
Scenario: configure function
* configure headers = read('classpath:headers.js')
Given path 'headers', token
And param url = demoBaseUrl
When method get
Then status 200
Scenario: configure json
* configure headers = { Authorization: '#(token + time + demoBaseUrl)' }
Given path 'headers', token
And param url = demoBaseUrl
When method get
Then status 200
Scenario: set header
* header Authorization = token + time + demoBaseUrl
Given path 'headers', token
And param url = demoBaseUrl
When method get
Then status 200
Scenario: multi-value headers
* header Authorization = 'dummy', token + time + demoBaseUrl
Given path 'headers', token
And param url = demoBaseUrl
When method get
Then status 200
Scenario: set headers using json
* headers { Authorization: '#(token + time + demoBaseUrl)' }
Given path 'headers', token
And param url = demoBaseUrl
When method get
Then status 200
Scenario: set multi-value headers using json
* headers { Authorization: ['dummy', '#(token + time + demoBaseUrl)'] }
Given path 'headers', token
And param url = demoBaseUrl
When method get
Then status 200
Scenario: set multi-value headers using function call
# this is a test case for an edge case where commas in json confuse cucumber
* def fun = function(arg){ return [arg.first, arg.second] }
* header Authorization = call fun { first: 'dummy', second: '#(token + time + demoBaseUrl)' }
Given path 'headers', token
And param url = demoBaseUrl
When method get
Then status 200