Skip to content

Commit 09139dc

Browse files
committed
imports removed
1 parent 58fc8b3 commit 09139dc

File tree

6 files changed

+44
-28
lines changed

6 files changed

+44
-28
lines changed

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

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import java.util.List;
2929
import java.util.stream.Collectors;
3030

31-
import org.assertj.core.api.Assertions;
3231
import org.junit.jupiter.api.BeforeEach;
3332
import org.junit.jupiter.api.Test;
3433
import org.mockito.Mockito;
@@ -57,15 +56,18 @@
5756
import static org.apache.hadoop.fs.azurebfs.constants.TestConfigurationKeys.FS_AZURE_BLOB_FS_CHECKACCESS_TEST_CLIENT_SECRET;
5857
import static org.apache.hadoop.fs.azurebfs.constants.TestConfigurationKeys.FS_AZURE_BLOB_FS_CHECKACCESS_TEST_USER_GUID;
5958
import static org.apache.hadoop.fs.azurebfs.constants.TestConfigurationKeys.FS_AZURE_BLOB_FS_CLIENT_SERVICE_PRINCIPAL_OBJECT_ID;
59+
import static org.apache.hadoop.fs.azurebfs.constants.TestConfigurationKeys.FS_AZURE_TEST_APP_SERVICE_PRINCIPAL_TENANT_ID;
6060
import static org.apache.hadoop.fs.azurebfs.constants.TestConfigurationKeys.FS_AZURE_TEST_END_USER_OBJECT_ID;
61+
import static org.apache.hadoop.fs.azurebfs.constants.TestConfigurationKeys.FS_AZURE_TEST_END_USER_TENANT_ID;
6162
import static org.apache.hadoop.test.LambdaTestUtils.intercept;
6263
import static org.assertj.core.api.Assumptions.assumeThat;
6364

