Skip to content

Commit a381f63

Browse files
authored
Merge pull request #5 from gridsuite/record_connections
FIX: an admin is authorized to pass the gateway
2 parents 8ee59b0 + 1a1f458 commit a381f63

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/main/java/org/gridsuite/useradmin/server/service/UserAdminService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public void delete(UUID id, String userId) {
6565
}
6666

6767
public boolean subExists(String sub) {
68-
Boolean isAllowed = (applicationProps.getAdmins().isEmpty() && userAdminRepository.count() == 0) || !userAdminRepository.findAllBySub(sub).isEmpty();
68+
Boolean isAllowed = (applicationProps.getAdmins().isEmpty() && userAdminRepository.count() == 0) || applicationProps.getAdmins().contains(sub) || !userAdminRepository.findAllBySub(sub).isEmpty();
6969
connectionsService.recordConnectionAttempt(sub, isAllowed);
7070
return isAllowed.booleanValue();
7171
}

src/test/java/org/gridsuite/useradmin/server/UserAdminTest.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ public void testUserAdmin() throws Exception {
8383

8484
assertEquals(0, userEntities.size());
8585

86+
mockMvc.perform(head("/" + UserAdminApi.API_VERSION + "/users/{sub}", ADMIN_USER))
87+
.andExpect(status().isOk())
88+
.andReturn();
89+
8690
mockMvc.perform(post("/" + UserAdminApi.API_VERSION + "/users/{sub}", USER_SUB)
8791
.header("userId", ADMIN_USER)
8892
)
@@ -109,7 +113,7 @@ public void testUserAdmin() throws Exception {
109113
mockMvc.perform(head("/" + UserAdminApi.API_VERSION + "/users/{sub}", "UNKNOWN"))
110114
.andExpect(status().isNoContent())
111115
.andReturn();
112-
assertEquals(2, connectionRepository.findAll().size());
116+
assertEquals(3, connectionRepository.findAll().size());
113117
assertTrue(connectionRepository.findBySub(USER_SUB).get(0).getConnectionAccepted());
114118
assertFalse(connectionRepository.findBySub("UNKNOWN").get(0).getConnectionAccepted());
115119
LocalDateTime firstConnectionDate = connectionRepository.findBySub(USER_SUB).get(0).getFirstConnexionDate();

0 commit comments

Comments
 (0)