Search in sources :

Example 11 with ConfigBuilder

use of org.apache.drill.test.ConfigBuilder in project drill by apache.

the class TestHttpProxy method testConfigForUrl.

@Test
public void testConfigForUrl() {
    Config config = new ConfigBuilder().put(ExecConstants.HTTP_PROXY_URL, "http://bob:secret@foo.com:1234").put(ExecConstants.HTTPS_PROXY_URL, "http://alice:s3cr3t@bar.com:2345").build();
    doTestConfigForUrl(config);
}
Also used : HttpProxyConfig(org.apache.drill.exec.store.http.util.HttpProxyConfig) Config(com.typesafe.config.Config) ConfigBuilder(org.apache.drill.test.ConfigBuilder) BaseTest(org.apache.drill.test.BaseTest) Test(org.junit.Test)

Example 12 with ConfigBuilder

use of org.apache.drill.test.ConfigBuilder in project drill by apache.

the class TestHttpProxy method testHttpUrlConfig.

@Test
public void testHttpUrlConfig() {
    Config config = new ConfigBuilder().put(ExecConstants.HTTP_PROXY_URL, "").put(ExecConstants.HTTP_PROXY_TYPE, "socks").put(ExecConstants.HTTP_PROXY_HOST, "foo.com").put(ExecConstants.HTTP_PROXY_PORT, 1234).put(ExecConstants.HTTP_PROXY_USER_NAME, "bob").put(ExecConstants.HTTP_PROXY_PASSWORD, "secret").build();
    HttpProxyConfig proxy = HttpProxyConfig.builder().fromHttpConfig(config).build();
    assertEquals(ProxyType.SOCKS, proxy.type);
    assertEquals("foo.com", proxy.host);
    assertEquals(1234, proxy.port);
    assertEquals("bob", proxy.username);
    assertEquals("secret", proxy.password);
}
Also used : HttpProxyConfig(org.apache.drill.exec.store.http.util.HttpProxyConfig) HttpProxyConfig(org.apache.drill.exec.store.http.util.HttpProxyConfig) Config(com.typesafe.config.Config) ConfigBuilder(org.apache.drill.test.ConfigBuilder) BaseTest(org.apache.drill.test.BaseTest) Test(org.junit.Test)

Example 13 with ConfigBuilder

use of org.apache.drill.test.ConfigBuilder in project drill by apache.

the class TestSSLConfig method testInvalidHadoopKeystore.

@Test
public void testInvalidHadoopKeystore() throws Exception {
    Configuration hadoopConfig = new Configuration();
    String hadoopSSLFileProp = MessageFormat.format(HADOOP_SSL_CONF_TPL_KEY, SSLConfig.Mode.SERVER.toString().toLowerCase());
    hadoopConfig.set(hadoopSSLFileProp, "ssl-server-invalid.xml");
    ConfigBuilder config = new ConfigBuilder();
    config.put(ExecConstants.USER_SSL_ENABLED, true);
    config.put(ExecConstants.SSL_USE_HADOOP_CONF, true);
    SSLConfig sslv;
    try {
        sslv = new SSLConfigBuilder().config(config.build()).mode(SSLConfig.Mode.SERVER).initializeSSLContext(false).validateKeyStore(true).hadoopConfig(hadoopConfig).build();
        fail();
    } catch (Exception e) {
        assertTrue(e instanceof DrillException);
    }
}
Also used : SSLConfig(org.apache.drill.exec.ssl.SSLConfig) Configuration(org.apache.hadoop.conf.Configuration) SSLConfigBuilder(org.apache.drill.exec.ssl.SSLConfigBuilder) ConfigBuilder(org.apache.drill.test.ConfigBuilder) SSLConfigBuilder(org.apache.drill.exec.ssl.SSLConfigBuilder) DrillException(org.apache.drill.common.exceptions.DrillException) DrillException(org.apache.drill.common.exceptions.DrillException) Test(org.junit.Test) BaseTest(org.apache.drill.test.BaseTest) SecurityTest(org.apache.drill.categories.SecurityTest)

