Skip to content

Commit 2912980

Browse files
author
Anuj Modi
committed
PR Checks
1 parent 92cb671 commit 2912980

File tree

8 files changed

+29
-25
lines changed

8 files changed

+29
-25
lines changed

hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/AbfsConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,7 @@ public AccessTokenProvider getTokenProvider() throws TokenAccessProviderExceptio
959959
* requires relying on the raw configurations. It is more stable to depend on the
960960
* AbfsConfiguration with which a filesystem is initialized,
961961
* and eliminate chances of dynamic modifications and spurious situations.
962-
* @return sasTokenProvider object
962+
* @return sasTokenProvider object.
963963
* @throws AzureBlobFileSystemException
964964
*/
965965
public SASTokenProvider getSASTokenProvider() throws AzureBlobFileSystemException {

hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/AzureBlobFileSystem.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1308,7 +1308,6 @@ public void access(final Path path, final FsAction mode) throws IOException {
13081308

13091309
/**
13101310
* Incrementing exists() calls from superclass for statistic collection.
1311-
*
13121311
* @param f source path.
13131312
* @return true if the path exists.
13141313
* @throws IOException

hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/ITestAzureBlobFileSystemChooseSAS.java

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,19 @@
3939

4040
/**
4141
* Tests to validate the choice between using a SASTokenProvider to generate
42-
* a SAS or using a Fixed SAS Token configured by user. To differentiate which config was used we will use different type of SAS Tokens.
43-
* For Fixed SAS Token we will use an Account SAS with permissions to do File system level operations.
44-
* For SASTokenProvider we will use a User Delegation SAS Token Provider such that File System level operations are not permitted.
42+
* a SAS or using a Fixed SAS Token configured by user.
4543
*/
4644
public class ITestAzureBlobFileSystemChooseSAS extends AbstractAbfsIntegrationTest{
4745

4846
private String accountSAS = null;
4947

48+
49+
/**
50+
* To differentiate which config was used we will use different type of SAS Tokens.
51+
* For Fixed SAS Token we will use an Account SAS with permissions to do File system level operations.
52+
* For SASTokenProvider we will use a User Delegation SAS Token Provider
53+
* such that File System level operations are not permitted.
54+
*/
5055
public ITestAzureBlobFileSystemChooseSAS() throws Exception {
5156
// SAS Token configured might not have permissions for creating file system.
5257
// Shared Key must be configured to create one. Once created, a new instance
@@ -61,7 +66,7 @@ public void setup() throws Exception {
6166
generateAccountSAS(); }
6267

6368
/**
64-
* Generates a Account SAS Token using the Account Shared Key to be used as a fixed SAS Token
69+
* Generates a Account SAS Token using the Account Shared Key to be used as a fixed SAS Token.
6570
* This will be used by individual tests to set in the configurations.
6671
* @throws AzureBlobFileSystemException
6772
*/
@@ -72,7 +77,7 @@ private void generateAccountSAS() throws AzureBlobFileSystemException {
7277
}
7378

7479
/**
75-
* Tests the scenario where both the SASTokenProvider and a fixed SAS token are configured:
80+
* Tests the scenario where both the SASTokenProvider and a fixed SAS token are configured.
7681
* SASTokenProvider class should be chosen and User Delegation SAS should be used.
7782
* @throws Exception
7883
*/
@@ -85,10 +90,10 @@ public void testBothProviderFixedTokenConfigured() throws Exception {
8590
testAbfsConfig.set(FS_AZURE_SAS_TOKEN_PROVIDER_TYPE,
8691
MockDelegationSASTokenProvider.class.getName());
8792

88-
// configuring the Fixed SAS token which is an Account SAS
93+
// configuring the Fixed SAS token which is an Account SAS.
8994
testAbfsConfig.set(FS_AZURE_SAS_FIXED_TOKEN, accountSAS);
9095

91-
// Creating a new file system with updated configs
96+
// Creating a new file system with updated configs.
9297
try (AzureBlobFileSystem newTestFs = (AzureBlobFileSystem)
9398
FileSystem.newInstance(testAbfsConfig.getRawConfiguration())) {
9499
TracingContext tracingContext = getTestTracingContext(newTestFs, true);
@@ -98,14 +103,14 @@ public void testBothProviderFixedTokenConfigured() throws Exception {
98103
newTestFs.getAbfsStore().getFilesystemProperties(tracingContext);
99104
});
100105

101-
// Asserting that User delegation SAS token is otherwise valid and blob level operations succeed
106+
// Asserting that User delegation SAS token is otherwise valid and blob level operations succeed.
102107
Path testPath = new Path("/testCorrectSASToken");
103108
newTestFs.create(testPath).close();
104109
}
105110
}
106111

107112
/**
108-
* Tests the scenario where only the fixed token is configured, and no token provider class is set:
113+
* Tests the scenario where only the fixed token is configured, and no token provider class is set.
109114
* Account SAS Token configured as fixed SAS should be used.
110115
* @throws IOException
111116
*/
@@ -114,10 +119,10 @@ public void testOnlyFixedTokenConfigured() throws IOException {
114119
AbfsConfiguration testAbfsConfig = getConfiguration();
115120
removeAnyPresetConfiguration(testAbfsConfig);
116121

117-
// setting an account SAS token in the fixed token field
122+
// setting an account SAS token in the fixed token field.
118123
testAbfsConfig.set(FS_AZURE_SAS_FIXED_TOKEN, accountSAS);
119124

120-
// Creating a new filesystem with updated configs
125+
// Creating a new filesystem with updated configs.
121126
try (AzureBlobFileSystem newTestFs = (AzureBlobFileSystem)
122127
FileSystem.newInstance(testAbfsConfig.getRawConfiguration())) {
123128

@@ -130,8 +135,8 @@ public void testOnlyFixedTokenConfigured() throws IOException {
130135
}
131136

132137
/**
133-
* Tests the scenario where both the token provider class and the fixed token are not configured:
134-
* whether the code errors out at the initialization stage itself
138+
* Tests the scenario where both the token provider class and the fixed token are not configured.
139+
* The code errors out at the initialization stage itself.
135140
* @throws IOException
136141
*/
137142
@Test

hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/extensions/MockDelegationSASTokenProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
import org.apache.hadoop.security.AccessControlException;
4141

4242
/**
43-
* A mock SAS token provider implementation
43+
* A mock SAS token provider implementation.
4444
*/
4545
public class MockDelegationSASTokenProvider implements SASTokenProvider {
4646

hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/extensions/MockSASTokenProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
import org.apache.hadoop.fs.azurebfs.utils.ServiceSASGenerator;
3333

3434
/**
35-
* A mock SAS token provider implementation for testing purpose
36-
* Account SAS with full permission is created using storage account key
35+
* A mock SAS token provider implementation for testing purpose.
36+
* Account SAS with full permission is created using storage account key.
3737
*/
3838
public class MockSASTokenProvider implements SASTokenProvider {
3939

hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/utils/AccountSASGenerator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
public class AccountSASGenerator extends SASGenerator {
3131
/**
3232
* Creates Account SAS from Storage Account Key.
33-
* https://learn.microsoft.com/en-us/rest/api/storageservices/create-account-sas
34-
* @param accountKey: the storage account key
33+
* https://learn.microsoft.com/en-us/rest/api/storageservices/create-account-sas.
34+
* @param accountKey: the storage account key.
3535
*/
3636
public AccountSASGenerator(byte[] accountKey) {
3737
super(accountKey);

hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/utils/SASGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ private SASGenerator() {
7070

7171
/**
7272
* Called by subclasses to initialize the cryptographic SHA-256 HMAC provider.
73-
* @param key - a 256-bit secret key
73+
* @param key - a 256-bit secret key.
7474
*/
7575
protected SASGenerator(byte[] key) {
7676
this.key = key;

hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/utils/ServiceSASGenerator.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@
2525

2626
/**
2727
* Test Service SAS Generator.
28-
* SAS Generated by this will have full access to specified container(filesystem)
28+
* SAS Generated by this will have full access to specified container(filesystem).
2929
*/
3030
public class ServiceSASGenerator extends SASGenerator {
3131

3232
/**
33-
* Creates a SAS Generator for Service SAS
33+
* Creates a SAS Generator for Service SAS.
3434
* (https://docs.microsoft.com/en-us/rest/api/storageservices/create-service-sas).
35-
* @param accountKey - the storage account key
35+
* @param accountKey - the storage account key.
3636
*/
3737
public ServiceSASGenerator(byte[] accountKey) {
3838
super(accountKey);
@@ -70,7 +70,7 @@ private String computeSignatureForSAS(String sp, String st, String se, String sv
7070
sb.append("\n");
7171
sb.append(se);
7272
sb.append("\n");
73-
// canonicalized resource
73+
// canonicalize resource
7474
sb.append("/blob/");
7575
sb.append(accountName);
7676
sb.append("/");

0 commit comments

Comments
 (0)