Skip to content

Commit

Permalink
"Fix" permissions' issues
Browse files Browse the repository at this point in the history
  • Loading branch information
bukajsytlos authored and Brutus5000 committed May 22, 2023
1 parent 478997e commit 6eaf11d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
12 changes: 10 additions & 2 deletions src/inttest/java/com/faforever/api/data/UserGroupTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import org.springframework.test.context.jdbc.Sql;
import org.springframework.test.context.jdbc.Sql.ExecutionPhase;

import java.util.Set;

import static com.faforever.api.data.JsonApiMediaType.JSON_API_MEDIA_TYPE;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.patch;
Expand Down Expand Up @@ -128,7 +130,10 @@ public void cannotCreateUserGroupWithoutRole() throws Exception {
@Test
public void canCreateUserGroupWithScopeAndRole() throws Exception {
mockMvc.perform(post("/data/userGroup")
.with(getOAuthTokenWithActiveUser(OAuthScope._ADMINISTRATIVE_ACTION, GroupPermission.ROLE_WRITE_USER_GROUP))
.with(getOAuthTokenWithActiveUser(
Set.of(OAuthScope._ADMINISTRATIVE_ACTION, OAuthScope._READ_SENSIBLE_USERDATA),
Set.of(GroupPermission.ROLE_WRITE_USER_GROUP, GroupPermission.ROLE_READ_USER_GROUP)
))
.header(HttpHeaders.CONTENT_TYPE, JSON_API_MEDIA_TYPE)
.content(testPost))
.andExpect(status().isCreated());
Expand All @@ -155,7 +160,10 @@ public void cannotUpdateUserGroupWithoutRole() throws Exception {
@Test
public void canUpdateUserGroupWithScopeAndRole() throws Exception {
mockMvc.perform(patch("/data/userGroup/3")
.with(getOAuthTokenWithActiveUser(OAuthScope._ADMINISTRATIVE_ACTION, GroupPermission.ROLE_WRITE_USER_GROUP))
.with(getOAuthTokenWithActiveUser(
Set.of(OAuthScope._ADMINISTRATIVE_ACTION, OAuthScope._READ_SENSIBLE_USERDATA),
Set.of(GroupPermission.ROLE_WRITE_USER_GROUP, GroupPermission.ROLE_READ_USER_GROUP)
))
.header(HttpHeaders.CONTENT_TYPE, JSON_API_MEDIA_TYPE)
.content(testPatch))
.andExpect(status().isNoContent());
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/com/faforever/api/data/domain/UserGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
@CreatePermission(expression = WriteUserGroupCheck.EXPRESSION)
@ReadPermission(expression = UserGroupPublicCheck.EXPRESSION + " or " + ReadUserGroupCheck.EXPRESSION)
@Setter
public class
UserGroup extends AbstractEntity<UserGroup> {
public class UserGroup extends AbstractEntity<UserGroup> {

private String technicalName;
private String nameKey;
Expand Down

0 comments on commit 6eaf11d

Please sign in to comment.