use of io.scalecube.services.sut.security.AnotherSecuredService in project scalecube by scalecube.
the class ServiceAuthRemoteTest method failedAuthenticationWhenAuthenticatorNotProvided.
@Test
@DisplayName("Authentication failed if authenticator not provided")
void failedAuthenticationWhenAuthenticatorNotProvided() {
Microservices caller = newCaller();
try {
AnotherSecuredService securedService = caller.call().api(AnotherSecuredService.class);
Consumer<Throwable> verifyError = th -> {
assertEquals(UnauthorizedException.class, th.getClass());
assertEquals("Authentication failed", th.getMessage());
};
StepVerifier.create(securedService.helloWithRequest("Bob")).expectErrorSatisfies(verifyError).verify();
StepVerifier.create(securedService.helloWithPrincipal()).expectErrorSatisfies(verifyError).verify();
StepVerifier.create(securedService.helloWithRequestAndPrincipal("Bob")).expectErrorSatisfies(verifyError).verify();
} finally {
caller.shutdown().block(TIMEOUT);
}
}
Aggregations