From 811f99cb2e68089415fb26485abbb4d7f17476ac Mon Sep 17 00:00:00 2001 From: Andrej Petras Date: Fri, 19 Jul 2024 13:17:21 +0200 Subject: [PATCH] fix: sonar issues --- .../rs/PermissionRestControllerCacheTest.java | 6 ++--- .../bff/rs/PermissionRestControllerTest.java | 26 +++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/test/java/org/tkit/onecx/shell/bff/rs/PermissionRestControllerCacheTest.java b/src/test/java/org/tkit/onecx/shell/bff/rs/PermissionRestControllerCacheTest.java index 7649ec7..f066a9c 100644 --- a/src/test/java/org/tkit/onecx/shell/bff/rs/PermissionRestControllerCacheTest.java +++ b/src/test/java/org/tkit/onecx/shell/bff/rs/PermissionRestControllerCacheTest.java @@ -93,9 +93,9 @@ void getPermissionsTest() { applicationPermissions.setAppId("onecx-shell-bff"); applicationPermissions.setProductName("onecx-shell"); - String AUTHTOKEN = keycloakClient.getAccessToken(ADMIN); + String token = keycloakClient.getAccessToken(ADMIN); PermissionRequest permissionRequest = new PermissionRequest(); - permissionRequest.setToken("Bearer " + AUTHTOKEN); + permissionRequest.setToken("Bearer " + token); // create mock rest endpoint for permission svc mockServerClient .when(request().withPath("/v1/permissions/user/applications/onecx-shell-bff").withMethod(HttpMethod.POST) @@ -121,7 +121,7 @@ void getPermissionsTest() { requestDTO.setProductName("product1"); var output = given() .when() - .auth().oauth2(AUTHTOKEN) + .auth().oauth2(token) .header(APM_HEADER_PARAM, ADMIN) .contentType(APPLICATION_JSON) .body(requestDTO) diff --git a/src/test/java/org/tkit/onecx/shell/bff/rs/PermissionRestControllerTest.java b/src/test/java/org/tkit/onecx/shell/bff/rs/PermissionRestControllerTest.java index 7b58f80..018f887 100644 --- a/src/test/java/org/tkit/onecx/shell/bff/rs/PermissionRestControllerTest.java +++ b/src/test/java/org/tkit/onecx/shell/bff/rs/PermissionRestControllerTest.java @@ -46,9 +46,9 @@ void getPermissionsTest() { applicationPermissions.setAppId("onecx-shell-bff"); applicationPermissions.setProductName("onecx-shell"); - String AUTHTOKEN = keycloakClient.getAccessToken(ADMIN); + String token = keycloakClient.getAccessToken(ADMIN); PermissionRequest permissionRequest = new PermissionRequest(); - permissionRequest.setToken("Bearer " + AUTHTOKEN); + permissionRequest.setToken("Bearer " + token); // create mock rest endpoint for permission svc mockServerClient .when(request().withPath("/v1/permissions/user/applications/onecx-shell-bff").withMethod(HttpMethod.POST) @@ -74,7 +74,7 @@ void getPermissionsTest() { requestDTO.setProductName("product1"); var output = given() .when() - .auth().oauth2(AUTHTOKEN) + .auth().oauth2(token) .header(APM_HEADER_PARAM, ADMIN) .contentType(APPLICATION_JSON) .body(requestDTO) @@ -96,9 +96,9 @@ void getPermissionsTest() { @Test void getPermissionsResponsesTest() { - String AUTHTOKEN = keycloakClient.getAccessToken(ADMIN); + String token = keycloakClient.getAccessToken(ADMIN); PermissionRequest permissionRequest = new PermissionRequest(); - permissionRequest.setToken("Bearer " + AUTHTOKEN); + permissionRequest.setToken("Bearer " + token); // return empty list of permissions mockServerClient.when(request().withPath("/v1/permissions/user/product1/app2").withMethod(HttpMethod.POST) @@ -111,7 +111,7 @@ void getPermissionsResponsesTest() { var output2 = given() .when() - .auth().oauth2(AUTHTOKEN) + .auth().oauth2(token) .header(APM_HEADER_PARAM, ADMIN) .contentType(APPLICATION_JSON) .body(new GetPermissionsRequestDTO().productName("product1").appId("app2")) @@ -133,7 +133,7 @@ void getPermissionsResponsesTest() { var output3 = given() .when() - .auth().oauth2(AUTHTOKEN) + .auth().oauth2(token) .header(APM_HEADER_PARAM, ADMIN) .contentType(APPLICATION_JSON) .body(new GetPermissionsRequestDTO().productName("product1").appId("app3")) @@ -158,7 +158,7 @@ void getPermissionsResponsesTest() { var output4 = given() .when() - .auth().oauth2(AUTHTOKEN) + .auth().oauth2(token) .header(APM_HEADER_PARAM, ADMIN) .contentType(APPLICATION_JSON) .body(new GetPermissionsRequestDTO().productName("product1").appId("app4")) @@ -176,12 +176,12 @@ void getPermissionsResponsesTest() { @Test void getPermissions_missing_input_Test() { - String AUTHTOKEN = keycloakClient.getAccessToken(ADMIN); + String token = keycloakClient.getAccessToken(ADMIN); GetPermissionsRequestDTO requestDTO = new GetPermissionsRequestDTO(); var output = given() .when() - .auth().oauth2(AUTHTOKEN) + .auth().oauth2(token) .header(APM_HEADER_PARAM, ADMIN) .contentType(APPLICATION_JSON) .body(requestDTO) @@ -206,9 +206,9 @@ void getPermissions_svc_error_Test() { applicationPermissions.setAppId("onecx-shell-bff"); applicationPermissions.setProductName("onecx-shell"); - String AUTHTOKEN = keycloakClient.getAccessToken(ADMIN); + String token = keycloakClient.getAccessToken(ADMIN); PermissionRequest permissionRequest = new PermissionRequest(); - permissionRequest.setToken("Bearer " + AUTHTOKEN); + permissionRequest.setToken("Bearer " + token); // create mock rest endpoint for permission svc mockServerClient .when(request().withPath("/v1/permissions/user/applications/onecx-shell-bff").withMethod(HttpMethod.POST) @@ -231,7 +231,7 @@ void getPermissions_svc_error_Test() { requestDTO.setProductName("product1"); var output = given() .when() - .auth().oauth2(AUTHTOKEN) + .auth().oauth2(token) .header(APM_HEADER_PARAM, ADMIN) .contentType(APPLICATION_JSON) .body(requestDTO)