2828import org .apache .hadoop .conf .Configuration ;
2929
3030import org .apache .hadoop .fs .Path ;
31- import org .apache .hadoop .fs .azurebfs .constants .ConfigurationKeys ;
3231import org .apache .hadoop .fs .azurebfs .constants .TestConfigurationKeys ;
3332import org .apache .hadoop .fs .azurebfs .contracts .exceptions .SASTokenProviderException ;
3433import org .apache .hadoop .fs .azurebfs .extensions .MockSASTokenProvider ;
3534import org .apache .hadoop .fs .azurebfs .services .AuthType ;
3635import org .apache .hadoop .fs .permission .FsAction ;
3736import org .apache .hadoop .fs .permission .FsPermission ;
3837
38+ import static org .apache .hadoop .fs .azurebfs .constants .ConfigurationKeys .FS_AZURE_ACCOUNT_AUTH_TYPE_PROPERTY_NAME ;
39+ import static org .apache .hadoop .fs .azurebfs .constants .ConfigurationKeys .FS_AZURE_ACCOUNT_IS_HNS_ENABLED ;
40+ import static org .apache .hadoop .fs .azurebfs .constants .ConfigurationKeys .FS_AZURE_SAS_TOKEN_PROVIDER_TYPE ;
3941import static org .apache .hadoop .fs .azurebfs .constants .TestConfigurationKeys .MOCK_SASTOKENPROVIDER_FAIL_INIT ;
4042import static org .apache .hadoop .fs .azurebfs .constants .TestConfigurationKeys .MOCK_SASTOKENPROVIDER_RETURN_EMPTY_SAS_TOKEN ;
4143import static org .apache .hadoop .fs .azurebfs .utils .AclTestHelpers .aclEntry ;
@@ -61,12 +63,12 @@ public ITestAzureBlobFileSystemAuthorization() throws Exception {
6163
6264 @ Override
6365 public void setup () throws Exception {
64- boolean isHNSEnabled = this . getConfiguration ().getBoolean (
66+ boolean isHNSEnabled = getConfiguration ().getBoolean (
6567 TestConfigurationKeys .FS_AZURE_TEST_NAMESPACE_ENABLED_ACCOUNT , false );
6668 Assume .assumeTrue (isHNSEnabled );
6769 loadConfiguredFileSystem ();
68- this . getConfiguration ().set (ConfigurationKeys . FS_AZURE_SAS_TOKEN_PROVIDER_TYPE , TEST_AUTHZ_CLASS );
69- this . getConfiguration ().set (ConfigurationKeys . FS_AZURE_ACCOUNT_AUTH_TYPE_PROPERTY_NAME , " SAS" );
70+ getConfiguration ().set (FS_AZURE_SAS_TOKEN_PROVIDER_TYPE , TEST_AUTHZ_CLASS );
71+ getConfiguration ().set (FS_AZURE_ACCOUNT_AUTH_TYPE_PROPERTY_NAME , AuthType . SAS . toString () );
7072 super .setup ();
7173 }
7274
@@ -75,13 +77,15 @@ public void testSASTokenProviderInitializeException() throws Exception {
7577 final AzureBlobFileSystem fs = this .getFileSystem ();
7678
7779 final AzureBlobFileSystem testFs = new AzureBlobFileSystem ();
78- Configuration testConfig = this .getConfiguration ().getRawConfiguration ();
79- testConfig .set (ConfigurationKeys .FS_AZURE_SAS_TOKEN_PROVIDER_TYPE , TEST_ERR_AUTHZ_CLASS );
80- testConfig .set (MOCK_SASTOKENPROVIDER_FAIL_INIT , "true" );
80+ Configuration testConfig = new Configuration (this .getConfiguration ().getRawConfiguration ());
81+ testConfig .set (FS_AZURE_SAS_TOKEN_PROVIDER_TYPE , TEST_ERR_AUTHZ_CLASS );
82+ testConfig .setBoolean (MOCK_SASTOKENPROVIDER_FAIL_INIT , true );
83+ // Setting IS_HNS_ENABLED to avoid the exception thrown by the HNS check.
84+ testConfig .setBoolean (FS_AZURE_ACCOUNT_IS_HNS_ENABLED , this .getIsNamespaceEnabled (fs ));
8185
8286 intercept (SASTokenProviderException .class ,
8387 ()-> {
84- testFs .initialize (fs .getUri (), this . getConfiguration (). getRawConfiguration () );
88+ testFs .initialize (fs .getUri (), testConfig );
8589 });
8690 }
8791
@@ -90,12 +94,13 @@ public void testSASTokenProviderEmptySASToken() throws Exception {
9094 final AzureBlobFileSystem fs = this .getFileSystem ();
9195
9296 final AzureBlobFileSystem testFs = new AzureBlobFileSystem ();
93- Configuration testConfig = this .getConfiguration ().getRawConfiguration ();
94- testConfig .set (ConfigurationKeys .FS_AZURE_SAS_TOKEN_PROVIDER_TYPE , TEST_ERR_AUTHZ_CLASS );
95- testConfig .set (MOCK_SASTOKENPROVIDER_RETURN_EMPTY_SAS_TOKEN , "true" );
97+ Configuration testConfig = new Configuration (this .getConfiguration ().getRawConfiguration ());
98+ testConfig .set (FS_AZURE_SAS_TOKEN_PROVIDER_TYPE , TEST_ERR_AUTHZ_CLASS );
99+ testConfig .setBoolean (MOCK_SASTOKENPROVIDER_RETURN_EMPTY_SAS_TOKEN , true );
100+ // Setting IS_HNS_ENABLED to avoid the exception thrown by the HNS check.
101+ testConfig .setBoolean (FS_AZURE_ACCOUNT_IS_HNS_ENABLED , this .getIsNamespaceEnabled (fs ));
96102
97- testFs .initialize (fs .getUri (),
98- this .getConfiguration ().getRawConfiguration ());
103+ testFs .initialize (fs .getUri (), testConfig );
99104 intercept (SASTokenProviderException .class ,
100105 () -> {
101106 testFs .create (new org .apache .hadoop .fs .Path ("/testFile" )).close ();
@@ -107,10 +112,13 @@ public void testSASTokenProviderNullSASToken() throws Exception {
107112 final AzureBlobFileSystem fs = this .getFileSystem ();
108113
109114 final AzureBlobFileSystem testFs = new AzureBlobFileSystem ();
110- Configuration testConfig = this .getConfiguration ().getRawConfiguration ();
111- testConfig .set (ConfigurationKeys .FS_AZURE_SAS_TOKEN_PROVIDER_TYPE , TEST_ERR_AUTHZ_CLASS );
115+ Configuration testConfig = new Configuration (this .getConfiguration ().getRawConfiguration ());
116+ testConfig .set (FS_AZURE_SAS_TOKEN_PROVIDER_TYPE , TEST_ERR_AUTHZ_CLASS );
117+ testConfig .setBoolean (MOCK_SASTOKENPROVIDER_RETURN_EMPTY_SAS_TOKEN , true );
118+ // Setting IS_HNS_ENABLED to avoid the exception thrown by the HNS check.
119+ testConfig .setBoolean (FS_AZURE_ACCOUNT_IS_HNS_ENABLED , this .getIsNamespaceEnabled (fs ));
112120
113- testFs .initialize (fs .getUri (), this . getConfiguration (). getRawConfiguration () );
121+ testFs .initialize (fs .getUri (), testConfig );
114122 intercept (SASTokenProviderException .class ,
115123 ()-> {
116124 testFs .create (new org .apache .hadoop .fs .Path ("/testFile" )).close ();
0 commit comments