use of io.micronaut.http.client.BlockingHttpClient in project micronaut-security by micronaut-projects.
the class LoggersTest method loggersEndpointIsAccessibleForUsersWithRoleROLE_SYSTEM.
@Test
void loggersEndpointIsAccessibleForUsersWithRoleROLE_SYSTEM() {
BlockingHttpClient client = httpClient.toBlocking();
HttpRequest<?> request = HttpRequest.GET("/loggers").basicAuth("system", "password");
HttpResponse<Map> response = client.exchange(request, Argument.of(Map.class));
assertEquals(HttpStatus.OK, response.status());
Map m = response.body();
assertTrue(m.containsKey("levels"));
assertTrue(m.containsKey("loggers"));
}
use of io.micronaut.http.client.BlockingHttpClient in project micronaut-security by micronaut-projects.
the class LoggersTest method loggersEndpointIsSecured.
@Test
void loggersEndpointIsSecured() {
BlockingHttpClient client = httpClient.toBlocking();
Executable e = () -> client.exchange(HttpRequest.GET("/loggers"));
HttpClientResponseException thrown = assertThrows(HttpClientResponseException.class, e);
assertEquals(HttpStatus.UNAUTHORIZED, thrown.getStatus());
}
use of io.micronaut.http.client.BlockingHttpClient in project micronaut-security by micronaut-projects.
the class LoggersTest method healthEndpointIsNotSecured.
@Test
void healthEndpointIsNotSecured() {
BlockingHttpClient client = httpClient.toBlocking();
HttpResponse<?> response = client.exchange(HttpRequest.GET("/health"));
assertEquals(HttpStatus.OK, response.status());
}
use of io.micronaut.http.client.BlockingHttpClient in project micronaut-security by micronaut-projects.
the class LoggersTest method loggersEndpointIsNotAccessibleForUsersWithoutRoleROLE_SYSTEM.
@Test
void loggersEndpointIsNotAccessibleForUsersWithoutRoleROLE_SYSTEM() {
BlockingHttpClient client = httpClient.toBlocking();
Executable e = () -> client.exchange(HttpRequest.GET("/loggers").basicAuth("user", "password"));
HttpClientResponseException thrown = assertThrows(HttpClientResponseException.class, e);
assertEquals(HttpStatus.FORBIDDEN, thrown.getStatus());
}
use of io.micronaut.http.client.BlockingHttpClient in project micronaut-security by micronaut-projects.
the class SensitiveEndpointRuleReplacementTest method testAccessingASensitiveEndpointWithAuthenticationAndASensitiveEndpointRuleReplacementWorks.
@Test
void testAccessingASensitiveEndpointWithAuthenticationAndASensitiveEndpointRuleReplacementWorks() {
BlockingHttpClient client = httpClient.toBlocking();
Executable e = () -> client.exchange(HttpRequest.GET("/beans"));
HttpClientResponseException thrown = assertThrows(HttpClientResponseException.class, e);
assertEquals(HttpStatus.UNAUTHORIZED, thrown.getStatus());
e = () -> client.exchange(HttpRequest.GET("/beans").basicAuth("user", "password"));
assertDoesNotThrow(e);
}
Aggregations