use of io.helidon.security.AuthorizationResponse in project helidon by oracle.
the class SecurityFilterTest method testAtzAbortWith.
@Test
void testAtzAbortWith() {
SecurityFeature feature = SecurityFeature.builder(security).build();
SecurityContext securityContext = security.createContext("testAbortWith");
SecurityFilter sf = new SecurityFilter(feature.featureConfig(), security, serverConfig, securityContext);
ContainerRequest request = mock(ContainerRequest.class);
SecurityFilter.FilterContext filterContext = new SecurityFilter.FilterContext();
filterContext.setJerseyRequest(request);
SecurityClientBuilder<AuthorizationResponse> clientBuilder = mock(SecurityClientBuilder.class);
when(clientBuilder.buildAndGet()).thenReturn(AuthorizationResponse.builder().description("Unit-test").status(SecurityResponse.SecurityStatus.FAILURE).build());
sf.processAuthorization(filterContext, clientBuilder);
assertThat(filterContext.isShouldFinish(), is(true));
verify(request).abortWith(argThat(response -> response.getStatus() == 403));
}
Aggregations