Skip to content

Commit

Permalink
Add environment to FromUri
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom-Newton committed Apr 28, 2024
1 parent 3ec7644 commit a3b6074
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cpp/src/arrow/filesystem/azurefs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ Status AzureOptions::ExtractFromUriQuery(const Uri& uri) {
credential_kind = CredentialKind::kAnonymous;
} else if (kv.second == "workload_identity") {
credential_kind = CredentialKind::kWorkloadIdentity;
} else if (kv.second == "environment") {
credential_kind = CredentialKind::kEnvironment;
} else {
// Other credential kinds should be inferred from the given
// parameters automatically.
Expand Down Expand Up @@ -171,6 +173,9 @@ Status AzureOptions::ExtractFromUriQuery(const Uri& uri) {
case CredentialKind::kWorkloadIdentity:
RETURN_NOT_OK(ConfigureWorkloadIdentityCredential());
break;
case CredentialKind::kEnvironment:
RETURN_NOT_OK(ConfigureEnvironmentCredential());
break;
default:
// Default credential
break;
Expand Down
12 changes: 12 additions & 0 deletions cpp/src/arrow/filesystem/azurefs_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,15 @@ class TestAzureOptions : public ::testing::Test {
ASSERT_EQ(options.credential_kind_, AzureOptions::CredentialKind::kWorkloadIdentity);
}

void TestFromUriCredentialEnvironment() {
ASSERT_OK_AND_ASSIGN(
auto options,
AzureOptions::FromUri("abfs://account.blob.core.windows.net/container/dir/blob?"
"credential_kind=environment",
nullptr));
ASSERT_EQ(options.credential_kind_, AzureOptions::CredentialKind::kEnvironment);
}

void TestFromUriCredentialInvalid() {
ASSERT_RAISES(Invalid, AzureOptions::FromUri(
"abfs://file_system@account.dfs.core.windows.net/dir/file?"
Expand Down Expand Up @@ -727,6 +736,9 @@ TEST_F(TestAzureOptions, FromUriCredentialManagedIdentity) {
TEST_F(TestAzureOptions, FromUriCredentialWorkloadIdentity) {
TestFromUriCredentialWorkloadIdentity();
}
TEST_F(TestAzureOptions, FromUriCredentialEnvironment) {
TestFromUriCredentialEnvironment();
}
TEST_F(TestAzureOptions, FromUriCredentialInvalid) { TestFromUriCredentialInvalid(); }
TEST_F(TestAzureOptions, FromUriBlobStorageAuthority) {
TestFromUriBlobStorageAuthority();
Expand Down

0 comments on commit a3b6074

Please sign in to comment.