use of org.springframework.boot.actuate.autoconfigure.cloudfoundry.SecurityResponse in project spring-boot by spring-projects.
the class CloudFoundrySecurityInterceptorTests method preHandleWhenRequestIsPreFlightShouldReturnTrue.
@Test
void preHandleWhenRequestIsPreFlightShouldReturnTrue() {
this.request.setMethod("OPTIONS");
this.request.addHeader(HttpHeaders.ORIGIN, "https://example.com");
this.request.addHeader(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET");
SecurityResponse response = this.interceptor.preHandle(this.request, EndpointId.of("test"));
assertThat(response.getStatus()).isEqualTo(HttpStatus.OK);
}
use of org.springframework.boot.actuate.autoconfigure.cloudfoundry.SecurityResponse in project spring-boot by spring-projects.
the class CloudFoundrySecurityInterceptorTests method preHandleWhenAccessIsNotAllowedShouldReturnFalse.
@Test
void preHandleWhenAccessIsNotAllowedShouldReturnFalse() {
String accessToken = mockAccessToken();
this.request.addHeader("Authorization", "bearer " + accessToken);
given(this.securityService.getAccessLevel(accessToken, "my-app-id")).willReturn(AccessLevel.RESTRICTED);
SecurityResponse response = this.interceptor.preHandle(this.request, EndpointId.of("test"));
assertThat(response.getStatus()).isEqualTo(Reason.ACCESS_DENIED.getStatus());
}
use of org.springframework.boot.actuate.autoconfigure.cloudfoundry.SecurityResponse in project spring-boot by spring-projects.
the class CloudFoundrySecurityInterceptorTests method preHandleWhenTokenIsNotBearerShouldReturnFalse.
@Test
void preHandleWhenTokenIsNotBearerShouldReturnFalse() {
this.request.addHeader("Authorization", mockAccessToken());
SecurityResponse response = this.interceptor.preHandle(this.request, EndpointId.of("test"));
assertThat(response.getStatus()).isEqualTo(Reason.MISSING_AUTHORIZATION.getStatus());
}
Aggregations