use of io.helidon.security.SecurityContext in project helidon by oracle.
the class PolicyValidatorTest method testSimplePolicyExecutor.
@Test
public void testSimplePolicyExecutor() {
PolicyValidator pv = PolicyValidator.builder().addExecutor(new MyPolicyExecutor()).build();
SecurityContext sc = mock(SecurityContext.class);
when(sc.isAuthenticated()).thenReturn(true);
ProviderRequest request = mock(ProviderRequest.class);
when(request.securityContext()).thenReturn(sc);
when(request.getObject()).thenReturn(Optional.empty());
PolicyValidator.PolicyConfig pc = PolicyValidator.PolicyConfig.builder().statement(PolicyClass.class.getName() + ".isAuthenticated").build();
Errors.Collector collector = Errors.collector();
pv.validate(pc, collector, request);
collector.collect().checkValid();
}
Aggregations