Search in sources :

Example 16 with SettingsException

use of org.opensearch.common.settings.SettingsException in project OpenSearch by opensearch-project.

the class AzureStorageServiceTests method testProxyNoHost.

public void testProxyNoHost() {
    final Settings settings = Settings.builder().setSecureSettings(buildSecureSettings()).put("azure.client.azure1.proxy.port", 8080).put("azure.client.azure1.proxy.type", randomFrom("socks", "socks4", "socks5", "http")).build();
    final SettingsException e = expectThrows(SettingsException.class, () -> storageServiceWithSettingsValidation(settings));
    assertEquals("Azure proxy type has been set but proxy host or port is not defined.", e.getMessage());
}
Also used : SettingsException(org.opensearch.common.settings.SettingsException) MockSecureSettings(org.opensearch.common.settings.MockSecureSettings) Settings(org.opensearch.common.settings.Settings)

Example 17 with SettingsException

use of org.opensearch.common.settings.SettingsException in project OpenSearch by opensearch-project.

the class AzureStorageServiceTests method testProxyWrongHost.

public void testProxyWrongHost() {
    final Settings settings = Settings.builder().setSecureSettings(buildSecureSettings()).put("azure.client.azure1.proxy.type", randomFrom("socks", "socks4", "socks5", "http")).put("azure.client.azure1.proxy.host", "thisisnotavalidhostorwehavebeensuperunlucky").put("azure.client.azure1.proxy.port", 8080).build();
    final SettingsException e = expectThrows(SettingsException.class, () -> storageServiceWithSettingsValidation(settings));
    assertEquals("Azure proxy host is unknown.", e.getMessage());
}
Also used : SettingsException(org.opensearch.common.settings.SettingsException) MockSecureSettings(org.opensearch.common.settings.MockSecureSettings) Settings(org.opensearch.common.settings.Settings)

Example 18 with SettingsException

use of org.opensearch.common.settings.SettingsException in project OpenSearch by opensearch-project.

the class AzureStorageServiceTests method testGetSelectedClientNonExisting.

public void testGetSelectedClientNonExisting() {
    final AzureStorageService azureStorageService = storageServiceWithSettingsValidation(buildSettings());
    final SettingsException e = expectThrows(SettingsException.class, () -> azureStorageService.client("azure4"));
    assertThat(e.getMessage(), is("Unable to find client with name [azure4]"));
}
Also used : SettingsException(org.opensearch.common.settings.SettingsException)

Example 19 with SettingsException

use of org.opensearch.common.settings.SettingsException in project OpenSearch by opensearch-project.

the class AzureStorageServiceTests method testReinitClientEmptySettings.

public void testReinitClientEmptySettings() throws IOException {
    final MockSecureSettings secureSettings = new MockSecureSettings();
    secureSettings.setString("azure.client.azure1.account", "myaccount1");
    secureSettings.setString("azure.client.azure1.key", encodeKey("mykey11"));
    final Settings settings = Settings.builder().setSecureSettings(secureSettings).build();
    try (AzureRepositoryPlugin plugin = pluginWithSettingsValidation(settings)) {
        final AzureStorageService azureStorageService = plugin.azureStoreService;
        final BlobServiceClient client11 = azureStorageService.client("azure1").v1();
        assertThat(client11.getAccountUrl(), equalTo("https://myaccount1.blob.core.windows.net"));
        // reinit with empty settings
        final SettingsException e = expectThrows(SettingsException.class, () -> plugin.reload(Settings.EMPTY));
        assertThat(e.getMessage(), is("If you want to use an azure repository, you need to define a client configuration."));
        // existing client untouched
        assertThat(client11.getAccountUrl(), equalTo("https://myaccount1.blob.core.windows.net"));
        // new client also untouched
        final BlobServiceClient client21 = azureStorageService.client("azure1").v1();
        assertThat(client21.getAccountUrl(), equalTo("https://myaccount1.blob.core.windows.net"));
    }
}
Also used : BlobServiceClient(com.azure.storage.blob.BlobServiceClient) SettingsException(org.opensearch.common.settings.SettingsException) MockSecureSettings(org.opensearch.common.settings.MockSecureSettings) MockSecureSettings(org.opensearch.common.settings.MockSecureSettings) Settings(org.opensearch.common.settings.Settings)

Example 20 with SettingsException

use of org.opensearch.common.settings.SettingsException in project OpenSearch by opensearch-project.

the class AzureStorageServiceTests method testProxyNoPort.

public void testProxyNoPort() {
    final Settings settings = Settings.builder().setSecureSettings(buildSecureSettings()).put("azure.client.azure1.proxy.host", "127.0.0.1").put("azure.client.azure1.proxy.type", randomFrom("socks", "socks4", "socks5", "http")).build();
    final SettingsException e = expectThrows(SettingsException.class, () -> storageServiceWithSettingsValidation(settings));
    assertEquals("Azure proxy type has been set but proxy host or port is not defined.", e.getMessage());
}
Also used : SettingsException(org.opensearch.common.settings.SettingsException) MockSecureSettings(org.opensearch.common.settings.MockSecureSettings) Settings(org.opensearch.common.settings.Settings)

Aggregations

SettingsException (org.opensearch.common.settings.SettingsException)23 Settings (org.opensearch.common.settings.Settings)15 MockSecureSettings (org.opensearch.common.settings.MockSecureSettings)14 SecureString (org.opensearch.common.settings.SecureString)4 BlobServiceClient (com.azure.storage.blob.BlobServiceClient)3 GoogleCloudStorageClientSettings.getClientSettings (org.opensearch.repositories.gcs.GoogleCloudStorageClientSettings.getClientSettings)3 IOException (java.io.IOException)2 InetAddress (java.net.InetAddress)2 UnknownHostException (java.net.UnknownHostException)2 Path (java.nio.file.Path)2 AWSCredentials (com.amazonaws.auth.AWSCredentials)1 BasicAWSCredentials (com.amazonaws.auth.BasicAWSCredentials)1 BasicSessionCredentials (com.amazonaws.auth.BasicSessionCredentials)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 Proxy (java.net.Proxy)1 HashMap (java.util.HashMap)1 PatternSyntaxException (java.util.regex.PatternSyntaxException)1 ToXContent (org.opensearch.common.xcontent.ToXContent)1 XContentBuilder (org.opensearch.common.xcontent.XContentBuilder)1