Skip to content

Commit

Permalink
Adapt role collection names in test scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
kuntzed committed Oct 30, 2024
1 parent a21e6aa commit 051c742
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions samples/deploy_and_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def test_hello_java_security_authz(self):
resp = self.perform_get_request_with_token('/hello-java-security-authz')
self.assertEqual(403, resp.status, EXPECT_403)

self.add_user_to_role('JAVA_SECURITY_SAMPLE_Viewer')
self.add_user_to_role('Sample Viewer (java-security-usage)')
resp = self.perform_get_request_with_token('/hello-java-security-authz')
self.assertEqual(200, resp.status, EXPECT_200)

Expand All @@ -301,7 +301,7 @@ def test_sayHello_xsuaa(self):
resp = self.perform_get_request_with_token('/sayHello')
self.assertEqual(403, resp.status, EXPECT_403)

self.add_user_to_role('XSUAA-Viewer')
self.add_user_to_role('Sample Viewer (spring-security-hybrid-usage)')
resp = self.perform_get_request_with_token('/sayHello')
self.assertEqual(200, resp.status, EXPECT_200)
clientid = self.get_deployed_app().get_credentials_property('clientid')
Expand Down Expand Up @@ -437,7 +437,7 @@ def test_hello_token_servlet(self):
resp = self.perform_get_request_with_token('/hello-token')
self.assertEqual(403, resp.status, EXPECT_403)

self.add_user_to_role('Buildpack_API_Viewer')
self.add_user_to_role('Sample Viewer (sap-java-buildpack-api-usage)')
resp = self.perform_get_request_with_token('/hello-token')
self.assertEqual(200, resp.status, EXPECT_200)
self.assertRegex(resp.body, self.credentials.username, 'Expected to find username in response')
Expand All @@ -463,7 +463,7 @@ def test_fetch_token_status_ok(self):
# app restart needed because tokens are cached in application
self.cf_app.restart()
logging.info(RUN_TEST.format("SpringSecurityBasicAuthTest.test_fetch_token_status_ok"))
self.add_user_to_role('BASIC_AUTH_API_Viewer')
self.add_user_to_role('Sample Viewer (spring-security-basic-auth)')
resp = self.perform_get_request('/fetchToken', username=self.credentials.username,
password=self.credentials.password)
self.assertEqual(200, resp.status, EXPECT_200)
Expand All @@ -487,7 +487,7 @@ def test_say_hello(self):
resp = self.perform_get_request_with_token('/v1/sayHello')
self.assertEqual(403, resp.status, EXPECT_403)

self.add_user_to_role('Webflux_API_Viewer')
self.add_user_to_role('Sample Viewer (spring-webflux-security-hybrid-usage)')
resp = self.perform_get_request_with_token('/v1/sayHello')
self.assertEqual(200, resp.status, EXPECT_200)
self.assertRegex(resp.body, self.credentials.username, 'Expected to find username in response')
Expand Down
6 changes: 3 additions & 3 deletions samples/k8s-deploy-and-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ for sample in "${SAMPLES[@]}"; do
token=$(get_token "$(declare -p serviceConfig)")
resultList[1]=$(execute_test "$host" "sayHello" 403 "Bearer $token")

add_user_to_role "$(declare -p serviceConfig)" XSUAA-Viewer
add_user_to_role "$(declare -p serviceConfig)" "Sample Viewer (spring-security-hybrid-usage)"
token=$(get_token "$(declare -p serviceConfig)")
resultList[2]=$(execute_test "$host" "sayHello" 200 "Bearer $token")
;;
Expand All @@ -209,7 +209,7 @@ for sample in "${SAMPLES[@]}"; do
resultList[2]=$(execute_test "$host" "java-security-usage/hello-java-security" 200 "Bearer $token")
resultList[3]=$(execute_test "$host" "java-security-usage/hello-java-security-authz" 403 "Bearer $token")

add_user_to_role "$(declare -p serviceConfig)" JAVA_SECURITY_SAMPLE_Viewer
add_user_to_role "$(declare -p serviceConfig)" "Sample Viewer (java-security-usage)"
token=$(get_token "$(declare -p serviceConfig)")
resultList[4]=$(execute_test "$host" "java-security-usage/hello-java-security-authz" 200 "Bearer $token")
;;
Expand All @@ -219,7 +219,7 @@ for sample in "${SAMPLES[@]}"; do
credentials=$(echo -n "$USER:$PASSWORD" | base64)
resultList[1]=$(execute_test "$host" "fetchToken" 403 "Basic $credentials")

add_user_to_role "$(declare -p serviceConfig)" BASIC_AUTH_API_Viewer
add_user_to_role "$(declare -p serviceConfig)" "Sample Viewer (spring-security-basic-auth)"
resultList[2]=$(execute_test "$host" "fetchToken" 200 "Basic $credentials")
;;
esac
Expand Down

0 comments on commit 051c742

Please sign in to comment.