Skip to content

Commit

Permalink
passing yetus checks
Browse files Browse the repository at this point in the history
  • Loading branch information
manika137 committed Mar 4, 2025
1 parent 8c4413e commit 4a182ac
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ public class AbfsConfiguration{
* Constructor for AbfsConfiguration for specified service type.
* @param rawConfig used to initialize the configuration.
* @param accountName the name of the azure storage account.
* @param fsName the name of the file system (container name).
* @param fsConfiguredServiceType service type configured for the file system.
* @throws IllegalAccessException if the field is not accessible.
* @throws IOException if an I/O error occurs.
Expand Down Expand Up @@ -666,7 +667,7 @@ public int getInt(String key, int defaultValue) {
*/
public String getPasswordString(String key) throws IOException {
char[] passchars = rawConfig.getPassword(containerConf(key));
if (passchars == null) {
if(passchars == null) {
passchars = rawConfig.getPassword(accountConf(key));
if(passchars == null){
passchars = rawConfig.getPassword(key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,8 @@ public static String accountProperty(String property, String account) {
return property + "." + account;
}

public static String containerProperty(String property, String FsName, String account) {
return property + "." + FsName + "." + account;
public static String containerProperty(String property, String fsName, String account) {
return property + "." + fsName + "." + account;
}

public static final String FS_AZURE_ENABLE_DELEGATION_TOKEN = "fs.azure.enable.delegation.token";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,13 @@ public void testBothProviderFixedTokenConfigured() throws Exception {
}
}

/**
* Helper method to get the Fixed SAS token value
*/
private String getFixedSASToken(AbfsConfiguration config) throws Exception {
return config.getSASTokenProvider().getSASToken(this.getAccountName(), this.getFileSystemName(), getMethodName(), "read");
}

/**
* Tests the implementation sequence if all fixed SAS configs are set.
* The expected sequence is Container Specific Fixed SAS, Account Specific Fixed SAS, Account Agnostic Fixed SAS.
Expand All @@ -161,21 +168,18 @@ public void testFixedTokenPreference() throws Exception {
testAbfsConfig.set(containerProperty(FS_AZURE_SAS_FIXED_TOKEN, this.getFileSystemName(), this.getAccountName()), containerSAS);
testAbfsConfig.set(accountProperty(FS_AZURE_SAS_FIXED_TOKEN, this.getAccountName()), accountSAS);
testAbfsConfig.set(FS_AZURE_SAS_FIXED_TOKEN, accountSAS);
String ContainerSASExpected = testAbfsConfig.getSASTokenProvider().getSASToken(this.getAccountName(), this.getFileSystemName(), getMethodName(), "read");

// Assert that Container Specific Fixed SAS is used
Assertions.assertThat(ContainerSASExpected).contains("sr=c");
Assertions.assertThat(getFixedSASToken(testAbfsConfig)).contains("sr=c");

// Assert that Account Specific Fixed SAS is used if container SAS isn't set
testAbfsConfig.unset(containerProperty(FS_AZURE_SAS_FIXED_TOKEN, this.getFileSystemName(), this.getAccountName()));
String AccountSASExpected = testAbfsConfig.getSASTokenProvider().getSASToken(this.getAccountName(), this.getFileSystemName(), getMethodName(), "read");
Assertions.assertThat(AccountSASExpected).contains("ss=bf");
Assertions.assertThat(getFixedSASToken(testAbfsConfig)).contains("ss=bf");

//Assert that Account-Agnostic fixed SAS is used if no other fixed SAS configs are set.
// The token is the same as the Account Specific Fixed SAS.
testAbfsConfig.unset(FS_AZURE_SAS_FIXED_TOKEN);
String AccountAgnosticSASExpected = testAbfsConfig.getSASTokenProvider().getSASToken(this.getAccountName(), this.getFileSystemName(), getMethodName(), "read");
Assertions.assertThat(AccountAgnosticSASExpected).contains("ss=bf");
testAbfsConfig.unset(accountProperty(FS_AZURE_SAS_FIXED_TOKEN, this.getAccountName()));
Assertions.assertThat(getFixedSASToken(testAbfsConfig)).contains("ss=bf");
}

/**
Expand Down

0 comments on commit 4a182ac

Please sign in to comment.