-
Notifications
You must be signed in to change notification settings - Fork 9.2k
HADOOP-19137. [ABFS] Prevent ABFS initialization for non-hierarchal-namespace account if Customer-provided-key configs given. #6752
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 14 commits
d186091
2d3a5dd
f712d0d
fa6be2b
794685c
1536675
d3cb3a1
9290858
60853e0
54b9698
5d09597
255b62d
d4cdd7e
3c8b712
c7e4358
c0dc108
39e8c5d
18eed9e
cd1d52f
5c9a103
0e2bceb
5309829
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -165,5 +165,8 @@ public static ApiVersion getCurrentVersion() { | |
| */ | ||
| public static final Integer HTTP_STATUS_CATEGORY_QUOTIENT = 100; | ||
|
|
||
| public static final String FS_INIT_FAILED_CPK_CONFIG_IN_NON_HNS_ACCOUNT = | ||
|
||
| "Non HNS account can not have CPK configs enabled."; | ||
|
||
|
|
||
| private AbfsHttpConstants() {} | ||
| } | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,7 +35,7 @@ | |
| import org.apache.hadoop.fs.azurebfs.services.AbfsClientUtils; | ||
| import org.apache.hadoop.fs.azurebfs.utils.TracingContext; | ||
| import org.assertj.core.api.Assertions; | ||
| import org.junit.Assume; | ||
| import org.assertj.core.api.Assumptions; | ||
| import org.junit.Test; | ||
| import org.junit.runner.RunWith; | ||
| import org.junit.runners.Parameterized; | ||
|
|
@@ -60,6 +60,7 @@ | |
| import org.apache.hadoop.test.LambdaTestUtils; | ||
| import org.apache.hadoop.util.Lists; | ||
|
|
||
| import static org.apache.hadoop.fs.azurebfs.constants.AbfsHttpConstants.FS_INIT_FAILED_CPK_CONFIG_IN_NON_HNS_ACCOUNT; | ||
| import static org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys.FS_AZURE_ENCRYPTION_CONTEXT_PROVIDER_TYPE; | ||
| import static org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys.FS_AZURE_ENCRYPTION_ENCODED_CLIENT_PROVIDED_KEY; | ||
| import static org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys.FS_AZURE_ENCRYPTION_ENCODED_CLIENT_PROVIDED_KEY_SHA; | ||
|
|
@@ -171,9 +172,6 @@ public static Iterable<Object[]> params() { | |
| } | ||
|
|
||
| public ITestAbfsCustomEncryption() throws Exception { | ||
| Assume.assumeTrue("Account should be HNS enabled for CPK", | ||
| getConfiguration().getBoolean(FS_AZURE_TEST_NAMESPACE_ENABLED_ACCOUNT, | ||
| false)); | ||
| new Random().nextBytes(cpk); | ||
| cpkSHAEncoded = EncodingHelper.getBase64EncodedString( | ||
| EncodingHelper.getSHA256Hash(cpk)); | ||
|
|
@@ -184,8 +182,8 @@ public void testCustomEncryptionCombinations() throws Exception { | |
| AzureBlobFileSystem fs = getOrCreateFS(); | ||
| Path testPath = path("/testFile"); | ||
| String relativePath = fs.getAbfsStore().getRelativePath(testPath); | ||
| MockEncryptionContextProvider ecp = | ||
| (MockEncryptionContextProvider) createEncryptedFile(testPath); | ||
| MockEncryptionContextProvider ecp | ||
|
||
| = (MockEncryptionContextProvider) createEncryptedFile(testPath); | ||
| AbfsRestOperation op = callOperation(fs, new Path(relativePath), ecp); | ||
| if (op == null) { | ||
| return; | ||
|
|
@@ -375,9 +373,7 @@ private AzureBlobFileSystem getECProviderEnabledFS() throws Exception { | |
| + getAccountName()); | ||
| configuration.unset(FS_AZURE_ENCRYPTION_ENCODED_CLIENT_PROVIDED_KEY_SHA + "." | ||
| + getAccountName()); | ||
| AzureBlobFileSystem fs = (AzureBlobFileSystem) FileSystem.newInstance(configuration); | ||
| fileSystemsOpenedInTest.add(fs); | ||
| return fs; | ||
| return getAzureBlobFileSystem(configuration); | ||
| } | ||
|
|
||
| private AzureBlobFileSystem getCPKEnabledFS() throws IOException { | ||
|
|
@@ -390,9 +386,34 @@ private AzureBlobFileSystem getCPKEnabledFS() throws IOException { | |
| conf.set(FS_AZURE_ENCRYPTION_ENCODED_CLIENT_PROVIDED_KEY_SHA + "." | ||
| + getAccountName(), cpkEncodedSHA); | ||
| conf.unset(FS_AZURE_ENCRYPTION_CONTEXT_PROVIDER_TYPE); | ||
| AzureBlobFileSystem fs = (AzureBlobFileSystem) FileSystem.newInstance(conf); | ||
| fileSystemsOpenedInTest.add(fs); | ||
| return fs; | ||
| return getAzureBlobFileSystem(conf); | ||
| } | ||
|
|
||
| private AzureBlobFileSystem getAzureBlobFileSystem(final Configuration conf) { | ||
| try { | ||
| AzureBlobFileSystem fs = (AzureBlobFileSystem) FileSystem.newInstance( | ||
steveloughran marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| conf); | ||
| fileSystemsOpenedInTest.add(fs); | ||
| Assertions.assertThat( | ||
| getConfiguration().getBoolean(FS_AZURE_TEST_NAMESPACE_ENABLED_ACCOUNT, | ||
| false)) | ||
| .describedAs("Encryption tests should run only on namespace enabled account") | ||
| .isTrue(); | ||
| return fs; | ||
| } catch (IOException ex) { | ||
| Assertions.assertThat(ex.getMessage()) | ||
|
||
| .describedAs("Exception message should contain the expected message") | ||
| .contains(FS_INIT_FAILED_CPK_CONFIG_IN_NON_HNS_ACCOUNT); | ||
| Assertions.assertThat( | ||
| getConfiguration().getBoolean(FS_AZURE_TEST_NAMESPACE_ENABLED_ACCOUNT, | ||
| false)) | ||
| .describedAs("Encryption tests should run only on namespace enabled account") | ||
| .isFalse(); | ||
|
|
||
| //Skip the test | ||
| Assumptions.assumeThat(true).isFalse(); | ||
| return null; | ||
| } | ||
| } | ||
|
|
||
| private AzureBlobFileSystem getOrCreateFS() throws Exception { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.