-
Notifications
You must be signed in to change notification settings - Fork 0
chore: add ranged get tests #84
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 all commits
53a2865
1e5b2ea
e0e7ab3
5dbb019
ddfdb9b
009d1b2
e12fa7d
db6c65d
a570537
39fc548
c755778
d72d851
0dc303f
88c2bc5
edd534e
12614dc
76387f0
d0457ad
ec3dabf
131d905
ebdaa64
9acf8ad
398fc4e
cd342a1
a8a025b
2b1b810
e0ee483
87b3bb1
4ccaab4
ff8e92b
2d477a6
3769f83
d290f89
b7bf864
402acb3
8370d08
1c63c14
a58ef9a
f85bf2e
09d339d
75d0c2f
375ff21
45a657e
e9f96a8
c159f9f
ba2414e
f0d5d12
630ff58
5767928
40d9fa0
180081b
6ceab31
58634c7
434520c
e174930
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 |
|---|---|---|
|
|
@@ -5,48 +5,24 @@ | |
|
|
||
| package software.amazon.encryption.s3; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| import static org.junit.jupiter.api.Assertions.assertTrue; | ||
| import static org.junit.jupiter.api.Assertions.fail; | ||
| import static software.amazon.encryption.s3.TestUtils.*; | ||
| import static software.amazon.encryption.s3.TestUtils.appendTestSuffix; | ||
|
|
||
| import java.lang.annotation.ElementType; | ||
| import java.nio.ByteBuffer; | ||
| import java.nio.charset.StandardCharsets; | ||
| import java.util.ArrayList; | ||
| import java.util.HashMap; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.stream.Stream; | ||
|
|
||
| import com.amazonaws.services.s3.model.KMSEncryptionMaterials; | ||
| import org.junit.jupiter.api.BeforeAll; | ||
| import org.junit.jupiter.params.ParameterizedTest; | ||
| import org.junit.jupiter.params.provider.Arguments; | ||
| import org.junit.jupiter.params.provider.MethodSource; | ||
| import org.junit.jupiter.api.TestMethodOrder; | ||
| import org.junit.jupiter.api.MethodOrderer; | ||
| import org.junit.jupiter.api.Order; | ||
| import org.junit.jupiter.api.TestMethodOrder; | ||
| import org.junit.jupiter.params.ParameterizedTest; | ||
| import org.junit.jupiter.params.provider.MethodSource; | ||
|
|
||
| import software.amazon.encryption.s3.client.S3ECTestServerClient; | ||
| import software.amazon.encryption.s3.model.CommitmentPolicy; | ||
| import software.amazon.encryption.s3.model.CreateClientInput; | ||
| import software.amazon.encryption.s3.model.CreateClientOutput; | ||
| import software.amazon.encryption.s3.model.EncryptionAlgorithm; | ||
| import software.amazon.encryption.s3.model.GetObjectInput; | ||
| import software.amazon.encryption.s3.model.GetObjectOutput; | ||
| import software.amazon.encryption.s3.model.KeyMaterial; | ||
| import software.amazon.encryption.s3.model.PutObjectInput; | ||
| import software.amazon.encryption.s3.model.S3ECConfig; | ||
| import software.amazon.encryption.s3.model.S3EncryptionClientError; | ||
|
|
||
| import com.amazonaws.services.s3.AmazonS3Encryption; | ||
| import com.amazonaws.services.s3.AmazonS3EncryptionClient; | ||
| import com.amazonaws.services.s3.model.CryptoConfiguration; | ||
| import com.amazonaws.services.s3.model.CryptoMode; | ||
| import com.amazonaws.services.s3.model.CryptoStorageMode; | ||
| import software.amazon.encryption.s3.TestUtils.*; | ||
| import com.amazonaws.services.s3.model.EncryptionMaterialsProvider; | ||
| import com.amazonaws.services.s3.model.KMSEncryptionMaterialsProvider; | ||
|
|
||
| /** | ||
| * Exhaustive tests for S3 Encryption Client round-trip operations. | ||
|
|
@@ -159,6 +135,7 @@ void transition_configured_with_forbid_encrypt_allow_decrypt_should_decrypt_gcm( | |
| .config(S3ECConfig.builder() | ||
| .keyMaterial(kmsKeyArn) | ||
| .commitmentPolicy(CommitmentPolicy.FORBID_ENCRYPT_ALLOW_DECRYPT) | ||
| .encryptionAlgorithm(EncryptionAlgorithm.ALG_AES_256_GCM_IV12_TAG16_NO_KDF) | ||
| .build()) | ||
| .build()); | ||
| String S3ECId = clientOutput.getClientId(); | ||
|
|
@@ -199,5 +176,94 @@ void improved_configured_with_require_encrypt_require_decrypt_should_fail_to_dec | |
|
|
||
| TestUtils.Decrypt_fails(client, S3ECId, crossLanguageObjects, EncryptionAlgorithm.ALG_AES_256_GCM_IV12_TAG16_NO_KDF); | ||
| } | ||
|
|
||
| // Ranged Get Tests - using existing GCM encrypted objects with ranged-get-supported clients | ||
|
|
||
| @Order(21) | ||
| @ParameterizedTest(name = "{0}: Transition configured with the default can ranged get GCM") | ||
| @MethodSource("software.amazon.encryption.s3.TestUtils#rangedGetTransitionClientsForTest") | ||
| void transition_configured_with_the_default_can_ranged_get_gcm(TestUtils.LanguageServerTarget language) { | ||
| S3ECTestServerClient client = TestUtils.testServerClientFor(language); | ||
| CreateClientOutput clientOutput = client.createClient(CreateClientInput.builder() | ||
| .config(S3ECConfig.builder() | ||
| .keyMaterial(kmsKeyArn) | ||
| .enableLegacyUnauthenticatedModes(true) | ||
| // .commitmentPolicy(CommitmentPolicy.FORBID_ENCRYPT_ALLOW_DECRYPT) | ||
| .build()) | ||
| .build()); | ||
| String S3ECId = clientOutput.getClientId(); | ||
|
|
||
| TestUtils.DecryptWithRangedGet(client, S3ECId, crossLanguageObjects, EncryptionAlgorithm.ALG_AES_256_GCM_IV12_TAG16_NO_KDF); | ||
| } | ||
|
|
||
| @Order(22) | ||
| @ParameterizedTest(name = "{0}: Transition configured with ForbidEncryptAllowDecrypt can ranged get GCM") | ||
| @MethodSource("software.amazon.encryption.s3.TestUtils#rangedGetTransitionClientsForTest") | ||
| void transition_configured_with_forbid_encrypt_allow_decrypt_can_ranged_get_gcm(TestUtils.LanguageServerTarget language) { | ||
| S3ECTestServerClient client = TestUtils.testServerClientFor(language); | ||
| CreateClientOutput clientOutput = client.createClient(CreateClientInput.builder() | ||
| .config(S3ECConfig.builder() | ||
| .keyMaterial(kmsKeyArn) | ||
| .commitmentPolicy(CommitmentPolicy.FORBID_ENCRYPT_ALLOW_DECRYPT) | ||
| .encryptionAlgorithm(EncryptionAlgorithm.ALG_AES_256_GCM_IV12_TAG16_NO_KDF) | ||
| .enableLegacyUnauthenticatedModes(true) | ||
| .build()) | ||
| .build()); | ||
| String S3ECId = clientOutput.getClientId(); | ||
|
|
||
| TestUtils.DecryptWithRangedGet(client, S3ECId, crossLanguageObjects, EncryptionAlgorithm.ALG_AES_256_GCM_IV12_TAG16_NO_KDF); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How do this work on languages that don't support RangeGets? I don't see any logic here to skip this test. I might be also missing something
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I found it in testutils, its with
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes |
||
| } | ||
|
|
||
| @Order(23) | ||
| @ParameterizedTest(name = "{0}: Improved configured with ForbidEncryptAllowDecrypt can ranged get GCM") | ||
| @MethodSource("software.amazon.encryption.s3.TestUtils#rangedGetImprovedClientsForTest") | ||
| void improved_configured_with_forbid_encrypt_allow_decrypt_can_ranged_get_gcm(TestUtils.LanguageServerTarget language) { | ||
| S3ECTestServerClient client = TestUtils.testServerClientFor(language); | ||
| CreateClientOutput clientOutput = client.createClient(CreateClientInput.builder() | ||
| .config(S3ECConfig.builder() | ||
| .keyMaterial(kmsKeyArn) | ||
| .commitmentPolicy(CommitmentPolicy.FORBID_ENCRYPT_ALLOW_DECRYPT) | ||
| .encryptionAlgorithm(EncryptionAlgorithm.ALG_AES_256_GCM_IV12_TAG16_NO_KDF) | ||
| .enableLegacyUnauthenticatedModes(true) | ||
| .build()) | ||
| .build()); | ||
| String S3ECId = clientOutput.getClientId(); | ||
|
|
||
| TestUtils.DecryptWithRangedGet(client, S3ECId, crossLanguageObjects, EncryptionAlgorithm.ALG_AES_256_GCM_IV12_TAG16_NO_KDF); | ||
| } | ||
|
|
||
| @Order(24) | ||
| @ParameterizedTest(name = "{0}: Improved configured with RequireEncryptAllowDecrypt can ranged get GCM") | ||
| @MethodSource("software.amazon.encryption.s3.TestUtils#rangedGetImprovedClientsForTest") | ||
| void improved_configured_with_require_encrypt_allow_decrypt_can_ranged_get_gcm(TestUtils.LanguageServerTarget language) { | ||
| S3ECTestServerClient client = TestUtils.testServerClientFor(language); | ||
| CreateClientOutput clientOutput = client.createClient(CreateClientInput.builder() | ||
| .config(S3ECConfig.builder() | ||
| .keyMaterial(kmsKeyArn) | ||
| .commitmentPolicy(CommitmentPolicy.REQUIRE_ENCRYPT_ALLOW_DECRYPT) | ||
| .enableLegacyUnauthenticatedModes(true) | ||
| .build()) | ||
| .build()); | ||
| String S3ECId = clientOutput.getClientId(); | ||
|
|
||
| TestUtils.DecryptWithRangedGet(client, S3ECId, crossLanguageObjects, EncryptionAlgorithm.ALG_AES_256_GCM_IV12_TAG16_NO_KDF); | ||
| } | ||
|
|
||
| @Order(25) | ||
| @ParameterizedTest(name = "{0}: Improved configured with RequireEncryptRequireDecrypt should fail to ranged get GCM") | ||
| @MethodSource("software.amazon.encryption.s3.TestUtils#rangedGetImprovedClientsForTest") | ||
| void improved_configured_with_require_encrypt_require_decrypt_should_fail_to_ranged_get_gcm(TestUtils.LanguageServerTarget language) { | ||
| S3ECTestServerClient client = TestUtils.testServerClientFor(language); | ||
| CreateClientOutput clientOutput = client.createClient(CreateClientInput.builder() | ||
| .config(S3ECConfig.builder() | ||
| .keyMaterial(kmsKeyArn) | ||
| .commitmentPolicy(CommitmentPolicy.REQUIRE_ENCRYPT_REQUIRE_DECRYPT) | ||
| .enableLegacyUnauthenticatedModes(true) | ||
| .build()) | ||
| .build()); | ||
| String S3ECId = clientOutput.getClientId(); | ||
|
|
||
| TestUtils.DecryptWithRangedGet_fails(client, S3ECId, crossLanguageObjects, EncryptionAlgorithm.ALG_AES_256_GCM_IV12_TAG16_NO_KDF); | ||
| } | ||
|
|
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we could had formatted it better.