public void applyClientConfiguration(String account, DataLakeFileSystemClientBuilder builder) {
    String sasToken = adlsSasTokens.get(account);
    if (sasToken != null && !sasToken.isEmpty()) {
      builder.sasToken(sasToken);
    } else if (namedKeyCreds != null) {
      builder.credential(
          new StorageSharedKeyCredential(namedKeyCreds.getKey(), namedKeyCreds.getValue()));
    } else {
      builder.credential(new DefaultAzureCredentialBuilder().build());
    }

    // apply connection string last so its parameters take precedence, e.g. SAS token
    String connectionString = adlsConnectionStrings.get(account);
    if (connectionString != null && !connectionString.isEmpty()) {
      builder.endpoint(connectionString);
    } else {
      builder.endpoint("https://" + account);
    }
  }
@Test
  public void testSharedKey() {
    assertThatIllegalArgumentException()
        .isThrownBy(
            () ->
                new AzureProperties(
                    ImmutableMap.of(
                        ADLS_SHARED_KEY_ACCOUNT_KEY, "not-really-base64-encoded-key-here")))
        .withMessage(
            String.format(
                "Azure authentication: shared-key requires both %s and %s",
                ADLS_SHARED_KEY_ACCOUNT_NAME, ADLS_SHARED_KEY_ACCOUNT_KEY));
    assertThatIllegalArgumentException()
        .isThrownBy(
            () -> new AzureProperties(ImmutableMap.of(ADLS_SHARED_KEY_ACCOUNT_NAME, "account")))
        .withMessage(
            String.format(
                "Azure authentication: shared-key requires both %s and %s",
                ADLS_SHARED_KEY_ACCOUNT_NAME, ADLS_SHARED_KEY_ACCOUNT_KEY));

    AzureProperties props =
        new AzureProperties(
            ImmutableMap.of(
                ADLS_SHARED_KEY_ACCOUNT_NAME,
                "account",
                ADLS_SHARED_KEY_ACCOUNT_KEY,
                "not-really-base64-encoded-key-here"));
    DataLakeFileSystemClientBuilder clientBuilder = mock(DataLakeFileSystemClientBuilder.class);
    props.applyClientConfiguration("account", clientBuilder);
    verify(clientBuilder).credential(any(StorageSharedKeyCredential.class));
    verify(clientBuilder, never()).credential(any(TokenCredential.class));
  }