Create enclave as part of setup logic and not while iterating through results
@@ -48,6 +48,8 @@ public class MigrateCommandTest {
private OrionKeyHelper orionKeyHelper;
+ private Enclave enclave;
+
public MigrateCommandTest(MigrateTestConfig migrateTestConfig) {
this.migrateTestConfig = migrateTestConfig;
}
@@ -91,6 +93,8 @@ public class MigrateCommandTest {
orionKeyHelper = OrionKeyHelper.from(adjustedOrionConfigFile);
+ enclave = createEnclave(orionKeyHelper);
+
}
@After
@@ -136,8 +140,6 @@ public class MigrateCommandTest {
byte[] payload = resultSet.getBytes(1);
EncodedPayload encodedPayload = PayloadEncoder.create().decode(payload);
- Enclave enclave = createEnclave();
-
PublicKey encryptionKey = orionKeyHelper.getKeyPairs().stream().findFirst()
.map(Box.KeyPair::publicKey)
.map(Box.PublicKey::bytesArray)
@@ -147,11 +149,9 @@ public class MigrateCommandTest {
byte[] unencryptedTransaction = enclave.unencryptTransaction(encodedPayload,encryptionKey);
assertThat(unencryptedTransaction).isEqualTo(Base64.getDecoder().decode(expected));
-
assertThat(encodedPayload.getPrivacyGroupId()).isPresent();
assertThat(encodedPayload.getPrivacyGroupId().get().encodeToBase64())
.isEqualTo(fixture.getPrivacyGroup());
-
assertThat(encodedPayload.getSenderKey().encodeToBase64())
.isEqualTo(fixture.getSender());
}
@@ -182,7 +182,7 @@ public class MigrateCommandTest {
);
}
- private Enclave createEnclave() {
+ private static Enclave createEnclave(OrionKeyHelper orionKeyHelper) {
Config tesseraConfig = new Config();
EncryptorConfig tesseraEncryptorConfig = new EncryptorConfig();
tesseraEncryptorConfig.setType(EncryptorType.NACL);
