Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ public boolean canReview(ReviewTask task,
Map<Long, NamespaceRole> userNamespaceRoles,
Set<String> platformRoles) {
if (task.getSubmittedBy().equals(userId)) {
return platformRoles.contains("SUPER_ADMIN");
if (platformRoles.contains("SUPER_ADMIN")) {
return true;
}
NamespaceRole role = userNamespaceRoles.get(task.getNamespaceId());
return hasPlatformReviewRole(platformRoles)
&& (role == NamespaceRole.ADMIN || role == NamespaceRole.OWNER);
}
return canReviewNamespace(task.getNamespaceId(), namespaceType, userNamespaceRoles, platformRoles);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,37 @@ void regularUserCannotReviewOwnSubmission() {
}

@Test
void skillAdminCannotReviewOwnSubmission() {
void skillAdminCannotReviewOwnSubmissionWithoutNamespaceRole() {
String userId = "user-1";
ReviewTask task = new ReviewTask(1L, 10L, userId);
assertFalse(checker.canReview(task, userId,
NamespaceType.TEAM, Map.of(), Set.of("SKILL_ADMIN")));
}

@Test
void skillAdminNamespaceAdminCanReviewOwnSubmission() {
String userId = "user-1";
ReviewTask task = new ReviewTask(1L, 10L, userId);
assertTrue(checker.canReview(task, userId,
NamespaceType.TEAM, Map.of(10L, NamespaceRole.ADMIN), Set.of("SKILL_ADMIN")));
}

@Test
void skillAdminNamespaceOwnerCanReviewOwnSubmission() {
String userId = "user-1";
ReviewTask task = new ReviewTask(1L, 10L, userId);
assertTrue(checker.canReview(task, userId,
NamespaceType.TEAM, Map.of(10L, NamespaceRole.OWNER), Set.of("SKILL_ADMIN")));
}

@Test
void skillAdminNamespaceMemberCannotReviewOwnSubmission() {
String userId = "user-1";
ReviewTask task = new ReviewTask(1L, 10L, userId);
assertFalse(checker.canReview(task, userId,
NamespaceType.TEAM, Map.of(10L, NamespaceRole.MEMBER), Set.of("SKILL_ADMIN")));
}

@Test
void superAdminCannotReviewOwnSubmission() {
String userId = "user-1";
Expand Down
Loading