Skip to content

Commit 2fd2e07

Browse files
committed
Reorganized key and certificate tests
1 parent 553e0fb commit 2fd2e07

File tree

12 files changed

+12
-12
lines changed

12 files changed

+12
-12
lines changed

src/test/java/com/mastercard/developer/encryption/FieldLevelEncryptionWithDefaultJsonEngineTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1126,7 +1126,7 @@ public void testDecryptPayload_ShouldThrowEncryptionException_WhenDecryptionErro
11261126
.withDecryptionPath("encryptedData", "data")
11271127
.withOaepPaddingDigestAlgorithm("SHA-256")
11281128
// Not the right key
1129-
.withDecryptionKey(loadDecryptionKey("./src/test/resources/test_key.p12", "mykeyalias", "Password1"))
1129+
.withDecryptionKey(loadDecryptionKey("./src/test/resources/keys/pkcs12/test_key.p12", "mykeyalias", "Password1"))
11301130
.build();
11311131

11321132
// THEN

src/test/java/com/mastercard/developer/test/TestUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ private TestUtils() {
1919
}
2020

2121
public static Certificate getTestEncryptionCertificate() throws Exception {
22-
return loadEncryptionCertificate("./src/test/resources/test_certificate.pem");
22+
return loadEncryptionCertificate("./src/test/resources/certificates/test_certificate-2048.pem");
2323
}
2424

2525
public static Certificate getTestInvalidEncryptionCertificate() {
2626
return mock(X509Certificate.class); // Will throw "java.security.InvalidKeyException: Key must not be null"
2727
}
2828

2929
public static PrivateKey getTestDecryptionKey() throws Exception {
30-
return loadDecryptionKey("./src/test/resources/test_key_pkcs8.der");
30+
return loadDecryptionKey("./src/test/resources/keys/pkcs8/test_key_pkcs8-2048.der");
3131
}
3232

3333
public static FieldLevelEncryptionConfigBuilder getTestFieldLevelEncryptionConfigBuilder() throws Exception {

src/test/java/com/mastercard/developer/utils/EncryptionUtilsTest.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class EncryptionUtilsTest {
2424
public void testLoadEncryptionCertificate_ShouldSupportPem() throws Exception {
2525

2626
// GIVEN
27-
String certificatePath = "./src/test/resources/test_certificate.pem";
27+
String certificatePath = "./src/test/resources/certificates/test_certificate-2048.pem";
2828

2929
// WHEN
3030
Certificate certificate = EncryptionUtils.loadEncryptionCertificate(certificatePath);
@@ -38,7 +38,7 @@ public void testLoadEncryptionCertificate_ShouldSupportPem() throws Exception {
3838
public void testLoadEncryptionCertificate_ShouldSupportDer() throws Exception {
3939

4040
// GIVEN
41-
String certificatePath = "./src/test/resources/test_certificate.der";
41+
String certificatePath = "./src/test/resources/certificates/test_certificate-2048.der";
4242

4343
// WHEN
4444
Certificate certificate = EncryptionUtils.loadEncryptionCertificate(certificatePath);
@@ -52,7 +52,7 @@ public void testLoadEncryptionCertificate_ShouldSupportDer() throws Exception {
5252
public void testLoadDecryptionKey_ShouldSupportPkcs8Der() throws Exception {
5353

5454
// GIVEN
55-
String keyPath = "./src/test/resources/test_key_pkcs8.der";
55+
String keyPath = "./src/test/resources/keys/pkcs8/test_key_pkcs8-2048.der";
5656

5757
// WHEN
5858
PrivateKey privateKey = EncryptionUtils.loadDecryptionKey(keyPath);
@@ -67,7 +67,7 @@ public void testLoadDecryptionKey_ShouldSupportPkcs8Der() throws Exception {
6767
public void testLoadDecryptionKey_ShouldSupportPkcs8Base64Pem() throws Exception {
6868

6969
// GIVEN
70-
String keyPath = "./src/test/resources/test_key_pkcs8.pem";
70+
String keyPath = "./src/test/resources/keys/pkcs8/test_key_pkcs8-2048.pem";
7171

7272
// WHEN
7373
PrivateKey privateKey = EncryptionUtils.loadDecryptionKey(keyPath);
@@ -82,7 +82,7 @@ public void testLoadDecryptionKey_ShouldSupportPkcs8Base64Pem() throws Exception
8282
public void testLoadDecryptionKey_ShouldSupportPkcs1Base64Pem_Nominal() throws Exception {
8383

8484
// GIVEN
85-
String keyPath = "./src/test/resources/test_key_pkcs1.pem";
85+
String keyPath = "./src/test/resources/keys/pkcs1/test_key_pkcs1-2048.pem";
8686

8787
// WHEN
8888
PrivateKey privateKey = EncryptionUtils.loadDecryptionKey(keyPath);
@@ -97,7 +97,7 @@ public void testLoadDecryptionKey_ShouldSupportPkcs1Base64Pem_Nominal() throws E
9797
public void testLoadDecryptionKey_ShouldSupportPkcs1Base64Pem_1024bits() throws Exception {
9898

9999
// GIVEN
100-
String keyPath = "./src/test/resources/test_key_pkcs1-1024.pem";
100+
String keyPath = "./src/test/resources/keys/pkcs1/test_key_pkcs1-1024.pem";
101101

102102
// WHEN
103103
PrivateKey privateKey = EncryptionUtils.loadDecryptionKey(keyPath);
@@ -111,7 +111,7 @@ public void testLoadDecryptionKey_ShouldSupportPkcs1Base64Pem_1024bits() throws
111111
public void testLoadDecryptionKey_ShouldSupportPkcs1Base64Pem_4096bits() throws Exception {
112112

113113
// GIVEN
114-
String keyPath = "./src/test/resources/test_key_pkcs1-4096.pem";
114+
String keyPath = "./src/test/resources/keys/pkcs1/test_key_pkcs1-4096.pem";
115115

116116
// WHEN
117117
PrivateKey privateKey = EncryptionUtils.loadDecryptionKey(keyPath);
@@ -125,7 +125,7 @@ public void testLoadDecryptionKey_ShouldSupportPkcs1Base64Pem_4096bits() throws
125125
public void testLoadDecryptionKey_ShouldSupportPkcs12() throws Exception {
126126

127127
// GIVEN
128-
String keyContainerPath = "./src/test/resources/test_key.p12";
128+
String keyContainerPath = "./src/test/resources/keys/pkcs12/test_key.p12";
129129
String keyAlias = "mykeyalias";
130130
String keyPassword = "Password1";
131131

@@ -143,7 +143,7 @@ public void testLoadDecryptionKey_ShouldSupportPkcs12() throws Exception {
143143
public void testLoadDecryptionKey_ShouldThrowIllegalArgumentException_WhenInvalidKey() throws Exception {
144144

145145
// GIVEN
146-
String keyPath = "./src/test/resources/test_invalid_key.der";
146+
String keyPath = "./src/test/resources/keys/pkcs8/test_invalid_key.der";
147147

148148
// THEN
149149
expectedException.expect(IllegalArgumentException.class);
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)