@@ -56,25 +56,25 @@ run_test () {
5656 printf " ${RED}${name} -- unexpected exit code from cURL\n\tcURL Exit Code: ${exitCode} " ;
5757 NUM_FAILED=$(( ${NUM_FAILED} + 1 )) ;
5858 else
59- OKAY =1
59+ local okay =1
6060
6161 if [ " ${expectedCode} " != " " ]; then
6262 local responseCode=$( echo " ${response} " | grep -Eo ' HTTP/1.1 ([0-9]{3})' | awk ' {print $2}' )
6363
6464 if [ " ${expectedCode} " != " ${responseCode} " ]; then
6565 printf " ${RED}${name} -- unexpected status code\n\tExpected: ${expectedCode} \n\tActual: ${responseCode} \n\tPath: ${path} "
6666 NUM_FAILED=$(( ${NUM_FAILED} + 1 ))
67- OKAY =0
67+ okay =0
6868 fi
6969 fi
70-
71- if [ " ${OKAY } " == " 1 " ] && [ " ${expectedResponseRegex} " != " " ] && echo " ${response} " | grep -Eq " ${expectedResponseRegex} " ; then
70+
71+ if [ " ${okay } " == ' 1 ' ] && [ " ${expectedResponseRegex} " != " " ] && ! [[ " ${response} " =~ " ${expectedResponseRegex} " ]] ; then
7272 printf " ${RED}${name} -- regex not found in response\n\tPath: ${path} \n\tRegEx: ${expectedResponseRegex} "
7373 NUM_FAILED=$(( ${NUM_FAILED} + 1 ))
74- OKAY =0
74+ okay =0
7575 fi
7676
77- if [ " ${OKAY } " == " 1 " ]; then
77+ if [ " ${okay } " == ' 1 ' ]; then
7878 printf " ${GREEN}${name} " ;
7979 fi
8080 fi
@@ -197,34 +197,64 @@ main() {
197197 -c ' 200' \
198198 -x ' --header "Auth-Token: Bearer ${JWT_HS256_VALID}"'
199199
200- run_test -n ' extracts single claim to request header ' \
200+ run_test -n ' extracts single claim to request variable ' \
201201 -p ' /secure/extract-claim/request/sub' \
202- -r ' ^ Test: sub=some-long-uuid$ ' \
202+ -r ' < Test: sub=some-long-uuid' \
203203 -x ' --header "Authorization: Bearer ${JWT_HS256_VALID}"'
204204
205- run_test -n ' extracts multiple claims (single directive) to request header ' \
205+ run_test -n ' extracts multiple claims (single directive) to request variable ' \
206206 -p ' /secure/extract-claim/request/name-1' \
207- -r ' ^ Test: hello world$ ' \
207+ -r ' < Test: firstName= hello; lastName= world' \
208208 -x ' --header "Authorization: Bearer ${JWT_HS256_VALID}"'
209209
210- run_test -n ' extracts multiple claims (multiple directives) to request header ' \
210+ run_test -n ' extracts multiple claims (multiple directives) to request variable ' \
211211 -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' \
213238 -x ' --header "Authorization: Bearer ${JWT_HS256_VALID}"'
214239
215240 run_test -n ' extracts single claim to response header' \
216241 -p ' /secure/extract-claim/response/sub' \
217- -r ' ^Test: sub= some-long-uuid$ ' \
242+ -r ' < JWT- sub: some-long-uuid' \
218243 -x ' --header "Authorization: Bearer ${JWT_HS256_VALID}"'
219244
220245 run_test -n ' extracts multiple claims (single directive) to response header' \
221246 -p ' /secure/extract-claim/response/name-1' \
222- -r ' ^Test : hello world$ ' \
247+ -r ' < JWT-firstName : hello' \
223248 -x ' --header "Authorization: Bearer ${JWT_HS256_VALID}"'
224249
225250 run_test -n ' extracts multiple claims (multiple directives) to response header' \
226251 -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' \
228258 -x ' --header "Authorization: Bearer ${JWT_HS256_VALID}"'
229259
230260 if [[ " ${NUM_FAILED} " = ' 0' ]]; then
0 commit comments