use of io.trino.server.testing.TestingTrinoServer in project trino by trinodb.
the class TestResourceSecurity method testInsecureAuthenticatorHttps.
@Test
public void testInsecureAuthenticatorHttps() throws Exception {
try (TestingTrinoServer server = TestingTrinoServer.builder().setProperties(SECURE_PROPERTIES).build()) {
server.getInstance(Key.get(AccessControlManager.class)).addSystemAccessControl(TestSystemAccessControl.WITH_IMPERSONATION);
HttpServerInfo httpServerInfo = server.getInstance(Key.get(HttpServerInfo.class));
assertInsecureAuthentication(httpServerInfo.getHttpUri());
assertInsecureAuthentication(httpServerInfo.getHttpsUri());
}
}
use of io.trino.server.testing.TestingTrinoServer in project trino by trinodb.
the class TestWebUi method testPasswordAuthenticator.
@Test
public void testPasswordAuthenticator() throws Exception {
try (TestingTrinoServer server = TestingTrinoServer.builder().setProperties(ImmutableMap.<String, String>builder().putAll(SECURE_PROPERTIES).put("http-server.authentication.type", "password").put("password-authenticator.config-files", passwordConfigDummy.toString()).put("http-server.authentication.password.user-mapping.pattern", ALLOWED_USER_MAPPING_PATTERN).buildOrThrow()).setAdditionalModule(binder -> jaxrsBinder(binder).bind(TestResource.class)).build()) {
server.getInstance(Key.get(PasswordAuthenticatorManager.class)).setAuthenticators(TestWebUi::authenticate);
HttpServerInfo httpServerInfo = server.getInstance(Key.get(HttpServerInfo.class));
testFormAuthentication(server, httpServerInfo, AUTHENTICATED_USER, TEST_PASSWORD, true);
}
}
use of io.trino.server.testing.TestingTrinoServer in project trino by trinodb.
the class TestWebUi method testJwtAuthenticator.
@Test
public void testJwtAuthenticator() throws Exception {
try (TestingTrinoServer server = TestingTrinoServer.builder().setProperties(ImmutableMap.<String, String>builder().putAll(SECURE_PROPERTIES).put("http-server.authentication.type", "jwt").put("http-server.authentication.jwt.key-file", HMAC_KEY).buildOrThrow()).build()) {
HttpServerInfo httpServerInfo = server.getInstance(Key.get(HttpServerInfo.class));
String nodeId = server.getInstance(Key.get(NodeInfo.class)).getNodeId();
testLogIn(httpServerInfo.getHttpUri(), FORM_LOGIN_USER, TEST_PASSWORD, false);
testNeverAuthorized(httpServerInfo.getHttpsUri(), client);
SecretKey hmac = hmacShaKeyFor(Base64.getDecoder().decode(Files.readString(Paths.get(HMAC_KEY)).trim()));
String token = newJwtBuilder().signWith(hmac).setSubject("test-user").setExpiration(Date.from(ZonedDateTime.now().plusMinutes(5).toInstant())).compact();
OkHttpClient clientWithJwt = client.newBuilder().authenticator((route, response) -> response.request().newBuilder().header(AUTHORIZATION, "Bearer " + token).build()).build();
testAlwaysAuthorized(httpServerInfo.getHttpsUri(), clientWithJwt, nodeId);
}
}
use of io.trino.server.testing.TestingTrinoServer in project trino by trinodb.
the class TestWebUi method testMultiplePasswordAuthenticators.
@Test
public void testMultiplePasswordAuthenticators() throws Exception {
try (TestingTrinoServer server = TestingTrinoServer.builder().setProperties(ImmutableMap.<String, String>builder().putAll(SECURE_PROPERTIES).put("http-server.authentication.type", "password").put("password-authenticator.config-files", passwordConfigDummy.toString()).put("http-server.authentication.password.user-mapping.pattern", ALLOWED_USER_MAPPING_PATTERN).buildOrThrow()).setAdditionalModule(binder -> jaxrsBinder(binder).bind(TestResource.class)).build()) {
server.getInstance(Key.get(PasswordAuthenticatorManager.class)).setAuthenticators(TestWebUi::authenticate, TestWebUi::authenticate2);
HttpServerInfo httpServerInfo = server.getInstance(Key.get(HttpServerInfo.class));
testFormAuthentication(server, httpServerInfo, AUTHENTICATED_USER, TEST_PASSWORD, true);
testFormAuthentication(server, httpServerInfo, AUTHENTICATED_USER, TEST_PASSWORD2, true);
}
}
use of io.trino.server.testing.TestingTrinoServer in project trino by trinodb.
the class DistributedQueryRunner method installPlugin.
@Override
public void installPlugin(Plugin plugin) {
long start = System.nanoTime();
for (TestingTrinoServer server : servers) {
server.installPlugin(plugin);
}
log.info("Installed plugin %s in %s", plugin.getClass().getSimpleName(), nanosSince(start).convertToMostSuccinctTimeUnit());
}
Aggregations