Search in sources :

Example 1 with AnotherSecuredService

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);
    }
}
Also used : StepVerifier(reactor.test.StepVerifier) HashMap(java.util.HashMap) RejectedSetupException(io.rsocket.exceptions.RejectedSetupException) PartiallySecuredServiceImpl(io.scalecube.services.sut.security.PartiallySecuredServiceImpl) SecuredServiceImpl(io.scalecube.services.sut.security.SecuredServiceImpl) Authenticator(io.scalecube.services.auth.Authenticator) AfterAll(org.junit.jupiter.api.AfterAll) SecuredService(io.scalecube.services.sut.security.SecuredService) UserProfile(io.scalecube.services.sut.security.UserProfile) BeforeAll(org.junit.jupiter.api.BeforeAll) Duration(java.time.Duration) Map(java.util.Map) PartiallySecuredService(io.scalecube.services.sut.security.PartiallySecuredService) WebsocketTransportFactory(io.scalecube.transport.netty.websocket.WebsocketTransportFactory) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) UnauthorizedException(io.scalecube.services.exceptions.UnauthorizedException) ScalecubeServiceDiscovery(io.scalecube.services.discovery.ScalecubeServiceDiscovery) AnotherSecuredService(io.scalecube.services.sut.security.AnotherSecuredService) Mono(reactor.core.publisher.Mono) AnotherSecuredServiceImpl(io.scalecube.services.sut.security.AnotherSecuredServiceImpl) ServiceDiscovery(io.scalecube.services.discovery.api.ServiceDiscovery) DisplayName(org.junit.jupiter.api.DisplayName) PrincipalMapper(io.scalecube.services.auth.PrincipalMapper) RSocketServiceTransport(io.scalecube.services.transport.rsocket.RSocketServiceTransport) Consumer(java.util.function.Consumer) Test(org.junit.jupiter.api.Test) Collections(java.util.Collections) UnauthorizedException(io.scalecube.services.exceptions.UnauthorizedException) AnotherSecuredService(io.scalecube.services.sut.security.AnotherSecuredService) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

RejectedSetupException (io.rsocket.exceptions.RejectedSetupException)1 Authenticator (io.scalecube.services.auth.Authenticator)1 PrincipalMapper (io.scalecube.services.auth.PrincipalMapper)1 ScalecubeServiceDiscovery (io.scalecube.services.discovery.ScalecubeServiceDiscovery)1 ServiceDiscovery (io.scalecube.services.discovery.api.ServiceDiscovery)1 UnauthorizedException (io.scalecube.services.exceptions.UnauthorizedException)1 AnotherSecuredService (io.scalecube.services.sut.security.AnotherSecuredService)1 AnotherSecuredServiceImpl (io.scalecube.services.sut.security.AnotherSecuredServiceImpl)1 PartiallySecuredService (io.scalecube.services.sut.security.PartiallySecuredService)1 PartiallySecuredServiceImpl (io.scalecube.services.sut.security.PartiallySecuredServiceImpl)1 SecuredService (io.scalecube.services.sut.security.SecuredService)1 SecuredServiceImpl (io.scalecube.services.sut.security.SecuredServiceImpl)1 UserProfile (io.scalecube.services.sut.security.UserProfile)1 RSocketServiceTransport (io.scalecube.services.transport.rsocket.RSocketServiceTransport)1 WebsocketTransportFactory (io.scalecube.transport.netty.websocket.WebsocketTransportFactory)1 Duration (java.time.Duration)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Consumer (java.util.function.Consumer)1