Skip to content

Commit 10bd80d

Browse files
committed
Testing no redirect
1 parent 1439114 commit 10bd80d

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

build.sh

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,23 @@ else
2727
echo -e "${RED}Secure test without jwt fail ${TEST_SECURE_EXPECT_302}${NONE}";
2828
fi
2929

30-
TEST_SECURE_EXPECT_200=`curl -X GET -o /dev/null --silent --head --write-out '%{http_code}\n' http://${MACHINE_IP}:8000/secure/index.html -H 'cache-control: no-cache' --cookie "rampartjwt=${VALIDJWT}"`
31-
if [ "$TEST_SECURE_EXPECT_200" -eq "200" ];then
32-
echo -e "${GREEN}Secure test with jwt pass ${TEST_SECURE_EXPECT_200}${NONE}";
30+
TEST_SECURE_COOKIE_EXPECT_200=`curl -X GET -o /dev/null --silent --head --write-out '%{http_code}\n' http://${MACHINE_IP}:8000/secure/index.html -H 'cache-control: no-cache' --cookie "rampartjwt=${VALIDJWT}"`
31+
if [ "$TEST_SECURE_COOKIE_EXPECT_200" -eq "200" ];then
32+
echo -e "${GREEN}Secure test with jwt pass ${TEST_SECURE_COOKIE_EXPECT_200}${NONE}";
3333
else
34-
echo -e "${RED}Secure test with jwt fail ${TEST_SECURE_EXPECT_200}${NONE}";
34+
echo -e "${RED}Secure test with jwt fail ${TEST_SECURE_COOKIE_EXPECT_200}${NONE}";
3535
fi
3636

37-
TEST_SECURE_EXPECT_200=`curl -X GET -o /dev/null --silent --head --write-out '%{http_code}\n' http://${MACHINE_IP}:8000/secure/index.html -H 'cache-control: no-cache' --header "Authorization: Bearer ${VALIDJWT}" --cookie "rampartjwt=${VALIDJWT}"`
38-
if [ "$TEST_SECURE_EXPECT_200" -eq "200" ];then
39-
echo -e "${GREEN}Secure test with jwt and auth header pass ${TEST_SECURE_EXPECT_200}${NONE}";
37+
TEST_SECURE_HEADER_EXPECT_200=`curl -X GET -o /dev/null --silent --head --write-out '%{http_code}\n' http://${MACHINE_IP}:8000/secure/index.html -H 'cache-control: no-cache' --header "Authorization: Bearer ${VALIDJWT}" --cookie "rampartjwt=${VALIDJWT}"`
38+
if [ "$TEST_SECURE_HEADER_EXPECT_200" -eq "200" ];then
39+
echo -e "${GREEN}Secure test with jwt and auth header pass ${TEST_SECURE_HEADER_EXPECT_200}${NONE}";
4040
else
41-
echo -e "${RED}Secure test with jwt and auth header fail ${TEST_SECURE_EXPECT_200}${NONE}";
41+
echo -e "${RED}Secure test with jwt and auth header fail ${TEST_SECURE_HEADER_EXPECT_200}${NONE}";
42+
fi
43+
44+
TEST_SECURE_NO_REDIRECT_EXPECT_401=`curl -X GET -o /dev/null --silent --head --write-out '%{http_code}\n' http://${MACHINE_IP}:8000/secure-no-redirect/index.html`
45+
if [ "$TEST_SECURE_NO_REDIRECT_EXPECT_401" -eq "401" ];then
46+
echo -e "${GREEN}Secure test with jwt and auth header pass ${TEST_SECURE_NO_REDIRECT_EXPECT_401}${NONE}";
47+
else
48+
echo -e "${RED}Secure test with jwt and auth header fail ${TEST_SECURE_NO_REDIRECT_EXPECT_401}${NONE}";
4249
fi

resources/test-jwt-nginx.conf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ server {
77
listen 8000;
88
server_name localhost;
99

10+
___location ~ ^/secure-no-redirect/ {
11+
auth_jwt_enabled on;
12+
auth_jwt_redirect off;
13+
alias /usr/share/nginx/secure/;
14+
}
15+
1016
___location ~ ^/secure/ {
1117
auth_jwt_enabled on;
1218
root /usr/share/nginx;

0 commit comments

Comments
 (0)