Skip to content

Commit 28c5eaf

Browse files
committed
[fapi] update tests to reflect recent change
1 parent 262149d commit 28c5eaf

File tree

2 files changed

+21
-22
lines changed

2 files changed

+21
-22
lines changed

spec/policy/fapi/fapi_spec.lua

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ local clientCert = assert(fixture('CA', 'client.crt'))
77
local header_parameter = 'x5t#S256'
88

99
local function jwt_cnf()
10-
local cnf = b64.encode_base64url(X509.new(clientCert):digest('SHA256'))
1110
return { [header_parameter] = b64.encode_base64url(X509.new(clientCert):digest('SHA256')) }
1211
end
1312

@@ -36,31 +35,31 @@ describe('fapi_1_baseline_profile policy', function()
3635

3736
describe('.header_filter', function()
3837
it('Use value from request', function()
39-
ngx_req_headers['x-fapi-transaction-id'] = 'abc'
38+
ngx_req_headers['x-fapi-interaction-id'] = 'abc'
4039
local fapi_policy = FAPIPolicy.new({})
4140
fapi_policy:header_filter()
42-
assert.same('abc', ngx.header['x-fapi-transaction-id'])
41+
assert.same('abc', ngx.header['x-fapi-interaction-id'])
4342
end)
4443

45-
it('Only use x-fapi-transaction-id from request if the header also exist in response from upstream', function()
46-
ngx_req_headers['x-fapi-transaction-id'] = 'abc'
47-
ngx_resp_headers['x-fapi-transaction-id'] = 'bdf'
44+
it('Only use x-fapi-interaction-id from request if the header also exist in response from upstream', function()
45+
ngx_req_headers['x-fapi-interaction-id'] = 'abc'
46+
ngx_resp_headers['x-fapi-interaction-id'] = 'bdf'
4847
local fapi_policy = FAPIPolicy.new({})
4948
fapi_policy:header_filter()
50-
assert.same('abc', ngx.header['x-fapi-transaction-id'])
49+
assert.same('abc', ngx.header['x-fapi-interaction-id'])
5150
end)
5251

53-
it('Use x-fapi-transaction-id from upstream response', function()
54-
ngx_resp_headers['x-fapi-transaction-id'] = 'abc'
52+
it('Use x-fapi-interaction-id from upstream response', function()
53+
ngx_resp_headers['x-fapi-interaction-id'] = 'abc'
5554
local fapi_policy = FAPIPolicy.new({})
5655
fapi_policy:header_filter()
57-
assert.same('abc', ngx.header['x-fapi-transaction-id'])
56+
assert.same('abc', ngx.header['x-fapi-interaction-id'])
5857
end)
5958

6059
it('generate uuid if header does not exist in both request and response', function()
6160
local fapi_policy = FAPIPolicy.new({})
6261
fapi_policy:header_filter()
63-
assert.is_true(uuid.is_valid(ngx.header['x-fapi-transaction-id']))
62+
assert.is_true(uuid.is_valid(ngx.header['x-fapi-interaction-id']))
6463
end)
6564
end)
6665

t/apicast-policy-fapi.t

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ run_tests();
2323

2424
__DATA__
2525

26-
=== TEST 1: Enables fapi policy inject x-fapi-transaction-id header to the response
26+
=== TEST 1: Enables fapi policy inject x-fapi-interaction-id header to the response
2727
--- configuration
2828
{
2929
"services": [
@@ -62,9 +62,9 @@ __DATA__
6262
}
6363
}
6464
--- more_headers
65-
x-fapi-transaction-id: abc
65+
x-fapi-interaction-id: abc
6666
--- response_headers
67-
x-fapi-transaction-id: abc
67+
x-fapi-interaction-id: abc
6868
--- request
6969
GET /?user_key=value
7070
--- error_code: 200
@@ -73,7 +73,7 @@ GET /?user_key=value
7373

7474

7575

76-
=== TEST 2: When x-fapi-transaction-id exist in both request and response headers, always use
76+
=== TEST 2: When x-fapi-interaction-id exist in both request and response headers, always use
7777
value from request
7878
--- configuration
7979
{
@@ -109,23 +109,23 @@ value from request
109109
--- upstream
110110
location / {
111111
content_by_lua_block {
112-
ngx.header['x-fapi-transaction-id'] = "blah"
112+
ngx.header['x-fapi-interaction-id'] = "blah"
113113
ngx.exit(200)
114114
}
115115
}
116116
--- more_headers
117-
x-fapi-transaction-id: abc
117+
x-fapi-interaction-id: abc
118118
--- request
119119
GET /?user_key=value
120120
--- response_headers
121-
x-fapi-transaction-id: abc
121+
x-fapi-interaction-id: abc
122122
--- error_code: 200
123123
--- no_error_log
124124
[error]
125125

126126

127127

128-
=== TEST 3: Use x-fapi-transaction-id header from upstream response
128+
=== TEST 3: Use x-fapi-interaction-id header from upstream response
129129
--- configuration
130130
{
131131
"services": [
@@ -160,14 +160,14 @@ x-fapi-transaction-id: abc
160160
--- upstream
161161
location / {
162162
content_by_lua_block {
163-
ngx.header['x-fapi-transaction-id'] = "blah"
163+
ngx.header['x-fapi-interaction-id'] = "blah"
164164
ngx.exit(200)
165165
}
166166
}
167167
--- request
168168
GET /?user_key=value
169169
--- response_headers
170-
x-fapi-transaction-id: blah
170+
x-fapi-interaction-id: blah
171171
--- error_code: 200
172172
--- no_error_log
173173
[error]
@@ -215,7 +215,7 @@ x-fapi-transaction-id: blah
215215
--- request
216216
GET /?user_key=value
217217
--- response_headers_like
218-
x-fapi-transaction-id: [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
218+
x-fapi-interaction-id: [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
219219
--- error_code: 200
220220
--- no_error_log
221221
[error]

0 commit comments

Comments
 (0)