Skip to content

Commit

Permalink
Fix sonar issues
Browse files Browse the repository at this point in the history
  • Loading branch information
enricovianello committed Oct 3, 2024
1 parent 51b94e6 commit 8382305
Showing 1 changed file with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void invalidAuthentication() {
}

@Test
void noScopeClaimYeldsIndeterminate() throws Exception {
void noScopeClaimYeldsIndeterminate() {
when(jwt.getClaimAsString(SCOPE_CLAIM)).thenReturn(null);
PathAuthorizationResult result =
pdp.authorizeRequest(newAuthorizationRequest(request, jwtAuth));
Expand All @@ -120,7 +120,7 @@ void noScopeClaimYeldsIndeterminate() throws Exception {
}

@Test
void noSaYeldsIndeterminate() throws Exception {
void noSaYeldsIndeterminate() {

when(pathResolver.resolveStorageArea("/test/example")).thenReturn(null);
PathAuthorizationResult result =
Expand All @@ -131,7 +131,7 @@ void noSaYeldsIndeterminate() throws Exception {
}

@Test
void noStorageScopesYeldsDeny() throws Exception {
void noStorageScopesYeldsDeny() {
when(jwt.getClaimAsString(SCOPE_CLAIM)).thenReturn("openid profile storage.read");

PathAuthorizationResult result =
Expand Down Expand Up @@ -229,7 +229,7 @@ void readMethodsRequestsRequireStorageReadOrStage() {
}

@Test
void replaceMethodsRequestsRequireStorageModifyOrCreate() throws Exception {
void replaceMethodsRequestsRequireStorageModifyOrCreate() {
when(jwt.getClaimAsString(SCOPE_CLAIM)).thenReturn("openid storage.read:/");

for (String m : REPLACE_METHODS) {
Expand Down Expand Up @@ -273,7 +273,7 @@ void replaceMethodsRequestsRequireStorageModifyOrCreate() throws Exception {
}

@Test
void modifyMethodsRequestsRequireStorageModifyOrCreate() throws Exception {
void modifyMethodsRequestsRequireStorageModifyOrCreate() {
when(jwt.getClaimAsString(SCOPE_CLAIM)).thenReturn("openid storage.read:/ storage.create:/");

for (String m : MODIFY_METHODS) {
Expand All @@ -296,7 +296,7 @@ void modifyMethodsRequestsRequireStorageModifyOrCreate() throws Exception {
}

@Test
void testLocalCopyRequiresStorageCreateOrModify() throws Exception {
void testLocalCopyRequiresStorageCreateOrModify() {

when(request.getMethod()).thenReturn(COPY_METHOD);
when(jwt.getClaimAsString(SCOPE_CLAIM)).thenReturn("openid storage.modify:/");
Expand All @@ -313,7 +313,7 @@ void testLocalCopyRequiresStorageCreateOrModify() throws Exception {
}

@Test
void testPullTpcRequiresCreateOrModify() throws Exception {
void testPullTpcRequiresCreateOrModify() {
when(request.getMethod()).thenReturn(COPY_METHOD);
when(request.getHeader("Source")).thenReturn("https://remote.example/test/example");
when(pathResolver.pathExists("/test/example")).thenReturn(true);
Expand Down Expand Up @@ -341,7 +341,7 @@ void testPullTpcRequiresCreateOrModify() throws Exception {
}

@Test
void testPushTpcRequiresRead() throws Exception {
void testPushTpcRequiresRead() {
when(request.getMethod()).thenReturn(COPY_METHOD);
when(jwt.getClaimAsString(SCOPE_CLAIM)).thenReturn("openid storage.create:/ storage.modify:/");
PathAuthorizationResult result =
Expand All @@ -357,7 +357,7 @@ void testPushTpcRequiresRead() throws Exception {
}

@Test
void testMoveRequiresModify() throws Exception {
void testMoveRequiresModify() {
when(request.getMethod()).thenReturn(MOVE_METHOD);
when(jwt.getClaimAsString(SCOPE_CLAIM)).thenReturn("openid storage.read:/ storage.create:/");
PathAuthorizationResult result =
Expand All @@ -373,7 +373,7 @@ void testMoveRequiresModify() throws Exception {
}

@Test
void testModifyImpliesCreate() throws Exception {
void testModifyImpliesCreate() {
when(jwt.getClaimAsString(SCOPE_CLAIM)).thenReturn("openid storage.read:/ storage.modify:/");
when(pathResolver.pathExists("/test/example")).thenReturn(false);

Expand All @@ -386,15 +386,15 @@ void testModifyImpliesCreate() throws Exception {
}

@Test
void testUnsupportedMethod() throws Exception {
void testUnsupportedMethod() {
when(request.getMethod()).thenReturn("TRACE");
assertThrows(IllegalArgumentException.class, () -> {
pdp.authorizeRequest(newAuthorizationRequest(request, jwtAuth));
});
}

@Test
void testPathAuthzIsEnforced() throws Exception {
void testPathAuthzIsEnforced() {
when(jwt.getClaimAsString(SCOPE_CLAIM)).thenReturn("openid storage.read:/subfolder");
when(request.getMethod()).thenReturn("GET");
PathAuthorizationResult result =
Expand Down

0 comments on commit 8382305

Please sign in to comment.