Polish
This commit is contained in:
@@ -116,7 +116,7 @@ class CloudFoundrySecurityService {
|
||||
}
|
||||
|
||||
private Map<String, String> extractTokenKeys(Map<?, ?> response) {
|
||||
Map<String, String> tokenKeys = new HashMap<String, String>();
|
||||
Map<String, String> tokenKeys = new HashMap<>();
|
||||
for (Object key : (List<?>) response.get("keys")) {
|
||||
Map<?, ?> tokenKey = (Map<?, ?>) key;
|
||||
tokenKeys.put((String) tokenKey.get("kid"), (String) tokenKey.get("value"));
|
||||
|
||||
@@ -101,7 +101,7 @@ class CloudFoundryWebEndpointServletHandlerMapping
|
||||
return Collections.singletonMap("_links", filteredLinks);
|
||||
}
|
||||
filteredLinks = links.entrySet().stream()
|
||||
.filter(e -> e.getKey().equals("self")
|
||||
.filter((e) -> e.getKey().equals("self")
|
||||
|| accessLevel.isAccessAllowed(e.getKey()))
|
||||
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
|
||||
return Collections.singletonMap("_links", filteredLinks);
|
||||
|
||||
@@ -52,8 +52,8 @@ public class Neo4jHealthIndicator extends AbstractHealthIndicator {
|
||||
protected void doHealthCheck(Health.Builder builder) throws Exception {
|
||||
Session session = this.sessionFactory.openSession();
|
||||
Result result = session.query(CYPHER, Collections.emptyMap());
|
||||
builder.up().withDetail("nodes", result.queryResults()
|
||||
.iterator().next().get("nodes"));
|
||||
builder.up().withDetail("nodes",
|
||||
result.queryResults().iterator().next().get("nodes"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public class WebMvcEndpointInfrastructureAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void webEndpointsAreDisabledByDefault() {
|
||||
this.contextRunner.run(context -> {
|
||||
this.contextRunner.run((context) -> {
|
||||
MockMvc mvc = MockMvcBuilders.webAppContextSetup(context).build();
|
||||
assertThat(isExposed(mvc, HttpMethod.GET, "autoconfig")).isFalse();
|
||||
assertThat(isExposed(mvc, HttpMethod.GET, "beans")).isFalse();
|
||||
@@ -76,7 +76,7 @@ public class WebMvcEndpointInfrastructureAutoConfigurationTests {
|
||||
public void webEndpointsCanBeEnabled() {
|
||||
WebApplicationContextRunner contextRunner = this.contextRunner
|
||||
.withPropertyValues("endpoints.default.web.enabled=true");
|
||||
contextRunner.run(context -> {
|
||||
contextRunner.run((context) -> {
|
||||
MockMvc mvc = MockMvcBuilders.webAppContextSetup(context).build();
|
||||
assertThat(isExposed(mvc, HttpMethod.GET, "autoconfig")).isTrue();
|
||||
assertThat(isExposed(mvc, HttpMethod.GET, "beans")).isTrue();
|
||||
|
||||
@@ -69,22 +69,22 @@ public class CloudFoundryMvcWebEndpointIntegrationTests {
|
||||
public void operationWithSecurityInterceptorForbidden() throws Exception {
|
||||
given(securityService.getAccessLevel(any(), eq("app-id")))
|
||||
.willReturn(AccessLevel.RESTRICTED);
|
||||
load(TestEndpointConfiguration.class, (client) -> {
|
||||
client.get().uri("/cfApplication/test").accept(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "bearer " + mockAccessToken()).exchange()
|
||||
.expectStatus().isEqualTo(HttpStatus.FORBIDDEN);
|
||||
});
|
||||
load(TestEndpointConfiguration.class,
|
||||
(client) -> client.get().uri("/cfApplication/test")
|
||||
.accept(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "bearer " + mockAccessToken()).exchange()
|
||||
.expectStatus().isEqualTo(HttpStatus.FORBIDDEN));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void operationWithSecurityInterceptorSuccess() throws Exception {
|
||||
given(securityService.getAccessLevel(any(), eq("app-id")))
|
||||
.willReturn(AccessLevel.FULL);
|
||||
load(TestEndpointConfiguration.class, (client) -> {
|
||||
client.get().uri("/cfApplication/test").accept(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "bearer " + mockAccessToken()).exchange()
|
||||
.expectStatus().isEqualTo(HttpStatus.OK);
|
||||
});
|
||||
load(TestEndpointConfiguration.class,
|
||||
(client) -> client.get().uri("/cfApplication/test")
|
||||
.accept(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "bearer " + mockAccessToken()).exchange()
|
||||
.expectStatus().isEqualTo(HttpStatus.OK));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -135,9 +135,8 @@ public class RequestMappingEndpointTests {
|
||||
OperationRequestPredicate requestPredicate = new OperationRequestPredicate("test",
|
||||
WebEndpointHttpMethod.GET, Collections.singletonList("application/json"),
|
||||
Collections.singletonList("application/json"));
|
||||
WebEndpointOperation operation = new WebEndpointOperation(
|
||||
OperationType.READ, (arguments) -> "Invoked", true,
|
||||
requestPredicate, "test");
|
||||
WebEndpointOperation operation = new WebEndpointOperation(OperationType.READ,
|
||||
(arguments) -> "Invoked", true, requestPredicate, "test");
|
||||
WebEndpointServletHandlerMapping mapping = new WebEndpointServletHandlerMapping(
|
||||
"application", Collections.singleton(new EndpointInfo<>("test", true,
|
||||
Collections.singleton(operation))));
|
||||
|
||||
Reference in New Issue
Block a user