use of io.helidon.config.Config in project helidon by oracle.
the class AtnProviderSyncTest method testFailure.
@Test
public void testFailure() {
Config config = Config.create(ConfigSources.create(Map.of("atn-object.size", String.valueOf(SIZE))));
SecurityContext context = mock(SecurityContext.class);
when(context.user()).thenReturn(Optional.empty());
when(context.service()).thenReturn(Optional.empty());
SecurityEnvironment se = SecurityEnvironment.create();
EndpointConfig ep = EndpointConfig.builder().config("atn-object", config).build();
ProviderRequest request = mock(ProviderRequest.class);
when(request.securityContext()).thenReturn(context);
when(request.env()).thenReturn(se);
when(request.endpointConfig()).thenReturn(ep);
AtnProviderSync provider = new AtnProviderSync();
AuthenticationResponse response = provider.syncAuthenticate(request);
assertThat(response.status(), is(SecurityResponse.SecurityStatus.FAILURE));
}
use of io.helidon.config.Config in project helidon by oracle.
the class AtnProviderSyncTest method testConfigSuccess.
@Test
public void testConfigSuccess() {
Config config = Config.create(ConfigSources.create(Map.of("value", VALUE, "size", String.valueOf(SIZE))));
SecurityContext context = mock(SecurityContext.class);
when(context.user()).thenReturn(Optional.empty());
when(context.service()).thenReturn(Optional.empty());
SecurityEnvironment se = SecurityEnvironment.create();
EndpointConfig ep = EndpointConfig.builder().config("atn-object", config).build();
ProviderRequest request = mock(ProviderRequest.class);
when(request.securityContext()).thenReturn(context);
when(request.env()).thenReturn(se);
when(request.endpointConfig()).thenReturn(ep);
testSuccess(request);
}
use of io.helidon.config.Config in project helidon by oracle.
the class OutboundOverrideExample method startServingService.
static CompletionStage<Void> startServingService(int port) {
Config config = createConfig("serving-service");
Routing routing = Routing.builder().register(WebSecurity.create(config.get("security"))).get("/hello", (req, res) -> {
res.send(req.context().get(SecurityContext.class).flatMap(SecurityContext::user).map(Subject::principal).map(Principal::getName).orElse("Anonymous"));
}).build();
return startServer(routing, port, server -> servingPort = server.port());
}
use of io.helidon.config.Config in project helidon by oracle.
the class OutboundOverrideExample method startClientService.
static CompletionStage<Void> startClientService(int port) {
Config config = createConfig("client-service");
Routing routing = Routing.builder().register(WebSecurity.create(config.get("security"))).get("/override", OutboundOverrideExample::override).get("/propagate", OutboundOverrideExample::propagate).build();
return startServer(routing, port, server -> clientPort = server.port());
}
use of io.helidon.config.Config in project helidon by oracle.
the class OutboundOverrideJwtExample method startServingService.
static CompletionStage<Void> startServingService(int port) {
Config config = createConfig("serving-service-jwt");
Routing routing = Routing.builder().register(WebSecurity.create(config.get("security"))).get("/hello", (req, res) -> {
// This is the token. It should be bearer <signed JWT base64 encoded>
req.headers().first("Authorization").ifPresent(System.out::println);
res.send(req.context().get(SecurityContext.class).flatMap(SecurityContext::user).map(Subject::principal).map(Principal::getName).orElse("Anonymous"));
}).build();
return startServer(routing, port, server -> servingPort = server.port());
}
Aggregations