From 7807dfdbafa1b07af1e2ec30e474568c133c1123 Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Mon, 21 Jun 2021 20:16:33 -0700 Subject: [PATCH 1/4] Fixed issue that prevented creating while providing an AzureNamedKeyCredential as the sole form of authentication. --- .../main/java/com/azure/data/tables/TableClientBuilder.java | 5 +++-- .../com/azure/data/tables/TableServiceClientBuilder.java | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClientBuilder.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClientBuilder.java index ab4fb4080aedd..0d7bbf5bb9022 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClientBuilder.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClientBuilder.java @@ -159,8 +159,9 @@ public TableAsyncClient buildAsyncClient() { } HttpPipeline pipeline = (httpPipeline != null) ? httpPipeline : BuilderHelper.buildPipeline( - namedKeyCredential, azureSasCredential, sasToken, endpoint, retryPolicy, httpLogOptions, - clientOptions, httpClient, perCallPolicies, perRetryPolicies, configuration, logger); + namedKeyCredential != null ? namedKeyCredential : azureNamedKeyCredential, azureSasCredential, sasToken, + endpoint, retryPolicy, httpLogOptions, clientOptions, httpClient, perCallPolicies, perRetryPolicies, + configuration, logger); return new TableAsyncClient(tableName, pipeline, endpoint, serviceVersion, TABLES_SERIALIZER, TRANSACTIONAL_BATCH_SERIALIZER); diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceClientBuilder.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceClientBuilder.java index 243947973b4e6..5d683777fa1d1 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceClientBuilder.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceClientBuilder.java @@ -156,8 +156,9 @@ public TableServiceAsyncClient buildAsyncClient() { } HttpPipeline pipeline = (httpPipeline != null) ? httpPipeline : BuilderHelper.buildPipeline( - namedKeyCredential, azureSasCredential, sasToken, endpoint, retryPolicy, httpLogOptions, - clientOptions, httpClient, perCallPolicies, perRetryPolicies, configuration, logger); + namedKeyCredential != null ? namedKeyCredential : azureNamedKeyCredential, azureSasCredential, sasToken, + endpoint, retryPolicy,httpLogOptions, clientOptions, httpClient, perCallPolicies, perRetryPolicies, + configuration, logger); return new TableServiceAsyncClient(pipeline, endpoint, serviceVersion, serializerAdapter); } From 48bc98ffc4f9233e9aff216929a7532655c98ca0 Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Mon, 21 Jun 2021 20:16:56 -0700 Subject: [PATCH 2/4] Added more tests involving credentials, SAS tokens and connection strings. --- .../tables/TableServiceClientBuilder.java | 2 +- .../data/tables/TableClientBuilderTest.java | 74 +++++++++++++++---- .../tables/TableServiceClientBuilderTest.java | 66 +++++++++++++---- 3 files changed, 115 insertions(+), 27 deletions(-) diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceClientBuilder.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceClientBuilder.java index 5d683777fa1d1..2b3cac0791f5d 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceClientBuilder.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceClientBuilder.java @@ -157,7 +157,7 @@ public TableServiceAsyncClient buildAsyncClient() { HttpPipeline pipeline = (httpPipeline != null) ? httpPipeline : BuilderHelper.buildPipeline( namedKeyCredential != null ? namedKeyCredential : azureNamedKeyCredential, azureSasCredential, sasToken, - endpoint, retryPolicy,httpLogOptions, clientOptions, httpClient, perCallPolicies, perRetryPolicies, + endpoint, retryPolicy, httpLogOptions, clientOptions, httpClient, perCallPolicies, perRetryPolicies, configuration, logger); return new TableServiceAsyncClient(pipeline, endpoint, serviceVersion, serializerAdapter); diff --git a/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableClientBuilderTest.java b/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableClientBuilderTest.java index 50dbd29adbcf5..dfe315f88ebb9 100644 --- a/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableClientBuilderTest.java +++ b/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableClientBuilderTest.java @@ -194,27 +194,62 @@ public void addPerCallPolicy() { assertTrue(retryPolicyPosition < perRetryPolicyPosition); } + @Test + public void singleFormOfAuthenticationPresent() { + assertDoesNotThrow(() -> new TableClientBuilder() + .sasToken("sasToken") + .endpoint("https://myAccount.table.core.windows.net") + .tableName("myTable") + .buildAsyncClient()); + + assertDoesNotThrow(() -> new TableClientBuilder() + .credential(new AzureSasCredential("sasToken")) + .endpoint("https://myAccount.table.core.windows.net") + .tableName("myTable") + .buildAsyncClient()); + + assertDoesNotThrow(() -> new TableClientBuilder() + .credential(new AzureNamedKeyCredential("name", "key")) + .endpoint("https://myAccount.table.core.windows.net") + .tableName("myTable") + .buildAsyncClient()); + + // Should internally create an AzureNamedKeyCredential and not throw when building a client. + assertDoesNotThrow(() -> new TableClientBuilder() + .connectionString("DefaultEndpointsProtocol=https;AccountName=myAccount;AccountKey=myKey;EndpointSuffix=core.windows.net") + .endpoint("https://myAccount.table.core.windows.net") + .tableName("myTable") + .buildAsyncClient()); + + // Should internally create an AzureSasCredential and not throw when building a client. + assertDoesNotThrow(() -> new TableClientBuilder() + .connectionString("TableEndpoint=https://myAccount.table.core.windows.net;SharedAccessSignature=sv=2020-02-10&ss=t&srt=o&sp=rwdlacu&se=2021-06-04T04:45:57Z&st=2021-06-03T20:45:57Z&spr=https&sig=someSignature") + .endpoint("https://myAccount.table.core.windows.net") + .tableName("myTable") + .buildAsyncClient()); + } + @Test public void multipleFormsOfAuthenticationPresent() { assertThrows(IllegalStateException.class, () -> new TableClientBuilder() .sasToken("sasToken") .credential(new AzureNamedKeyCredential("name", "key")) .tableName("myTable") - .endpoint("https://myaccount.table.core.windows.net") + .endpoint("https://myAccount.table.core.windows.net") .buildAsyncClient()); assertThrows(IllegalStateException.class, () -> new TableClientBuilder() .sasToken("sasToken") .credential(new AzureSasCredential("sasToken")) .tableName("myTable") - .endpoint("https://myaccount.table.core.windows.net") + .endpoint("https://myAccount.table.core.windows.net") .buildAsyncClient()); assertThrows(IllegalStateException.class, () -> new TableClientBuilder() .credential(new AzureNamedKeyCredential("name", "key")) .credential(new AzureSasCredential("sasToken")) .tableName("myTable") - .endpoint("https://myaccount.table.core.windows.net") + .endpoint("https://myAccount.table.core.windows.net") .buildAsyncClient()); assertThrows(IllegalStateException.class, () -> new TableClientBuilder() @@ -222,7 +257,7 @@ public void multipleFormsOfAuthenticationPresent() { .credential(new AzureNamedKeyCredential("name", "key")) .credential(new AzureSasCredential("sasToken")) .tableName("myTable") - .endpoint("https://myaccount.table.core.windows.net") + .endpoint("https://myAccount.table.core.windows.net") .buildAsyncClient()); } @@ -230,7 +265,7 @@ public void multipleFormsOfAuthenticationPresent() { public void buildWithSameSasTokenInConnectionStringDoesNotThrow() { assertDoesNotThrow(() -> new TableClientBuilder() .sasToken("sv=2020-02-10&ss=t&srt=o&sp=rwdlacu&se=2021-06-04T04:45:57Z&st=2021-06-03T20:45:57Z&spr=https&sig=someSignature") - .connectionString("TableEndpoint=https://myaccount.table.core.windows.net/;SharedAccessSignature=sv=2020-02-10&ss=t&srt=o&sp=rwdlacu&se=2021-06-04T04:45:57Z&st=2021-06-03T20:45:57Z&spr=https&sig=someSignature") + .connectionString("TableEndpoint=https://myAccount.table.core.windows.net/;SharedAccessSignature=sv=2020-02-10&ss=t&srt=o&sp=rwdlacu&se=2021-06-04T04:45:57Z&st=2021-06-03T20:45:57Z&spr=https&sig=someSignature") .tableName("myTable") .buildAsyncClient()); } @@ -239,7 +274,7 @@ public void buildWithSameSasTokenInConnectionStringDoesNotThrow() { public void buildWithDifferentSasTokenInConnectionStringThrows() { assertThrows(IllegalStateException.class, () -> new TableClientBuilder() .sasToken("sv=2020-02-10&ss=t&srt=o&sp=rwd&se=2021-06-04T04:45:57Z&st=2021-06-03T20:45:57Z&spr=https&sig=someSignature") - .connectionString("TableEndpoint=https://myaccount.table.core.windows.net/;SharedAccessSignature=sv=2020-02-10&ss=t&srt=o&sp=rwdlacu&se=2021-06-04T04:45:57Z&st=2021-06-03T20:45:57Z&spr=https&sig=anotherSignature") + .connectionString("TableEndpoint=https://myAccount.table.core.windows.net/;SharedAccessSignature=sv=2020-02-10&ss=t&srt=o&sp=rwdlacu&se=2021-06-04T04:45:57Z&st=2021-06-03T20:45:57Z&spr=https&sig=anotherSignature") .tableName("myTable") .buildAsyncClient()); } @@ -247,26 +282,39 @@ public void buildWithDifferentSasTokenInConnectionStringThrows() { @Test public void buildWithSameEndpointInConnectionStringDoesNotThrow() { assertDoesNotThrow(() -> new TableClientBuilder() - .endpoint("https://myaccount.table.core.windows.net/") - .connectionString("TableEndpoint=https://myaccount.table.core.windows.net/;SharedAccessSignature=sv=2020-02-10&ss=t&srt=o&sp=rwdlacu&se=2021-06-04T04:45:57Z&st=2021-06-03T20:45:57Z&spr=https&sig=someSignature") + .endpoint("https://myAccount.table.core.windows.net/") + .connectionString("TableEndpoint=https://myAccount.table.core.windows.net/;SharedAccessSignature=sv=2020-02-10&ss=t&srt=o&sp=rwdlacu&se=2021-06-04T04:45:57Z&st=2021-06-03T20:45:57Z&spr=https&sig=someSignature") .tableName("myTable") .buildAsyncClient()); } @Test - public void buildWithSameEndpointInConnectionStringWithTrailingSlashDoesNotThrow() { + public void buildWithWithTrailingSlashInEndpointOrConnectionStringDoesNotThrow() { assertDoesNotThrow(() -> new TableClientBuilder() - .endpoint("https://myaccount.table.core.windows.net") - .connectionString("TableEndpoint=https://myaccount.table.core.windows.net/;SharedAccessSignature=sv=2020-02-10&ss=t&srt=o&sp=rwdlacu&se=2021-06-04T04:45:57Z&st=2021-06-03T20:45:57Z&spr=https&sig=someSignature") + .endpoint("https://myAccount.table.core.windows.net") + .connectionString("TableEndpoint=https://myAccount.table.core.windows.net/;SharedAccessSignature=sv=2020-02-10&ss=t&srt=o&sp=rwdlacu&se=2021-06-04T04:45:57Z&st=2021-06-03T20:45:57Z&spr=https&sig=someSignature") + .tableName("myTable") + .buildAsyncClient()); + + assertDoesNotThrow(() -> new TableClientBuilder() + .endpoint("https://myAccount.table.core.windows.net/") + .connectionString("TableEndpoint=https://myAccount.table.core.windows.net;SharedAccessSignature=sv=2020-02-10&ss=t&srt=o&sp=rwdlacu&se=2021-06-04T04:45:57Z&st=2021-06-03T20:45:57Z&spr=https&sig=someSignature") .tableName("myTable") .buildAsyncClient()); } + @Test public void buildWithDifferentEndpointInConnectionStringThrows() { assertThrows(IllegalStateException.class, () -> new TableClientBuilder() - .endpoint("https://myotheraccount.table.core.windows.net/") - .connectionString("TableEndpoint=https://myaccount.table.core.windows.net/;SharedAccessSignature=sv=2020-02-10&ss=t&srt=o&sp=rwdlacu&se=2021-06-04T04:45:57Z&st=2021-06-03T20:45:57Z&spr=https&sig=someSignature") + .endpoint("https://myOtherAccount.table.core.windows.net/") + .connectionString("TableEndpoint=https://myAccount.table.core.windows.net/;SharedAccessSignature=sv=2020-02-10&ss=t&srt=o&sp=rwdlacu&se=2021-06-04T04:45:57Z&st=2021-06-03T20:45:57Z&spr=https&sig=someSignature") + .tableName("myTable") + .buildAsyncClient()); + + assertThrows(IllegalStateException.class, () -> new TableClientBuilder() + .endpoint("https://myAccount.table.core.windows.net/") + .connectionString("DefaultEndpointsProtocol=https;AccountName=myOtherAccount;AccountKey=myKey;EndpointSuffix=core.windows.net") .tableName("myTable") .buildAsyncClient()); } diff --git a/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableServiceClientBuilderTest.java b/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableServiceClientBuilderTest.java index 8667309445a86..90ace0bac420e 100644 --- a/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableServiceClientBuilderTest.java +++ b/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableServiceClientBuilderTest.java @@ -185,31 +185,61 @@ public void addPerCallPolicy() { assertTrue(retryPolicyPosition < perRetryPolicyPosition); } + @Test + public void singleFormOfAuthenticationPresent() { + assertDoesNotThrow(() -> new TableServiceClientBuilder() + .sasToken("sasToken") + .endpoint("https://myAccount.table.core.windows.net") + .buildAsyncClient()); + + assertDoesNotThrow(() -> new TableServiceClientBuilder() + .credential(new AzureSasCredential("sasToken")) + .endpoint("https://myAccount.table.core.windows.net") + .buildAsyncClient()); + + assertDoesNotThrow(() -> new TableServiceClientBuilder() + .credential(new AzureNamedKeyCredential("name", "key")) + .endpoint("https://myAccount.table.core.windows.net") + .buildAsyncClient()); + + // Should internally create an AzureNamedKeyCredential and not throw when building a client. + assertDoesNotThrow(() -> new TableServiceClientBuilder() + .connectionString("DefaultEndpointsProtocol=https;AccountName=myAccount;AccountKey=myKey;EndpointSuffix=core.windows.net") + .endpoint("https://myAccount.table.core.windows.net") + .buildAsyncClient()); + + // Should internally create an AzureSasCredential and not throw when building a client. + assertDoesNotThrow(() -> new TableServiceClientBuilder() + .connectionString("TableEndpoint=https://myAccount.table.core.windows.net;SharedAccessSignature=sv=2020-02-10&ss=t&srt=o&sp=rwdlacu&se=2021-06-04T04:45:57Z&st=2021-06-03T20:45:57Z&spr=https&sig=someSignature") + .endpoint("https://myAccount.table.core.windows.net") + .buildAsyncClient()); + } + @Test public void multipleFormsOfAuthenticationPresent() { assertThrows(IllegalStateException.class, () -> new TableServiceClientBuilder() .sasToken("sasToken") .credential(new AzureNamedKeyCredential("name", "key")) - .endpoint("https://myaccount.table.core.windows.net") + .endpoint("https://myAccount.table.core.windows.net") .buildAsyncClient()); assertThrows(IllegalStateException.class, () -> new TableServiceClientBuilder() .sasToken("sasToken") .credential(new AzureSasCredential("sasToken")) - .endpoint("https://myaccount.table.core.windows.net") + .endpoint("https://myAccount.table.core.windows.net") .buildAsyncClient()); assertThrows(IllegalStateException.class, () -> new TableServiceClientBuilder() .credential(new AzureNamedKeyCredential("name", "key")) .credential(new AzureSasCredential("sasToken")) - .endpoint("https://myaccount.table.core.windows.net") + .endpoint("https://myAccount.table.core.windows.net") .buildAsyncClient()); assertThrows(IllegalStateException.class, () -> new TableServiceClientBuilder() .sasToken("sasToken") .credential(new AzureNamedKeyCredential("name", "key")) .credential(new AzureSasCredential("sasToken")) - .endpoint("https://myaccount.table.core.windows.net") + .endpoint("https://myAccount.table.core.windows.net") .buildAsyncClient()); } @@ -217,7 +247,7 @@ public void multipleFormsOfAuthenticationPresent() { public void buildWithSameSasTokenInConnectionStringDoesNotThrow() { assertDoesNotThrow(() -> new TableServiceClientBuilder() .sasToken("sv=2020-02-10&ss=t&srt=o&sp=rwdlacu&se=2021-06-04T04:45:57Z&st=2021-06-03T20:45:57Z&spr=https&sig=someSignature") - .connectionString("TableEndpoint=https://myaccount.table.core.windows.net/;SharedAccessSignature=sv=2020-02-10&ss=t&srt=o&sp=rwdlacu&se=2021-06-04T04:45:57Z&st=2021-06-03T20:45:57Z&spr=https&sig=someSignature") + .connectionString("TableEndpoint=https://myAccount.table.core.windows.net/;SharedAccessSignature=sv=2020-02-10&ss=t&srt=o&sp=rwdlacu&se=2021-06-04T04:45:57Z&st=2021-06-03T20:45:57Z&spr=https&sig=someSignature") .buildAsyncClient()); } @@ -225,31 +255,41 @@ public void buildWithSameSasTokenInConnectionStringDoesNotThrow() { public void buildWithDifferentSasTokenInConnectionStringThrows() { assertThrows(IllegalStateException.class, () -> new TableServiceClientBuilder() .sasToken("sv=2020-02-10&ss=t&srt=o&sp=rwd&se=2021-06-04T04:45:57Z&st=2021-06-03T20:45:57Z&spr=https&sig=someSignature") - .connectionString("TableEndpoint=https://myaccount.table.core.windows.net/;SharedAccessSignature=sv=2020-02-10&ss=t&srt=o&sp=rwdlacu&se=2021-06-04T04:45:57Z&st=2021-06-03T20:45:57Z&spr=https&sig=anotherSignature") + .connectionString("TableEndpoint=https://myAccount.table.core.windows.net/;SharedAccessSignature=sv=2020-02-10&ss=t&srt=o&sp=rwdlacu&se=2021-06-04T04:45:57Z&st=2021-06-03T20:45:57Z&spr=https&sig=anotherSignature") .buildAsyncClient()); } @Test public void buildWithSameEndpointInConnectionStringDoesNotThrow() { assertDoesNotThrow(() -> new TableServiceClientBuilder() - .endpoint("https://myaccount.table.core.windows.net/") - .connectionString("TableEndpoint=https://myaccount.table.core.windows.net/;SharedAccessSignature=sv=2020-02-10&ss=t&srt=o&sp=rwdlacu&se=2021-06-04T04:45:57Z&st=2021-06-03T20:45:57Z&spr=https&sig=someSignature") + .endpoint("https://myAccount.table.core.windows.net/") + .connectionString("TableEndpoint=https://myAccount.table.core.windows.net/;SharedAccessSignature=sv=2020-02-10&ss=t&srt=o&sp=rwdlacu&se=2021-06-04T04:45:57Z&st=2021-06-03T20:45:57Z&spr=https&sig=someSignature") .buildAsyncClient()); } @Test - public void buildWithSameEndpointInConnectionStringWithTrailingSlashDoesNotThrow() { + public void buildWithWithTrailingSlashInEndpointOrConnectionStringDoesNotThrow() { assertDoesNotThrow(() -> new TableServiceClientBuilder() - .endpoint("https://myaccount.table.core.windows.net") - .connectionString("TableEndpoint=https://myaccount.table.core.windows.net/;SharedAccessSignature=sv=2020-02-10&ss=t&srt=o&sp=rwdlacu&se=2021-06-04T04:45:57Z&st=2021-06-03T20:45:57Z&spr=https&sig=someSignature") + .endpoint("https://myAccount.table.core.windows.net") + .connectionString("TableEndpoint=https://myAccount.table.core.windows.net/;SharedAccessSignature=sv=2020-02-10&ss=t&srt=o&sp=rwdlacu&se=2021-06-04T04:45:57Z&st=2021-06-03T20:45:57Z&spr=https&sig=someSignature") + .buildAsyncClient()); + + assertDoesNotThrow(() -> new TableServiceClientBuilder() + .endpoint("https://myAccount.table.core.windows.net/") + .connectionString("TableEndpoint=https://myAccount.table.core.windows.net;SharedAccessSignature=sv=2020-02-10&ss=t&srt=o&sp=rwdlacu&se=2021-06-04T04:45:57Z&st=2021-06-03T20:45:57Z&spr=https&sig=someSignature") .buildAsyncClient()); } @Test public void buildWithDifferentEndpointInConnectionStringThrows() { assertThrows(IllegalStateException.class, () -> new TableServiceClientBuilder() - .endpoint("https://myotheraccount.table.core.windows.net/") - .connectionString("TableEndpoint=https://myaccount.table.core.windows.net/;SharedAccessSignature=sv=2020-02-10&ss=t&srt=o&sp=rwdlacu&se=2021-06-04T04:45:57Z&st=2021-06-03T20:45:57Z&spr=https&sig=someSignature") + .endpoint("https://myAccount.table.core.windows.net/") + .connectionString("TableEndpoint=https://myOtherAccount.table.core.windows.net/;SharedAccessSignature=sv=2020-02-10&ss=t&srt=o&sp=rwdlacu&se=2021-06-04T04:45:57Z&st=2021-06-03T20:45:57Z&spr=https&sig=someSignature") + .buildAsyncClient()); + + assertThrows(IllegalStateException.class, () -> new TableServiceClientBuilder() + .endpoint("https://myAccount.table.core.windows.net/") + .connectionString("DefaultEndpointsProtocol=https;AccountName=myOtherAccount;AccountKey=myKey;EndpointSuffix=core.windows.net") .buildAsyncClient()); } } From 3634e714474bc71aa2a1d43810d79b45ef4b928f Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Tue, 22 Jun 2021 17:38:49 -0700 Subject: [PATCH 3/4] Fixed issue where a `connectionString` with an account name and key would override a SAS token's authentication settings. --- .../src/main/java/com/azure/data/tables/BuilderHelper.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/BuilderHelper.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/BuilderHelper.java index 7e6473337ea02..2f58df994608a 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/BuilderHelper.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/BuilderHelper.java @@ -145,11 +145,14 @@ static void validateCredentials(AzureNamedKeyCredential azureNamedKeyCredential, return; } else { throw logger.logExceptionAsError(new IllegalStateException("'connectionString' contains a SAS token" - + " with different settings than 'sasToken'.")); + + " with different settings than the one provided using the builder's 'sasToken()' method.")); } + } else if (authSettings.getType() == StorageAuthenticationSettings.Type.ACCOUNT_NAME_KEY) { + throw logger.logExceptionAsError(new IllegalStateException("A 'connectionString' containing an account" + + "name and key cannot be provided alongside a 'sasToken'.")); } - // If the 'connectionString' auth type is not SAS_TOKEN and a 'sasToken' was provided, then multiplte + // If the 'connectionString' auth type is not SAS_TOKEN and a 'sasToken' was provided, then multiple // incompatible forms of authentication were specified in the client builder. } From 87f81571a3adb2a7f85d72679c8276fc8eb2c1f5 Mon Sep 17 00:00:00 2001 From: Victor Colin Amador Date: Tue, 22 Jun 2021 17:42:15 -0700 Subject: [PATCH 4/4] Updated CHANGELOG. --- sdk/tables/azure-data-tables/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sdk/tables/azure-data-tables/CHANGELOG.md b/sdk/tables/azure-data-tables/CHANGELOG.md index bcb99437ee100..8e4ea48f0821d 100644 --- a/sdk/tables/azure-data-tables/CHANGELOG.md +++ b/sdk/tables/azure-data-tables/CHANGELOG.md @@ -2,6 +2,8 @@ ## 12.1.0-beta.1 (Unreleased) +### Bug fixes +- Fixed an issue where a `connectionString` with an account name and key would override a `sasToken`'s authentication settings in client builders. ## 12.0.0 (2021-06-11)