From 61a3d5f2f63745affe650e6c7485c2f32aff8b37 Mon Sep 17 00:00:00 2001 From: Andrey Pleskach Date: Sun, 13 Feb 2022 22:51:08 +0100 Subject: [PATCH] Migration Azure to affix settings All Azure settings have such prefix: aive.s3.*. - Pass Map of AzureClientSettings - EncryptionKeyProvider now creates/recreates together with Azure client --- .../azure/AzureClientSettings.java | 140 ++++++++++++------ .../azure/AzureRepositoryPlugin.java | 4 +- .../AzureRepositoryStorageIOProvider.java | 6 +- .../azure/AzureSettingsProvider.java | 5 +- .../azure/AzureClientProviderTest.java | 29 +++- .../azure/AzureClientSettingsTest.java | 138 ++++++++++------- 6 files changed, 207 insertions(+), 115 deletions(-) diff --git a/repository-azure/src/main/java/io/aiven/elasticsearch/repositories/azure/AzureClientSettings.java b/repository-azure/src/main/java/io/aiven/elasticsearch/repositories/azure/AzureClientSettings.java index ea821a4..27c9b3a 100644 --- a/repository-azure/src/main/java/io/aiven/elasticsearch/repositories/azure/AzureClientSettings.java +++ b/repository-azure/src/main/java/io/aiven/elasticsearch/repositories/azure/AzureClientSettings.java @@ -18,6 +18,9 @@ import java.io.IOException; import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; import org.opensearch.common.settings.SecureSetting; import org.opensearch.common.settings.SecureString; @@ -28,46 +31,84 @@ import io.aiven.elasticsearch.repositories.CommonSettings; import static io.aiven.elasticsearch.repositories.CommonSettings.ClientSettings.checkSettings; +import static io.aiven.elasticsearch.repositories.CommonSettings.ClientSettings.getConfigValue; import static io.aiven.elasticsearch.repositories.CommonSettings.ClientSettings.readInputStream; -import static io.aiven.elasticsearch.repositories.CommonSettings.ClientSettings.withPrefix; public class AzureClientSettings implements CommonSettings.ClientSettings { + static final String AZURE_PREFIX = AIVEN_PREFIX + "azure."; + static final String AZURE_CONNECTION_STRING_TEMPLATE = "DefaultEndpointsProtocol=https;AccountName=%s;AccountKey=%s"; - static final Setting AZURE_HTTP_POOL_MIN_THREADS = - Setting.intSetting(withPrefix("azure.http.thread_pool.min"), - Runtime.getRuntime().availableProcessors() * 2 - 1, 1, Setting.Property.NodeScope); - - static final Setting AZURE_HTTP_POOL_MAX_THREADS = - Setting.intSetting(withPrefix("azure.http.thread_pool.max"), - Runtime.getRuntime().availableProcessors() * 2 - 1, 1, Setting.Property.NodeScope); - - static final Setting AZURE_HTTP_POOL_KEEP_ALIVE = - Setting.timeSetting(withPrefix("azure.http.thread_pool.keep_alive"), TimeValue.timeValueSeconds(30L), - Setting.Property.NodeScope); - - static final Setting AZURE_HTTP_POOL_WORKING_QUEUE_SIZE = - Setting.intSetting(withPrefix("azure.http.thread_pool.working_queue_size"), 1000, 10, - Setting.Property.NodeScope); - - - public static final Setting PUBLIC_KEY_FILE = - SecureSetting.secureFile(withPrefix("azure.public_key_file"), null); - - public static final Setting PRIVATE_KEY_FILE = - SecureSetting.secureFile(withPrefix("azure.private_key_file"), null); - - public static final Setting AZURE_ACCOUNT = - SecureSetting.secureString(withPrefix("azure.client.account"), null); - - public static final Setting AZURE_ACCOUNT_KEY = - SecureSetting.secureString(withPrefix("azure.client.account.key"), null); + static final Setting.AffixSetting AZURE_HTTP_POOL_MIN_THREADS = + Setting.affixKeySetting( + AZURE_PREFIX, + "http.thread_pool.min", + key -> Setting.intSetting(key, + Runtime.getRuntime().availableProcessors() * 2 - 1, 1, + Setting.Property.NodeScope) + ); + + static final Setting.AffixSetting AZURE_HTTP_POOL_MAX_THREADS = + Setting.affixKeySetting( + AZURE_PREFIX, + "http.thread_pool.max", + key -> Setting.intSetting(key, + Runtime.getRuntime().availableProcessors() * 2 - 1, 1, + Setting.Property.NodeScope) + ); + + static final Setting.AffixSetting AZURE_HTTP_POOL_KEEP_ALIVE = + Setting.affixKeySetting( + AZURE_PREFIX, + "http.thread_pool.keep_alive", + key -> Setting.timeSetting(key, TimeValue.timeValueSeconds(30L), Setting.Property.NodeScope) + ); + + static final Setting.AffixSetting AZURE_HTTP_POOL_WORKING_QUEUE_SIZE = + Setting.affixKeySetting( + AZURE_PREFIX, + "http.thread_pool.working_queue_size", + key -> Setting.intSetting(key, 1000, 10, Setting.Property.NodeScope) + ); + + + public static final Setting.AffixSetting PUBLIC_KEY_FILE = + Setting.affixKeySetting( + AZURE_PREFIX, + "public_key_file", + key -> SecureSetting.secureFile(key, null) + ); + + public static final Setting.AffixSetting PRIVATE_KEY_FILE = + Setting.affixKeySetting( + AZURE_PREFIX, + "private_key_file", + key -> SecureSetting.secureFile(key, null) + ); + + public static final Setting.AffixSetting AZURE_ACCOUNT = + Setting.affixKeySetting( + AZURE_PREFIX, + "client.account", + key -> SecureSetting.secureString(key, null) + ); + + public static final Setting.AffixSetting AZURE_ACCOUNT_KEY = + Setting.affixKeySetting( + AZURE_PREFIX, + "client.account.key", + key -> SecureSetting.secureString(key, null) + ); //default is 3 please take a look ExponentialBackoff azure class - public static final Setting MAX_RETRIES = - Setting.intSetting(withPrefix("max_retries"), 3, Setting.Property.NodeScope); + public static final Setting.AffixSetting MAX_RETRIES = + Setting.affixKeySetting( + AZURE_PREFIX, + "max_retries", + key -> Setting.intSetting(key, 3, Setting.Property.NodeScope) + ); private final byte[] publicKey; @@ -119,22 +160,31 @@ public int maxRetries() { return maxRetries; } - public static AzureClientSettings create(final Settings settings) throws IOException { - checkSettings(AZURE_ACCOUNT, settings); - checkSettings(AZURE_ACCOUNT_KEY, settings); - checkSettings(PUBLIC_KEY_FILE, settings); - checkSettings(PRIVATE_KEY_FILE, settings); + public static Map create(final Settings settings) throws IOException { + final Set clientNames = settings.getGroups(AZURE_PREFIX).keySet(); + final var clientSettings = new HashMap(); + for (final var clientName : clientNames) { + clientSettings.put(clientName, createSettings(clientName, settings)); + } + return Map.copyOf(clientSettings); + } + + static AzureClientSettings createSettings(final String clientName, final Settings settings) throws IOException { + checkSettings(AZURE_ACCOUNT, clientName, settings); + checkSettings(AZURE_ACCOUNT_KEY, clientName, settings); + checkSettings(PUBLIC_KEY_FILE, clientName, settings); + checkSettings(PRIVATE_KEY_FILE, clientName, settings); return new AzureClientSettings( - readInputStream(PUBLIC_KEY_FILE, settings), - readInputStream(PRIVATE_KEY_FILE, settings), - AZURE_ACCOUNT.get(settings).toString(), - AZURE_ACCOUNT_KEY.get(settings).toString(), - MAX_RETRIES.get(settings), + readInputStream(getConfigValue(settings, clientName, PUBLIC_KEY_FILE)), + readInputStream(getConfigValue(settings, clientName, PRIVATE_KEY_FILE)), + getConfigValue(settings, clientName, AZURE_ACCOUNT).toString(), + getConfigValue(settings, clientName, AZURE_ACCOUNT_KEY).toString(), + getConfigValue(settings, clientName, MAX_RETRIES), new HttpThreadPoolSettings( - AZURE_HTTP_POOL_MIN_THREADS.get(settings), - AZURE_HTTP_POOL_MAX_THREADS.get(settings), - AZURE_HTTP_POOL_KEEP_ALIVE.get(settings).getMillis(), - AZURE_HTTP_POOL_WORKING_QUEUE_SIZE.get(settings)) + getConfigValue(settings, clientName, AZURE_HTTP_POOL_MIN_THREADS), + getConfigValue(settings, clientName, AZURE_HTTP_POOL_MAX_THREADS), + getConfigValue(settings, clientName, AZURE_HTTP_POOL_KEEP_ALIVE).getMillis(), + getConfigValue(settings, clientName, AZURE_HTTP_POOL_WORKING_QUEUE_SIZE)) ); } diff --git a/repository-azure/src/main/java/io/aiven/elasticsearch/repositories/azure/AzureRepositoryPlugin.java b/repository-azure/src/main/java/io/aiven/elasticsearch/repositories/azure/AzureRepositoryPlugin.java index 6704895..0fc25a7 100644 --- a/repository-azure/src/main/java/io/aiven/elasticsearch/repositories/azure/AzureRepositoryPlugin.java +++ b/repository-azure/src/main/java/io/aiven/elasticsearch/repositories/azure/AzureRepositoryPlugin.java @@ -25,12 +25,14 @@ import com.azure.storage.blob.BlobServiceClient; +import static io.aiven.elasticsearch.repositories.azure.AzureClientSettings.AZURE_PREFIX; + public class AzureRepositoryPlugin extends AbstractRepositoryPlugin { public static final String REPOSITORY_TYPE = "aiven-azure"; public AzureRepositoryPlugin(final Settings settings) { - super(REPOSITORY_TYPE, settings, new AzureSettingsProvider()); + super(REPOSITORY_TYPE, AZURE_PREFIX, settings, new AzureSettingsProvider()); } @Override diff --git a/repository-azure/src/main/java/io/aiven/elasticsearch/repositories/azure/AzureRepositoryStorageIOProvider.java b/repository-azure/src/main/java/io/aiven/elasticsearch/repositories/azure/AzureRepositoryStorageIOProvider.java index b650614..af9fc94 100644 --- a/repository-azure/src/main/java/io/aiven/elasticsearch/repositories/azure/AzureRepositoryStorageIOProvider.java +++ b/repository-azure/src/main/java/io/aiven/elasticsearch/repositories/azure/AzureRepositoryStorageIOProvider.java @@ -37,7 +37,6 @@ import io.aiven.elasticsearch.repositories.Permissions; import io.aiven.elasticsearch.repositories.RepositoryStorageIOProvider; import io.aiven.elasticsearch.repositories.io.CryptoIOProvider; -import io.aiven.elasticsearch.repositories.security.EncryptionKeyProvider; import com.azure.storage.blob.BlobContainerClient; import com.azure.storage.blob.BlobServiceClient; @@ -50,9 +49,8 @@ public class AzureRepositoryStorageIOProvider static final Setting CONTAINER_NAME = Setting.simpleString("container_name"); - public AzureRepositoryStorageIOProvider(final AzureClientSettings clientSettings, - final EncryptionKeyProvider encryptionKeyProvider) { - super(new AzureClientProvider(), clientSettings, encryptionKeyProvider); + public AzureRepositoryStorageIOProvider(final Map clientSettings) { + super(new AzureClientProvider(), clientSettings); } @Override diff --git a/repository-azure/src/main/java/io/aiven/elasticsearch/repositories/azure/AzureSettingsProvider.java b/repository-azure/src/main/java/io/aiven/elasticsearch/repositories/azure/AzureSettingsProvider.java index d791c37..104aa93 100644 --- a/repository-azure/src/main/java/io/aiven/elasticsearch/repositories/azure/AzureSettingsProvider.java +++ b/repository-azure/src/main/java/io/aiven/elasticsearch/repositories/azure/AzureSettingsProvider.java @@ -23,7 +23,6 @@ import io.aiven.elasticsearch.repositories.Permissions; import io.aiven.elasticsearch.repositories.RepositorySettingsProvider; import io.aiven.elasticsearch.repositories.RepositoryStorageIOProvider; -import io.aiven.elasticsearch.repositories.security.EncryptionKeyProvider; import com.azure.storage.blob.BlobServiceClient; @@ -34,10 +33,8 @@ protected RepositoryStorageIOProvider cr final Settings settings) throws IOException { return Permissions.doPrivileged(() -> { final var azureClientSettings = AzureClientSettings.create(settings); - final var encryptionKeyProvider = - EncryptionKeyProvider.of(azureClientSettings.publicKey(), azureClientSettings.privateKey()); return Permissions.doPrivileged(() -> - new AzureRepositoryStorageIOProvider(azureClientSettings, encryptionKeyProvider)); + new AzureRepositoryStorageIOProvider(azureClientSettings)); }); } diff --git a/repository-azure/src/test/java/io/aiven/elasticsearch/repositories/azure/AzureClientProviderTest.java b/repository-azure/src/test/java/io/aiven/elasticsearch/repositories/azure/AzureClientProviderTest.java index 35ebe77..b1c4ed7 100644 --- a/repository-azure/src/test/java/io/aiven/elasticsearch/repositories/azure/AzureClientProviderTest.java +++ b/repository-azure/src/test/java/io/aiven/elasticsearch/repositories/azure/AzureClientProviderTest.java @@ -39,6 +39,10 @@ import org.mockito.junit.jupiter.MockitoExtension; import static io.aiven.elasticsearch.repositories.CommonSettings.RepositorySettings.MAX_RETRIES; +import static io.aiven.elasticsearch.repositories.azure.AzureClientSettings.AZURE_ACCOUNT; +import static io.aiven.elasticsearch.repositories.azure.AzureClientSettings.AZURE_ACCOUNT_KEY; +import static io.aiven.elasticsearch.repositories.azure.AzureClientSettings.PRIVATE_KEY_FILE; +import static io.aiven.elasticsearch.repositories.azure.AzureClientSettings.PUBLIC_KEY_FILE; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.never; import static org.mockito.Mockito.times; @@ -109,8 +113,9 @@ void testBuildClient() throws Exception { .put("some_settings_2", 210) .build(); + final var azureClientSettings = AzureClientSettings.create(settings); final var client = azureClientProvider - .buildClientIfNeeded(AzureClientSettings.create(settings), repoSettings); + .buildClientIfNeeded(azureClientSettings.get("default"), repoSettings).v2(); assertEquals("AZURE_ACCOUNT", client.getAccountName()); @@ -131,8 +136,9 @@ void testMaxRetriesOverridesClientSettings() throws Exception { .put("some_settings_2", 210) .build(); + final var azureClientSettings = AzureClientSettings.create(settings); final var client = azureClientProvider - .buildClientIfNeeded(AzureClientSettings.create(settings), repoSettings); + .buildClientIfNeeded(azureClientSettings.get("default"), repoSettings).v2(); assertEquals("AZURE_ACCOUNT", client.getAccountName()); @@ -145,13 +151,22 @@ void testMaxRetriesOverridesClientSettings() throws Exception { private Settings createSettings() throws IOException { final var secureSettings = new DummySecureSettings() - .setString(AzureClientSettings.AZURE_ACCOUNT.getKey(), "AZURE_ACCOUNT") - .setString(AzureClientSettings.AZURE_ACCOUNT_KEY.getKey(), "AZURE_ACCOUNT_KEY") - .setFile(AzureClientSettings.PUBLIC_KEY_FILE.getKey(), Files.newInputStream(publicKeyPem)) - .setFile(AzureClientSettings.PRIVATE_KEY_FILE.getKey(), Files.newInputStream(privateKeyPem)); + .setString( + AZURE_ACCOUNT.getConcreteSettingForNamespace("default").getKey(), + "AZURE_ACCOUNT" + ).setString( + AZURE_ACCOUNT_KEY.getConcreteSettingForNamespace("default").getKey(), + "AZURE_ACCOUNT_KEY" + ).setFile( + PUBLIC_KEY_FILE.getConcreteSettingForNamespace("default").getKey(), + Files.newInputStream(publicKeyPem) + ).setFile( + PRIVATE_KEY_FILE.getConcreteSettingForNamespace("default").getKey(), + Files.newInputStream(privateKeyPem) + ); return Settings.builder() - .put(AzureClientSettings.MAX_RETRIES.getKey(), 12) + .put(AzureClientSettings.MAX_RETRIES.getConcreteSettingForNamespace("default").getKey(), 12) .setSecureSettings(secureSettings) .build(); } diff --git a/repository-azure/src/test/java/io/aiven/elasticsearch/repositories/azure/AzureClientSettingsTest.java b/repository-azure/src/test/java/io/aiven/elasticsearch/repositories/azure/AzureClientSettingsTest.java index be08ecf..c933f44 100644 --- a/repository-azure/src/test/java/io/aiven/elasticsearch/repositories/azure/AzureClientSettingsTest.java +++ b/repository-azure/src/test/java/io/aiven/elasticsearch/repositories/azure/AzureClientSettingsTest.java @@ -27,6 +27,14 @@ import org.junit.jupiter.api.Test; +import static io.aiven.elasticsearch.repositories.azure.AzureClientSettings.AZURE_ACCOUNT; +import static io.aiven.elasticsearch.repositories.azure.AzureClientSettings.AZURE_ACCOUNT_KEY; +import static io.aiven.elasticsearch.repositories.azure.AzureClientSettings.AZURE_HTTP_POOL_KEEP_ALIVE; +import static io.aiven.elasticsearch.repositories.azure.AzureClientSettings.AZURE_HTTP_POOL_MAX_THREADS; +import static io.aiven.elasticsearch.repositories.azure.AzureClientSettings.AZURE_HTTP_POOL_MIN_THREADS; +import static io.aiven.elasticsearch.repositories.azure.AzureClientSettings.MAX_RETRIES; +import static io.aiven.elasticsearch.repositories.azure.AzureClientSettings.PRIVATE_KEY_FILE; +import static io.aiven.elasticsearch.repositories.azure.AzureClientSettings.PUBLIC_KEY_FILE; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -34,57 +42,62 @@ class AzureClientSettingsTest extends RsaKeyAwareTest { @Test void failsForEmptyPublicKey() throws IOException { - final var settings = - Settings.builder() - .setSecureSettings( - new DummySecureSettings() - .setString(AzureClientSettings.AZURE_ACCOUNT.getKey(), "some_account") - .setString(AzureClientSettings.AZURE_ACCOUNT_KEY.getKey(), "some_account_key") - .setFile( - AzureClientSettings.PRIVATE_KEY_FILE.getKey(), - Files.newInputStream(privateKeyPem) - ) - ).build(); + final var securitySettings = + new DummySecureSettings() + .setString( + AZURE_ACCOUNT.getConcreteSettingForNamespace("default").getKey(), + "some_account" + ).setString( + AZURE_ACCOUNT_KEY.getConcreteSettingForNamespace("default").getKey(), + "some_account_key") + .setFile( + PRIVATE_KEY_FILE.getConcreteSettingForNamespace("default").getKey(), + Files.newInputStream(privateKeyPem) + ); + final var settings = Settings.builder().setSecureSettings(securitySettings).build(); final var t = assertThrows( IllegalArgumentException.class, () -> AzureClientSettings.create(settings)); - assertEquals("Settings with name aiven.azure.public_key_file hasn't been set", t.getMessage()); + assertEquals("Settings with name aiven.azure.default.public_key_file hasn't been set", + t.getMessage()); } @Test void failsForEmptyPrivateKey() throws IOException { - final var settings = - Settings.builder() - .setSecureSettings( - new DummySecureSettings() - .setString(AzureClientSettings.AZURE_ACCOUNT.getKey(), "some_account") - .setString( - AzureClientSettings.AZURE_ACCOUNT_KEY.getKey(), - "some_account_key" - ) - .setFile( - AzureClientSettings.PUBLIC_KEY_FILE.getKey(), - Files.newInputStream(publicKeyPem) - ) - ).build(); + final var securitySettings = + new DummySecureSettings() + .setString( + AZURE_ACCOUNT.getConcreteSettingForNamespace("default").getKey(), + "some_account" + ).setString( + AZURE_ACCOUNT_KEY.getConcreteSettingForNamespace("default").getKey(), + "some_account_key" + ).setFile( + PUBLIC_KEY_FILE.getConcreteSettingForNamespace("default").getKey(), + Files.newInputStream(publicKeyPem) + ); + final var settings = Settings.builder().setSecureSettings(securitySettings).build(); final var t = assertThrows( IllegalArgumentException.class, () -> AzureClientSettings.create(settings)); - assertEquals("Settings with name aiven.azure.private_key_file hasn't been set", t.getMessage()); + assertEquals("Settings with name aiven.azure.default.private_key_file hasn't been set", t.getMessage()); } @Test void failsForEmptyAzureAccount() { final var secureSettings = new DummySecureSettings() - .setString(AzureClientSettings.AZURE_ACCOUNT_KEY.getKey(), "some_key"); + .setString( + AZURE_ACCOUNT_KEY.getConcreteSettingForNamespace("default").getKey(), + "some_key" + ); final var t = assertThrows(IllegalArgumentException.class, () -> AzureClientSettings.create(Settings.builder() .setSecureSettings(secureSettings).build())); - assertEquals("Settings with name aiven.azure.client.account hasn't been set", t.getMessage()); + assertEquals("Settings with name aiven.azure.default.client.account hasn't been set", t.getMessage()); } @Test @@ -92,33 +105,41 @@ void failsForEmptyAzureAccountKey() { final var secureSettings = new DummySecureSettings() - .setString(AzureClientSettings.AZURE_ACCOUNT.getKey(), "some_account"); + .setString( + AZURE_ACCOUNT.getConcreteSettingForNamespace("default").getKey(), + "some_account" + ); final var t = assertThrows(IllegalArgumentException.class, () -> AzureClientSettings.create(Settings.builder() .setSecureSettings(secureSettings).build())); - assertEquals("Settings with name aiven.azure.client.account.key hasn't been set", t.getMessage()); + assertEquals("Settings with name aiven.azure.default.client.account.key hasn't been set", + t.getMessage()); } @Test void loadDefaultSettings() throws IOException { final var secureSettings = new DummySecureSettings() - .setString(AzureClientSettings.AZURE_ACCOUNT.getKey(), "some_account") - .setString(AzureClientSettings.AZURE_ACCOUNT_KEY.getKey(), "some_account_key") + .setString( + AZURE_ACCOUNT.getConcreteSettingForNamespace("default").getKey(), + "some_account" + ).setString( + AZURE_ACCOUNT_KEY.getConcreteSettingForNamespace("default").getKey(), + "some_account_key") .setFile( - AzureClientSettings.PUBLIC_KEY_FILE.getKey(), + PUBLIC_KEY_FILE.getConcreteSettingForNamespace("default").getKey(), Files.newInputStream(publicKeyPem) ) .setFile( - AzureClientSettings.PRIVATE_KEY_FILE.getKey(), + PRIVATE_KEY_FILE.getConcreteSettingForNamespace("default").getKey(), Files.newInputStream(privateKeyPem) ); final var azureClientSettings = - AzureClientSettings.create(Settings.builder().setSecureSettings(secureSettings).build()); + AzureClientSettings.create(Settings.builder().setSecureSettings(secureSettings).build()).get("default"); assertEquals("some_account", azureClientSettings.azureAccount()); assertEquals("some_account_key", azureClientSettings.azureAccountKey()); @@ -138,32 +159,41 @@ void loadDefaultSettings() throws IOException { @Test void overrideDefaultSettings() throws IOException { - final var settingsBuilder = Settings.builder(); - settingsBuilder.setSecureSettings( + final var securitySettings = new DummySecureSettings() - .setString(AzureClientSettings.AZURE_ACCOUNT.getKey(), "some_account") - .setString(AzureClientSettings.AZURE_ACCOUNT_KEY.getKey(), "some_account_key") + .setString( + AZURE_ACCOUNT.getConcreteSettingForNamespace("default").getKey(), + "some_account" + ).setString( + AZURE_ACCOUNT_KEY.getConcreteSettingForNamespace("default").getKey(), + "some_account_key") .setFile( - AzureClientSettings.PUBLIC_KEY_FILE.getKey(), - Files.newInputStream(publicKeyPem) + PUBLIC_KEY_FILE.getConcreteSettingForNamespace("default").getKey(), + Files.newInputStream(publicKeyPem) ) .setFile( - AzureClientSettings.PRIVATE_KEY_FILE.getKey(), - Files.newInputStream(privateKeyPem) - ) - ); - - settingsBuilder.put(AzureClientSettings.MAX_RETRIES.getKey(), 42); - - settingsBuilder.put(AzureClientSettings.AZURE_HTTP_POOL_MIN_THREADS.getKey(), 10); - settingsBuilder.put(AzureClientSettings.AZURE_HTTP_POOL_MAX_THREADS.getKey(), 32); + PRIVATE_KEY_FILE.getConcreteSettingForNamespace("default").getKey(), + Files.newInputStream(privateKeyPem) + ); + final var settingsBuilder = Settings.builder(); + settingsBuilder.setSecureSettings(securitySettings); settingsBuilder.put( - AzureClientSettings.AZURE_HTTP_POOL_KEEP_ALIVE.getKey(), - TimeValue.timeValueMillis(1000L)); + MAX_RETRIES.getConcreteSettingForNamespace("default").getKey(), + 42 + ).put( + AZURE_HTTP_POOL_MIN_THREADS.getConcreteSettingForNamespace("default").getKey(), + 10 + ).put( + AZURE_HTTP_POOL_MAX_THREADS.getConcreteSettingForNamespace("default").getKey(), + 32 + ).put( + AZURE_HTTP_POOL_KEEP_ALIVE.getConcreteSettingForNamespace("default").getKey(), + TimeValue.timeValueMillis(1000L) + ); final var azureClientSettings = - AzureClientSettings.create(settingsBuilder.build()); + AzureClientSettings.create(settingsBuilder.build()).get("default"); assertEquals("some_account", azureClientSettings.azureAccount()); assertEquals("some_account_key", azureClientSettings.azureAccountKey());