Search in sources :

Example 76 with InMemoryRepository

use of com.github.joschi.jadconfig.repositories.InMemoryRepository in project graylog2-server by Graylog2.

the class BaseConfigurationTest method webTlsValidationFailsIfPrivateKeyIsMissing.

@Test
public void webTlsValidationFailsIfPrivateKeyIsMissing() throws Exception {
    final File privateKey = temporaryFolder.newFile("graylog.key");
    final File certificate = temporaryFolder.newFile("graylog.crt");
    validProperties.put("web_enable_tls", "true");
    validProperties.put("web_tls_key_file", privateKey.getAbsolutePath());
    validProperties.put("web_tls_cert_file", certificate.getAbsolutePath());
    assertThat(privateKey.delete()).isTrue();
    expectedException.expect(ValidationException.class);
    expectedException.expectMessage("Unreadable or missing web interface private key: ");
    new JadConfig(new InMemoryRepository(validProperties), new Configuration()).process();
}
Also used : JadConfig(com.github.joschi.jadconfig.JadConfig) InMemoryRepository(com.github.joschi.jadconfig.repositories.InMemoryRepository) File(java.io.File) Test(org.junit.Test)

Example 77 with InMemoryRepository

use of com.github.joschi.jadconfig.repositories.InMemoryRepository in project graylog2-server by Graylog2.

the class BaseConfigurationTest method restTlsValidationFailsIfPrivateKeyIsMissing.

@Test
public void restTlsValidationFailsIfPrivateKeyIsMissing() throws Exception {
    final File privateKey = temporaryFolder.newFile("graylog.key");
    final File certificate = temporaryFolder.newFile("graylog.crt");
    validProperties.put("rest_enable_tls", "true");
    validProperties.put("rest_tls_key_file", privateKey.getAbsolutePath());
    validProperties.put("rest_tls_cert_file", certificate.getAbsolutePath());
    assertThat(privateKey.delete()).isTrue();
    expectedException.expect(ValidationException.class);
    expectedException.expectMessage("Unreadable or missing REST API private key: ");
    new JadConfig(new InMemoryRepository(validProperties), new Configuration()).process();
}
Also used : JadConfig(com.github.joschi.jadconfig.JadConfig) InMemoryRepository(com.github.joschi.jadconfig.repositories.InMemoryRepository) File(java.io.File) Test(org.junit.Test)

Example 78 with InMemoryRepository

use of com.github.joschi.jadconfig.repositories.InMemoryRepository in project graylog2-server by Graylog2.

the class BaseConfigurationTest method restTlsValidationFailsIfCertificateIsMissing.

@Test
public void restTlsValidationFailsIfCertificateIsMissing() throws Exception {
    final File privateKey = temporaryFolder.newFile("graylog.key");
    final File certificate = temporaryFolder.newFile("graylog.crt");
    validProperties.put("rest_enable_tls", "true");
    validProperties.put("rest_tls_key_file", privateKey.getAbsolutePath());
    validProperties.put("rest_tls_cert_file", certificate.getAbsolutePath());
    assertThat(certificate.delete()).isTrue();
    expectedException.expect(ValidationException.class);
    expectedException.expectMessage("Unreadable or missing REST API X.509 certificate: ");
    new JadConfig(new InMemoryRepository(validProperties), new Configuration()).process();
}
Also used : JadConfig(com.github.joschi.jadconfig.JadConfig) InMemoryRepository(com.github.joschi.jadconfig.repositories.InMemoryRepository) File(java.io.File) Test(org.junit.Test)

Example 79 with InMemoryRepository

use of com.github.joschi.jadconfig.repositories.InMemoryRepository in project graylog2-server by Graylog2.

the class ElasticsearchConfigurationTest method throwValidationExceptionIfHomePathIsNotADirectory.

@Test(expected = ValidationException.class)
public void throwValidationExceptionIfHomePathIsNotADirectory() throws Exception {
    final File path = temporaryFolder.newFile("elasticsearch-home");
    final ElasticsearchConfiguration configuration = new ElasticsearchConfiguration() {

        @Override
        public String getPathHome() {
            return path.getAbsolutePath();
        }
    };
    new JadConfig(new InMemoryRepository(), configuration).process();
}
Also used : JadConfig(com.github.joschi.jadconfig.JadConfig) InMemoryRepository(com.github.joschi.jadconfig.repositories.InMemoryRepository) File(java.io.File) Test(org.junit.Test)

Example 80 with InMemoryRepository

use of com.github.joschi.jadconfig.repositories.InMemoryRepository in project graylog2-server by Graylog2.

the class ElasticsearchConfigurationTest method throwValidationExceptionIfHomePathIsNotReadable.

@Test(expected = ValidationException.class)
public void throwValidationExceptionIfHomePathIsNotReadable() throws Exception {
    final File path = temporaryFolder.newFolder("elasticsearch-home");
    assumeTrue(path.setReadable(false));
    final ElasticsearchConfiguration configuration = new ElasticsearchConfiguration() {

        @Override
        public String getPathHome() {
            return path.getAbsolutePath();
        }
    };
    new JadConfig(new InMemoryRepository(), configuration).process();
}
Also used : JadConfig(com.github.joschi.jadconfig.JadConfig) InMemoryRepository(com.github.joschi.jadconfig.repositories.InMemoryRepository) File(java.io.File) Test(org.junit.Test)

Aggregations

InMemoryRepository (com.github.joschi.jadconfig.repositories.InMemoryRepository)117 Test (org.junit.Test)115 JadConfig (com.github.joschi.jadconfig.JadConfig)86 File (java.io.File)25 ValidationException (com.github.joschi.jadconfig.ValidationException)5 Ignore (org.junit.Ignore)4 ElasticsearchConfiguration (org.graylog2.configuration.ElasticsearchConfiguration)3 Settings (org.elasticsearch.common.settings.Settings)2 RepositoryException (com.github.joschi.jadconfig.RepositoryException)1 GuavaConverterFactory (com.github.joschi.jadconfig.guava.GuavaConverterFactory)1 HashMap (java.util.HashMap)1