Search in sources :

Example 1 with SecuredServiceImpl

use of io.scalecube.services.sut.security.SecuredServiceImpl in project scalecube by scalecube.

the class ServiceAuthRemoteTest method beforeAll.

@BeforeAll
static void beforeAll() {
    StepVerifier.setDefaultTimeout(TIMEOUT);
    principalMapper = authData -> new UserProfile(authData.get("name"), authData.get("role"));
    service = Microservices.builder().discovery(serviceEndpoint -> new ScalecubeServiceDiscovery().transport(cfg -> cfg.transportFactory(new WebsocketTransportFactory())).options(opts -> opts.metadata(serviceEndpoint))).transport(() -> new RSocketServiceTransport().authenticator(authenticator)).services(ServiceInfo.fromServiceInstance(new SecuredServiceImpl()).principalMapper(principalMapper).build()).startAwait();
    serviceWithoutAuthenticator = Microservices.builder().discovery(serviceEndpoint -> new ScalecubeServiceDiscovery().transport(cfg -> cfg.transportFactory(new WebsocketTransportFactory())).options(opts -> opts.metadata(serviceEndpoint))).transport(RSocketServiceTransport::new).services(ServiceInfo.fromServiceInstance(new AnotherSecuredServiceImpl()).principalMapper(principalMapper).build()).startAwait();
    partiallySecuredService = Microservices.builder().discovery(serviceEndpoint -> new ScalecubeServiceDiscovery().transport(cfg -> cfg.transportFactory(new WebsocketTransportFactory())).options(opts -> opts.metadata(serviceEndpoint))).transport(() -> new RSocketServiceTransport().authenticator(authenticator)).services(ServiceInfo.fromServiceInstance(new PartiallySecuredServiceImpl()).principalMapper(principalMapper).build()).startAwait();
}
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) ScalecubeServiceDiscovery(io.scalecube.services.discovery.ScalecubeServiceDiscovery) UserProfile(io.scalecube.services.sut.security.UserProfile) WebsocketTransportFactory(io.scalecube.transport.netty.websocket.WebsocketTransportFactory) PartiallySecuredServiceImpl(io.scalecube.services.sut.security.PartiallySecuredServiceImpl) SecuredServiceImpl(io.scalecube.services.sut.security.SecuredServiceImpl) AnotherSecuredServiceImpl(io.scalecube.services.sut.security.AnotherSecuredServiceImpl) PartiallySecuredServiceImpl(io.scalecube.services.sut.security.PartiallySecuredServiceImpl) RSocketServiceTransport(io.scalecube.services.transport.rsocket.RSocketServiceTransport) AnotherSecuredServiceImpl(io.scalecube.services.sut.security.AnotherSecuredServiceImpl) BeforeAll(org.junit.jupiter.api.BeforeAll)

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