Skip to content

Commit

Permalink
Resolves audit 4.1.4. Test for extraneous functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
oharsta committed Oct 24, 2023
1 parent 2beb4bb commit 508e49c
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 114 deletions.
2 changes: 1 addition & 1 deletion client/src/pages/Role.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export const Role = () => {
rel="noreferrer"
target="_blank">
<span className={"application-name"}>{`${role.applicationName}`}</span>
</a><span>{` (${role.applicationOrganizationName})`}</span>
</a>{role.applicationOrganizationName && <span>{` (${role.applicationOrganizationName})`}</span>}
</div>

</div>
Expand Down
4 changes: 4 additions & 0 deletions client/src/tabs/Invitations.scss
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@

tbody {
td {
&.email {
word-break: keep-all;
}

&.check {
text-align: center;
}
Expand Down
19 changes: 0 additions & 19 deletions server/src/main/java/access/api/ManageController.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,25 +55,6 @@ public ResponseEntity<Map<String, Object>> providerById(@PathVariable("type") En
return ResponseEntity.ok(provider);
}

@GetMapping("provisioning/{id}")
public ResponseEntity<List<Map<String, Object>>> provisioning(@PathVariable("id") String id,
@Parameter(hidden = true) User user) {
LOG.debug("provisioning");
UserPermissions.assertManagerRole(Map.of("id", id), user);
List<Map<String, Object>> provisioning = manage.provisioning(List.of(id));
if (!user.isSuperUser()) {
provisioning.forEach(prov -> {
Map<String, Object> data = (Map<String, Object>) prov.get("data");
Map<String, Object> metaDataFields = (Map<String, Object>) data.getOrDefault("metaDataFields", Collections.emptyMap());
List.of("scim_url", "scim_user", "scim_password",
"eva_url", "eva_token",
"graph_url", "graph_tenant", "graph_secret", "graph_client_id")
.forEach(metaDataFields::remove);
});
}
return ResponseEntity.ok(provisioning);
}

@GetMapping("providers")
public ResponseEntity<List<Map<String, Object>>> providers(@Parameter(hidden = true) User user) {
LOG.debug("/providers");
Expand Down
11 changes: 0 additions & 11 deletions server/src/main/java/access/api/UserController.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,17 +155,6 @@ public View msAcceptReturn(@PathVariable("manageId") String manageId, @PathVaria
return new RedirectView(redirectReference.get());
}

@GetMapping("switch")
public View switchApp(@Param(value = "app") String app, @Parameter(hidden = true) User user) {
boolean welcome = app.equals("welcome");
UserPermissions.assertAuthority(user, welcome ? Authority.GUEST : Authority.INVITER);
SecurityContext securityContext = SecurityContextHolder.getContext();
Authentication authentication = securityContext.getAuthentication();
//This will force a cookie to authenticate
securityContext.setAuthentication(authentication);
return new RedirectView(welcome ? config.getWelcomeUrl() : config.getClientUrl(), false);
}

@PostMapping("error")
public ResponseEntity<Map<String, Integer>> error(@RequestBody Map<String, Object> payload,
@Parameter(hidden = true) User user) throws
Expand Down
51 changes: 0 additions & 51 deletions server/src/test/java/access/api/ManageControllerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,55 +92,4 @@ void providerById() throws Exception {
assertEquals("1", result.get("id"));
}

@Test
void provisioningBySuperUser() throws Exception {
AccessCookieFilter accessCookieFilter = openIDConnectFlow("/api/v1/users/login", SUPER_SUB);

String spBody = objectMapper.writeValueAsString(localManage.provisioning(List.of("1")));
stubFor(post(urlPathMatching("/manage/api/internal/provisioning")).willReturn(aResponse()
.withHeader("Content-Type", "application/json")
.withBody(spBody)));
List<Map<String, Object>> result = given()
.when()
.filter(accessCookieFilter.cookieFilter())
.accept(ContentType.JSON)
.header(accessCookieFilter.csrfToken().getHeaderName(), accessCookieFilter.csrfToken().getToken())
.contentType(ContentType.JSON)
.get("/api/v1/manage/provisioning/1")
.as(new TypeRef<>() {
});
assertEquals(1, result.size());

Map<String, Object> data = (Map<String, Object>) result.get(0).get("data");
Map<String, Object> metaDataFields = (Map<String, Object>) data.get("metaDataFields");
assertTrue(Stream.of("scim_url", "scim_user", "scim_password")
.allMatch(metaDataFields::containsKey));
}

@Test
void provisioningByManager() throws Exception {
AccessCookieFilter accessCookieFilter = openIDConnectFlow("/api/v1/users/login", MANAGE_SUB);

String spBody = objectMapper.writeValueAsString(localManage.provisioning(List.of("1")));
stubFor(post(urlPathMatching("/manage/api/internal/provisioning")).willReturn(aResponse()
.withHeader("Content-Type", "application/json")
.withBody(spBody)));
List<Map<String, Object>> result = given()
.when()
.filter(accessCookieFilter.cookieFilter())
.accept(ContentType.JSON)
.header(accessCookieFilter.csrfToken().getHeaderName(), accessCookieFilter.csrfToken().getToken())
.contentType(ContentType.JSON)
.get("/api/v1/manage/provisioning/1")
.as(new TypeRef<>() {
});
assertEquals(1, result.size());

Map<String, Object> data = (Map<String, Object>) result.get(0).get("data");
Map<String, Object> metaDataFields = (Map<String, Object>) data.get("metaDataFields");
assertTrue(Stream.of("scim_url", "scim_user", "scim_password", "graph_token", "eva_token")
.noneMatch(metaDataFields::containsKey));
assertTrue(Stream.of("name:en")
.allMatch(metaDataFields::containsKey));
}
}
32 changes: 0 additions & 32 deletions server/src/test/java/access/api/UserControllerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -290,38 +290,6 @@ void searchOwl() throws Exception {
assertEquals(5, users.size());
}

@Test
void switchApp() throws Exception {
AccessCookieFilter accessCookieFilter = openIDConnectFlow("/api/v1/users/login", SUPER_SUB);

given().redirects()
.follow(false)
.when()
.filter(accessCookieFilter.cookieFilter())
.accept(ContentType.JSON)
.contentType(ContentType.JSON)
.queryParam("app", "welcome")
.get("/api/v1/users/switch")
.then()
.header("Location", "http://localhost:4000");
}

@Test
void switchAppToClient() throws Exception {
AccessCookieFilter accessCookieFilter = openIDConnectFlow("/api/v1/users/login", SUPER_SUB);

given().redirects()
.follow(false)
.when()
.filter(accessCookieFilter.cookieFilter())
.accept(ContentType.JSON)
.contentType(ContentType.JSON)
.queryParam("app", "client")
.get("/api/v1/users/switch")
.then()
.header("Location", "http://localhost:3000");
}

@Test
void other() throws Exception {
AccessCookieFilter accessCookieFilter = openIDConnectFlow("/api/v1/users/login", SUPER_SUB);
Expand Down

0 comments on commit 508e49c

Please sign in to comment.