Example 14 with ConfigBuilder

use of org.apache.drill.test.ConfigBuilder in project drill by apache.

the class TestSSLConfig method testForTrustStore.

@Test
public void testForTrustStore() throws Exception {
    ConfigBuilder config = new ConfigBuilder();
    config.put(ExecConstants.HTTP_TRUSTSTORE_PATH, "/root");
    config.put(ExecConstants.HTTP_TRUSTSTORE_PASSWORD, "root");
    config.put(ExecConstants.SSL_USE_HADOOP_CONF, false);
    SSLConfig sslv = new SSLConfigBuilder().config(config.build()).mode(SSLConfig.Mode.SERVER).initializeSSLContext(false).validateKeyStore(true).build();
    assertEquals(true, sslv.hasTrustStorePath());
    assertEquals(true, sslv.hasTrustStorePassword());
    assertEquals("/root", sslv.getTrustStorePath());
    assertEquals("root", sslv.getTrustStorePassword());
}
Also used : SSLConfig(org.apache.drill.exec.ssl.SSLConfig) SSLConfigBuilder(org.apache.drill.exec.ssl.SSLConfigBuilder) ConfigBuilder(org.apache.drill.test.ConfigBuilder) SSLConfigBuilder(org.apache.drill.exec.ssl.SSLConfigBuilder) Test(org.junit.Test) BaseTest(org.apache.drill.test.BaseTest) SecurityTest(org.apache.drill.categories.SecurityTest)

Example 15 with ConfigBuilder

use of org.apache.drill.test.ConfigBuilder in project drill by apache.

the class TestSSLConfig method testMissingKeystorePassword.

@Test
public void testMissingKeystorePassword() throws Exception {
    ConfigBuilder config = new ConfigBuilder();
    config.put(ExecConstants.HTTP_KEYSTORE_PATH, "/root");
    config.put(ExecConstants.HTTP_KEYSTORE_PASSWORD, "");
    config.put(ExecConstants.SSL_USE_HADOOP_CONF, false);
    config.put(ExecConstants.USER_SSL_ENABLED, true);
    try {
        SSLConfig sslv = new SSLConfigBuilder().config(config.build()).mode(SSLConfig.Mode.SERVER).initializeSSLContext(false).validateKeyStore(true).build();
        fail();
    // Expected
    } catch (Exception e) {
        assertTrue(e instanceof DrillException);
    }
}
Also used : SSLConfig(org.apache.drill.exec.ssl.SSLConfig) SSLConfigBuilder(org.apache.drill.exec.ssl.SSLConfigBuilder) ConfigBuilder(org.apache.drill.test.ConfigBuilder) SSLConfigBuilder(org.apache.drill.exec.ssl.SSLConfigBuilder) DrillException(org.apache.drill.common.exceptions.DrillException) DrillException(org.apache.drill.common.exceptions.DrillException) Test(org.junit.Test) BaseTest(org.apache.drill.test.BaseTest) SecurityTest(org.apache.drill.categories.SecurityTest)

Aggregations

ConfigBuilder (org.apache.drill.test.ConfigBuilder)18 Test (org.junit.Test)18 SecurityTest (org.apache.drill.categories.SecurityTest)12 SSLConfig (org.apache.drill.exec.ssl.SSLConfig)12 SSLConfigBuilder (org.apache.drill.exec.ssl.SSLConfigBuilder)12 BaseTest (org.apache.drill.test.BaseTest)12 DrillException (org.apache.drill.common.exceptions.DrillException)8 Config (com.typesafe.config.Config)6 HttpProxyConfig (org.apache.drill.exec.store.http.util.HttpProxyConfig)6 Configuration (org.apache.hadoop.conf.Configuration)2 Ignore (org.junit.Ignore)1