Skip to content

Commit

Permalink
fix: sonar issues (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrejpetras authored Jul 19, 2024
1 parent 2ef8525 commit 02d4214
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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"))
Expand All @@ -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"))
Expand All @@ -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"))
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 02d4214

Please sign in to comment.