@@ -56,25 +56,25 @@ run_test () {
56
56
printf " ${RED}${name} -- unexpected exit code from cURL\n\tcURL Exit Code: ${exitCode} " ;
57
57
NUM_FAILED=$(( ${NUM_FAILED} + 1 )) ;
58
58
else
59
- OKAY =1
59
+ local okay =1
60
60
61
61
if [ " ${expectedCode} " != " " ]; then
62
62
local responseCode=$( echo " ${response} " | grep -Eo ' HTTP/1.1 ([0-9]{3})' | awk ' {print $2}' )
63
63
64
64
if [ " ${expectedCode} " != " ${responseCode} " ]; then
65
65
printf " ${RED}${name} -- unexpected status code\n\tExpected: ${expectedCode} \n\tActual: ${responseCode} \n\tPath: ${path} "
66
66
NUM_FAILED=$(( ${NUM_FAILED} + 1 ))
67
- OKAY =0
67
+ okay =0
68
68
fi
69
69
fi
70
-
71
- if [ " ${OKAY } " == " 1 " ] && [ " ${expectedResponseRegex} " != " " ] && echo " ${response} " | grep -Eq " ${expectedResponseRegex} " ; then
70
+
71
+ if [ " ${okay } " == ' 1 ' ] && [ " ${expectedResponseRegex} " != " " ] && ! [[ " ${response} " =~ " ${expectedResponseRegex} " ]] ; then
72
72
printf " ${RED}${name} -- regex not found in response\n\tPath: ${path} \n\tRegEx: ${expectedResponseRegex} "
73
73
NUM_FAILED=$(( ${NUM_FAILED} + 1 ))
74
- OKAY =0
74
+ okay =0
75
75
fi
76
76
77
- if [ " ${OKAY } " == " 1 " ]; then
77
+ if [ " ${okay } " == ' 1 ' ]; then
78
78
printf " ${GREEN}${name} " ;
79
79
fi
80
80
fi
@@ -197,34 +197,64 @@ main() {
197
197
-c ' 200' \
198
198
-x ' --header "Auth-Token: Bearer ${JWT_HS256_VALID}"'
199
199
200
- run_test -n ' extracts single claim to request header ' \
200
+ run_test -n ' extracts single claim to request variable ' \
201
201
-p ' /secure/extract-claim/request/sub' \
202
- -r ' ^ Test: sub=some-long-uuid$ ' \
202
+ -r ' < Test: sub=some-long-uuid' \
203
203
-x ' --header "Authorization: Bearer ${JWT_HS256_VALID}"'
204
204
205
- run_test -n ' extracts multiple claims (single directive) to request header ' \
205
+ run_test -n ' extracts multiple claims (single directive) to request variable ' \
206
206
-p ' /secure/extract-claim/request/name-1' \
207
- -r ' ^ Test: hello world$ ' \
207
+ -r ' < Test: firstName= hello; lastName= world' \
208
208
-x ' --header "Authorization: Bearer ${JWT_HS256_VALID}"'
209
209
210
- run_test -n ' extracts multiple claims (multiple directives) to request header ' \
210
+ run_test -n ' extracts multiple claims (multiple directives) to request variable ' \
211
211
-p ' /secure/extract-claim/request/name-2' \
212
- -r ' ^Test: hello world$' \
212
+ -r ' < Test: firstName=hello; lastName=world' \
213
+ -x ' --header "Authorization: Bearer ${JWT_HS256_VALID}"'
214
+
215
+ run_test -n ' extracts nested claim to request variable' \
216
+ -p ' /secure/extract-claim/request/nested' \
217
+ -r ' < Test: username=hello.world' \
218
+ -x ' --header "Authorization: Bearer ${JWT_HS256_VALID}"'
219
+
220
+ run_test -n ' extracts single claim to response variable' \
221
+ -p ' /secure/extract-claim/response/sub' \
222
+ -r ' < Test: sub=some-long-uuid' \
223
+ -x ' --header "Authorization: Bearer ${JWT_HS256_VALID}"'
224
+
225
+ run_test -n ' extracts multiple claims (single directive) to response variable' \
226
+ -p ' /secure/extract-claim/response/name-1' \
227
+ -r ' < Test: firstName=hello; lastName=world' \
228
+ -x ' --header "Authorization: Bearer ${JWT_HS256_VALID}"'
229
+
230
+ run_test -n ' extracts multiple claims (multiple directives) to response variable' \
231
+ -p ' /secure/extract-claim/response/name-2' \
232
+ -r ' < Test: firstName=hello; lastName=world' \
233
+ -x ' --header "Authorization: Bearer ${JWT_HS256_VALID}"'
234
+
235
+ run_test -n ' extracts nested claim to response variable' \
236
+ -p ' /secure/extract-claim/response/nested' \
237
+ -r ' < Test: username=hello.world' \
213
238
-x ' --header "Authorization: Bearer ${JWT_HS256_VALID}"'
214
239
215
240
run_test -n ' extracts single claim to response header' \
216
241
-p ' /secure/extract-claim/response/sub' \
217
- -r ' ^Test: sub= some-long-uuid$ ' \
242
+ -r ' < JWT- sub: some-long-uuid' \
218
243
-x ' --header "Authorization: Bearer ${JWT_HS256_VALID}"'
219
244
220
245
run_test -n ' extracts multiple claims (single directive) to response header' \
221
246
-p ' /secure/extract-claim/response/name-1' \
222
- -r ' ^Test : hello world$ ' \
247
+ -r ' < JWT-firstName : hello' \
223
248
-x ' --header "Authorization: Bearer ${JWT_HS256_VALID}"'
224
249
225
250
run_test -n ' extracts multiple claims (multiple directives) to response header' \
226
251
-p ' /secure/extract-claim/response/name-2' \
227
- -r ' ^Test: hello world$' \
252
+ -r ' < JWT-firstName: hello' \
253
+ -x ' --header "Authorization: Bearer ${JWT_HS256_VALID}"'
254
+
255
+ run_test -n ' extracts nested claim to response header' \
256
+ -p ' /secure/extract-claim/response/nested' \
257
+ -r ' < JWT-username: hello.world' \
228
258
-x ' --header "Authorization: Bearer ${JWT_HS256_VALID}"'
229
259
230
260
if [[ " ${NUM_FAILED} " = ' 0' ]]; then
0 commit comments