Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
federicaagostini authored and enricovianello committed Dec 10, 2024
1 parent 4639b18 commit ffa0e72
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.request;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import static org.italiangrid.storm.webdav.oauth.GrantedAuthoritiesMapperSupport.OAUTH_GROUP_CLAIM_NAMES;

import java.net.URI;

Expand Down Expand Up @@ -275,7 +276,24 @@ void writeAccessWithoutMatchedJWTIsDenied() throws Exception {

mvc.perform(put(SLASH_WLCG_SLASH_FILE).with(jwt().jwt(token).authorities(authConverter)))
.andExpect(status().isForbidden());
}

@Test
void readWriteAccessAsJwtWithAllowedGroup() throws Exception {

for (String groupClaim : OAUTH_GROUP_CLAIM_NAMES) {
Jwt token = Jwt.withTokenValue("test")
.header("kid", "rsa1")
.issuer(EXAMPLE_ISSUER)
.claim(groupClaim, "/example/admins")
.build();

mvc.perform(get(SLASH_WLCG_SLASH_FILE).with(jwt().jwt(token).authorities(authConverter)))
.andExpect(status().isNotFound());

mvc.perform(put(SLASH_WLCG_SLASH_FILE).with(jwt().jwt(token).authorities(authConverter)))
.andExpect(status().isOk());
}
}

@WithMockVOMSUser(vos = "wlcg", saReadPermissions = {"wlcg"})
Expand Down

0 comments on commit ffa0e72

Please sign in to comment.