| 1745 | } |
| 1746 | |
| 1747 | void TestSASCredential() { |
| 1748 | auto data = SetUpPreexistingData(); |
| 1749 | |
| 1750 | ASSERT_OK_AND_ASSIGN(auto env, GetAzureEnv()); |
| 1751 | ASSERT_OK_AND_ASSIGN(auto options, MakeOptions(env)); |
| 1752 | ASSERT_OK_AND_ASSIGN( |
| 1753 | auto sas_token, |
| 1754 | GetContainerSASToken(data.container_name, |
| 1755 | Azure::Storage::StorageSharedKeyCredential( |
| 1756 | env->account_name(), env->account_key()))); |
| 1757 | // AzureOptions::FromUri will not cut off extra query parameters that it consumes, so |
| 1758 | // make sure these don't cause problems. |
| 1759 | auto polluted_sas_token = "?blob_storage_authority=dummy_value0&" + |
| 1760 | sas_token.substr(1) + "&credential_kind=dummy-value1"; |
| 1761 | ARROW_EXPECT_OK(options.ConfigureSASCredential(polluted_sas_token)); |
| 1762 | ASSERT_EQ(options.AccountKey(), ""); |
| 1763 | ASSERT_EQ(options.SasToken(), polluted_sas_token); |
| 1764 | ASSERT_EQ(options.TenantId(), ""); |
| 1765 | ASSERT_EQ(options.ClientId(), ""); |
| 1766 | ASSERT_EQ(options.ClientSecret(), ""); |
| 1767 | EXPECT_OK_AND_ASSIGN(auto fs, AzureFileSystem::Make(options)); |
| 1768 | |
| 1769 | AssertFileInfo(fs.get(), data.ObjectPath(), FileType::File); |
| 1770 | |
| 1771 | // Test CopyFile because the most obvious implementation requires generating a SAS |
| 1772 | // token at runtime which doesn't work when the original auth is SAS token. |
| 1773 | ASSERT_OK(fs->CopyFile(data.ObjectPath(), data.ObjectPath() + "_copy")); |
| 1774 | AssertFileInfo(fs.get(), data.ObjectPath() + "_copy", FileType::File); |
| 1775 | } |
| 1776 | |
| 1777 | private: |
| 1778 | using StringMatcher = |
no test coverage detected