| 1765 | } |
| 1766 | |
| 1767 | void TestSASCredential() { |
| 1768 | auto data = SetUpPreexistingData(); |
| 1769 | |
| 1770 | ASSERT_OK_AND_ASSIGN(auto env, GetAzureEnv()); |
| 1771 | ASSERT_OK_AND_ASSIGN(auto options, MakeOptions(env)); |
| 1772 | ASSERT_OK_AND_ASSIGN( |
| 1773 | auto sas_token, |
| 1774 | GetContainerSASToken(data.container_name, |
| 1775 | Azure::Storage::StorageSharedKeyCredential( |
| 1776 | env->account_name(), env->account_key()))); |
| 1777 | // AzureOptions::FromUri will not cut off extra query parameters that it consumes, so |
| 1778 | // make sure these don't cause problems. |
| 1779 | auto polluted_sas_token = "?blob_storage_authority=dummy_value0&" + |
| 1780 | sas_token.substr(1) + "&credential_kind=dummy-value1"; |
| 1781 | ARROW_EXPECT_OK(options.ConfigureSASCredential(polluted_sas_token)); |
| 1782 | ASSERT_EQ(options.AccountKey(), ""); |
| 1783 | ASSERT_EQ(options.SasToken(), polluted_sas_token); |
| 1784 | ASSERT_EQ(options.TenantId(), ""); |
| 1785 | ASSERT_EQ(options.ClientId(), ""); |
| 1786 | ASSERT_EQ(options.ClientSecret(), ""); |
| 1787 | EXPECT_OK_AND_ASSIGN(auto fs, AzureFileSystem::Make(options)); |
| 1788 | |
| 1789 | AssertFileInfo(fs.get(), data.ObjectPath(), FileType::File); |
| 1790 | |
| 1791 | // Test CopyFile because the most obvious implementation requires generating a SAS |
| 1792 | // token at runtime which doesn't work when the original auth is SAS token. |
| 1793 | ASSERT_OK(fs->CopyFile(data.ObjectPath(), data.ObjectPath() + "_copy")); |
| 1794 | AssertFileInfo(fs.get(), data.ObjectPath() + "_copy", FileType::File); |
| 1795 | } |
| 1796 | |
| 1797 | private: |
| 1798 | using StringMatcher = |
no test coverage detected