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());
}
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());
}
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]"));
}
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"));
}
}
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());
}
Aggregations