6465
/**
6566
* Integration tests for AzureBlobFileSystem using User-Bound SAS and OAuth.
6667
* Covers scenarios for token provider configuration, SAS token validity, and basic file operations.
6768
*/
68-
public class ITestAzureBlobFileSystemUserBoundSAS extends AbstractAbfsIntegrationTest {
69+
public class ITestAzureBlobFileSystemUserBoundSAS
70+
extends AbstractAbfsIntegrationTest {
6971

7072
private static Path testPath = new Path("/test.txt");
7173

@@ -115,6 +117,8 @@ public void setup() throws Exception {
115117
abfsConfig.get(FS_AZURE_BLOB_FS_CHECKACCESS_TEST_CLIENT_SECRET));
116118
abfsConfig.set(FS_AZURE_ACCOUNT_OAUTH_CLIENT_SECRET,
117119
abfsConfig.get(FS_AZURE_BLOB_FS_CHECKACCESS_TEST_CLIENT_SECRET));
120+
abfsConfig.set(FS_AZURE_TEST_END_USER_TENANT_ID,
121+
abfsConfig.get(FS_AZURE_TEST_APP_SERVICE_PRINCIPAL_TENANT_ID));
118122
abfsConfig.set(FS_AZURE_TEST_END_USER_OBJECT_ID,
119123
abfsConfig.get(FS_AZURE_BLOB_FS_CHECKACCESS_TEST_USER_GUID));
120124
abfsConfig.set(FS_AZURE_SAS_TOKEN_PROVIDER_TYPE,
@@ -154,7 +158,8 @@ private void injectMockTokenProvider(AzureBlobFileSystem fs,
154158
*/
155159
private AzureBlobFileSystem createTestFileSystem() throws RuntimeException {
156160
try {
157-
return (AzureBlobFileSystem) FileSystem.newInstance(getRawConfiguration());
161+
return (AzureBlobFileSystem) FileSystem.newInstance(
162+
getRawConfiguration());
158163
} catch (IOException e) {
159164
throw new RuntimeException(e);
160165
}
@@ -167,7 +172,8 @@ private AzureBlobFileSystem createTestFileSystem() throws RuntimeException {
167172
@Test
168173
public void testShouldFailWhenSduoidMismatchesServicePrincipalId()
169174
throws Exception {
170-
this.getConfiguration().set(FS_AZURE_TEST_END_USER_OBJECT_ID, TEST_OBJECT_ID);
175+
this.getConfiguration()
176+
.set(FS_AZURE_TEST_END_USER_OBJECT_ID, TEST_OBJECT_ID);
171177
AzureBlobFileSystem testFs = createTestFileSystem();
172178
intercept(AccessDeniedException.class,
173179
() -> {
@@ -201,7 +207,8 @@ public void testOAuthTokenProviderAndSASTokenFlow() throws Exception {
201207

202208
// Verify AbfsConfiguration has an SASTokenProvider configured
203209
SASTokenProvider sasProvider
204-
= abfsConfiguration.getUserBoundSASTokenProvider(AuthType.UserboundSASWithOAuth);
210+
= abfsConfiguration.getUserBoundSASTokenProvider(
211+
AuthType.UserboundSASWithOAuth);
205212
assertNotNull(sasProvider,
206213
"SASTokenProvider for user-bound SAS must be configured");
207214
assertInstanceOf(MockUserBoundSASTokenProvider.class, sasProvider,
@@ -216,7 +223,7 @@ public void testOAuthTokenProviderAndSASTokenFlow() throws Exception {
216223
}
217224

218225
/*
219-
* Tests listing and deleting files under an implicit directory
226+
* Tests listing and deleting files under an implicit directory
220227
*/
221228
@Test
222229
public void testOperationsForImplicitPaths() throws Exception {
@@ -245,7 +252,8 @@ public void testOperationsForImplicitPaths() throws Exception {
245252
listOp.getResult().getListResultSchema().paths();
246253

247254
assertNotNull(listedEntries, "List result should not be null");
248-
assertEquals(2, listedEntries.size(), "Expected exactly two files under implicit directory");
255+
assertEquals(2, listedEntries.size(),
256+
"Expected exactly two files under implicit directory");
249257

250258
client.deletePath(
251259
implicitDir.toString(),
@@ -346,7 +354,8 @@ public void testOperationWithValidAndExpiredSASToken() throws Exception {
346354
// Get a real SAS token from the configured provider
347355
AbfsConfiguration abfsConfig = testFs.getAbfsStore().getAbfsConfiguration();
348356
SASTokenProvider realSasProvider
349-
= abfsConfig.getUserBoundSASTokenProvider(AuthType.UserboundSASWithOAuth);
357+
= abfsConfig.getUserBoundSASTokenProvider(
358+
AuthType.UserboundSASWithOAuth);
350359
assertNotNull(realSasProvider,
351360
"SASTokenProvider for user-bound SAS must be configured");
352361
String validSasToken = realSasProvider.getSASToken(
@@ -388,20 +397,26 @@ public void testOperationWithValidAndExpiredSASToken() throws Exception {
388397
injectMockSASTokenProvider(testFs, mockSasProvider);
389398

390399
// Try a file operation and expect failure due to expired SAS token
391-
intercept(AccessDeniedException.class, () -> {testFs.getFileStatus(testPath);});
400+
intercept(AccessDeniedException.class,
401+
() -> {testFs.getFileStatus(testPath);});
392402
}
393403

394404
// Helper method to inject a mock SASTokenProvider into the AbfsClient
395-
private void injectMockSASTokenProvider(AzureBlobFileSystem fs, SASTokenProvider provider) throws Exception {
396-
Field abfsStoreField = AzureBlobFileSystem.class.getDeclaredField("abfsStore");
405+
private void injectMockSASTokenProvider(AzureBlobFileSystem fs,
406+
SASTokenProvider provider) throws Exception {
407+
Field abfsStoreField = AzureBlobFileSystem.class.getDeclaredField(
408+
"abfsStore");
397409
abfsStoreField.setAccessible(true);
398-
AzureBlobFileSystemStore store = (AzureBlobFileSystemStore) abfsStoreField.get(fs);
410+
AzureBlobFileSystemStore store
411+
= (AzureBlobFileSystemStore) abfsStoreField.get(fs);
399412

400-
Field abfsClientField = AzureBlobFileSystemStore.class.getDeclaredField("client");
413+
Field abfsClientField = AzureBlobFileSystemStore.class.getDeclaredField(
414+
"client");
401415
abfsClientField.setAccessible(true);
402416
AbfsClient client = (AbfsClient) abfsClientField.get(store);
403417

404-
Field sasProviderField = AbfsClient.class.getDeclaredField("sasTokenProvider");
418+
Field sasProviderField = AbfsClient.class.getDeclaredField(
419+
"sasTokenProvider");
405420
sasProviderField.setAccessible(true);
406421
sasProviderField.set(client, provider);
407422
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
import org.apache.hadoop.fs.azurebfs.services.AbfsHttpHeader;
3737
import org.apache.hadoop.fs.azurebfs.services.AbfsJdkHttpOperation;
3838
import org.apache.hadoop.fs.azurebfs.utils.Base64;
39-
import org.apache.hadoop.fs.azurebfs.utils.DelegationSASGenerator_Version_July5;
39+
import org.apache.hadoop.fs.azurebfs.utils.DelegationSASGeneratorVersionJuly5;
4040
import org.apache.hadoop.fs.azurebfs.utils.SASGenerator;
4141
import org.apache.hadoop.security.AccessControlException;
4242

@@ -49,7 +49,7 @@
4949
*/
5050
public class MockDelegationSASTokenProvider implements SASTokenProvider {
5151

52-
private DelegationSASGenerator_Version_July5 generator;
52+
private DelegationSASGeneratorVersionJuly5 generator;
5353

5454
public static final String TEST_OWNER = "325f1619-4205-432f-9fce-3fd594325ce5";
5555
public static final String CORRELATION_ID = "66ff4ffc-ff17-417e-a2a9-45db8c5b0b5c";
@@ -66,7 +66,7 @@ public void initialize(Configuration configuration, String accountName) throws I
6666
String skv = SASGenerator.AuthenticationVersion.Dec19.toString();
6767

6868
byte[] key = getUserDelegationKey(accountName, appID, appSecret, sktid, skt, ske, skv);
69-
generator = new DelegationSASGenerator_Version_July5(key, skoid, sktid, skt, ske, skv, EMPTY_STRING, EMPTY_STRING);
69+
generator = new DelegationSASGeneratorVersionJuly5(key, skoid, sktid, skt, ske, skv, EMPTY_STRING, EMPTY_STRING);
7070
}
7171

7272
// Invokes the AAD v2.0 authentication endpoint with a client credentials grant to get an

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,8 @@
1818

1919
package org.apache.hadoop.fs.azurebfs.extensions;
2020

21-
import java.io.IOException;
22-
2321
import org.apache.hadoop.conf.Configuration;
2422

25-
import static org.apache.hadoop.fs.azurebfs.constants.TestConfigurationKeys.MOCK_SASTOKENPROVIDER_FAIL_INIT;
26-
import static org.apache.hadoop.fs.azurebfs.constants.TestConfigurationKeys.MOCK_SASTOKENPROVIDER_RETURN_EMPTY_SAS_TOKEN;
27-
2823
/**
2924
* A mock SAS token provider to test error conditions.
3025
*/

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
import org.apache.hadoop.fs.azurebfs.services.AbfsHttpHeader;
3737
import org.apache.hadoop.fs.azurebfs.services.AbfsJdkHttpOperation;
3838
import org.apache.hadoop.fs.azurebfs.utils.Base64;
39-
import org.apache.hadoop.fs.azurebfs.utils.DelegationSASGenerator_Version_July5;
39+
import org.apache.hadoop.fs.azurebfs.utils.DelegationSASGeneratorVersionJuly5;
4040
import org.apache.hadoop.fs.azurebfs.utils.SASGenerator;
4141
import org.apache.hadoop.security.AccessControlException;
4242

@@ -65,7 +65,7 @@ public class MockUserBoundSASTokenProvider implements SASTokenProvider {
6565
public static final String CORRELATION_ID = "66ff4ffc-ff17-417e-a2a9-45db8c5b0b5c";
6666
public static final String NO_AGENT_PATH = "NoAgentPath";
6767

68-
private DelegationSASGenerator_Version_July5 generator;
68+
private DelegationSASGeneratorVersionJuly5 generator;
6969

7070
/**
7171
* Initializes the SAS token provider with configuration settings.
@@ -89,7 +89,7 @@ public void initialize(Configuration configuration, String accountName) throws I
8989

9090
byte[] key = getUserDelegationKey(accountName, appID, appSecret, sktid, skt, ske, skv, skdutid);
9191

92-
generator = new DelegationSASGenerator_Version_July5(key, skoid, sktid, skt, ske, skv, skdutid, sduoid);
92+
generator = new DelegationSASGeneratorVersionJuly5(key, skoid, sktid, skt, ske, skv, skdutid, sduoid);
9393
}
9494

9595
/**

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@
8484
import static org.apache.hadoop.fs.azurebfs.constants.TestConfigurationKeys.FS_AZURE_ABFS_ACCOUNT_NAME;
8585
import static org.apache.hadoop.fs.azurebfs.constants.HttpOperationType.APACHE_HTTP_CLIENT;
8686
import static org.apache.hadoop.fs.azurebfs.constants.HttpOperationType.JDK_HTTP_URL_CONNECTION;
87-
import static org.apache.hadoop.fs.azurebfs.constants.TestConfigurationKeys.FS_AZURE_TEST_END_USER_OBJECT_ID;
8887
import static org.apache.hadoop.test.LambdaTestUtils.intercept;
8988
import static org.mockito.ArgumentMatchers.any;
9089
import static org.mockito.ArgumentMatchers.eq;
Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
/**
3232
* Test Delegation SAS generator.
3333
*/
34-
public class DelegationSASGenerator_Version_July5 extends SASGenerator {
34+
public class DelegationSASGeneratorVersionJuly5 extends SASGenerator {
3535
private final String skoid;
3636
private final String sktid;
3737
private final String skt;
@@ -53,7 +53,14 @@ public class DelegationSASGenerator_Version_July5 extends SASGenerator {
5353
* @param skdutid Azure AD delegated app's tenant ID
5454
* @param sduoid Azure AD delegated app's user object ID
5555
*/
56-
public DelegationSASGenerator_Version_July5(byte[] userDelegationKey, String skoid, String sktid, String skt, String ske, String skv, String skdutid, String sduoid) {
56+
public DelegationSASGeneratorVersionJuly5(byte[] userDelegationKey,
57+
String skoid,
58+
String sktid,
59+
String skt,
60+
String ske,
61+
String skv,
62+
String skdutid,
63+
String sduoid) {
5764
super(userDelegationKey);
5865
this.skoid = skoid;
5966
this.sktid = sktid;

0 commit comments

Comments
 (0)