Use the default `SecureRandom` algorithm for tests
This commit is contained in:
parent
5bd08800bb
commit
9734433f00
|
@ -20,7 +20,6 @@ import com.github.tomakehurst.wiremock.junit5.WireMockExtension;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import io.dropwizard.auth.PolymorphicAuthValueFactoryProvider;
|
import io.dropwizard.auth.PolymorphicAuthValueFactoryProvider;
|
||||||
import io.dropwizard.testing.junit5.ResourceExtension;
|
import io.dropwizard.testing.junit5.ResourceExtension;
|
||||||
import java.security.NoSuchAlgorithmException;
|
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
import java.time.Clock;
|
import java.time.Clock;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
@ -69,14 +68,8 @@ class DonationControllerTest {
|
||||||
static WireMockExtension wm = WireMockExtension.newInstance()
|
static WireMockExtension wm = WireMockExtension.newInstance()
|
||||||
.options(wireMockConfig().dynamicPort().dynamicHttpsPort())
|
.options(wireMockConfig().dynamicPort().dynamicHttpsPort())
|
||||||
.build();
|
.build();
|
||||||
static SecureRandom secureRandom;
|
|
||||||
static {
|
private static final SecureRandom SECURE_RANDOM = new SecureRandom();
|
||||||
try {
|
|
||||||
secureRandom = SecureRandom.getInstanceStrong();
|
|
||||||
} catch (NoSuchAlgorithmException e) {
|
|
||||||
throw new AssertionError(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static DonationConfiguration getDonationConfiguration() {
|
static DonationConfiguration getDonationConfiguration() {
|
||||||
DonationConfiguration configuration = new DonationConfiguration();
|
DonationConfiguration configuration = new DonationConfiguration();
|
||||||
|
@ -119,10 +112,10 @@ class DonationControllerTest {
|
||||||
accountsManager = mock(AccountsManager.class);
|
accountsManager = mock(AccountsManager.class);
|
||||||
AccountsHelper.setupMockUpdate(accountsManager);
|
AccountsHelper.setupMockUpdate(accountsManager);
|
||||||
receiptSerialBytes = new byte[ReceiptSerial.SIZE];
|
receiptSerialBytes = new byte[ReceiptSerial.SIZE];
|
||||||
secureRandom.nextBytes(receiptSerialBytes);
|
SECURE_RANDOM.nextBytes(receiptSerialBytes);
|
||||||
receiptSerial = new ReceiptSerial(receiptSerialBytes);
|
receiptSerial = new ReceiptSerial(receiptSerialBytes);
|
||||||
presentation = new byte[ReceiptCredentialPresentation.SIZE];
|
presentation = new byte[ReceiptCredentialPresentation.SIZE];
|
||||||
secureRandom.nextBytes(presentation);
|
SECURE_RANDOM.nextBytes(presentation);
|
||||||
receiptCredentialPresentationFactory = mock(DonationController.ReceiptCredentialPresentationFactory.class);
|
receiptCredentialPresentationFactory = mock(DonationController.ReceiptCredentialPresentationFactory.class);
|
||||||
receiptCredentialPresentation = mock(ReceiptCredentialPresentation.class);
|
receiptCredentialPresentation = mock(ReceiptCredentialPresentation.class);
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import java.security.NoSuchAlgorithmException;
|
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
import java.time.Clock;
|
import java.time.Clock;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
@ -31,14 +30,7 @@ class RedeemedReceiptsManagerTest {
|
||||||
|
|
||||||
private static final long NOW_EPOCH_SECONDS = 1_500_000_000L;
|
private static final long NOW_EPOCH_SECONDS = 1_500_000_000L;
|
||||||
private static final String REDEEMED_RECEIPTS_TABLE_NAME = "redeemed_receipts";
|
private static final String REDEEMED_RECEIPTS_TABLE_NAME = "redeemed_receipts";
|
||||||
private static final SecureRandom SECURE_RANDOM;
|
private static final SecureRandom SECURE_RANDOM = new SecureRandom();
|
||||||
static {
|
|
||||||
try {
|
|
||||||
SECURE_RANDOM = SecureRandom.getInstanceStrong();
|
|
||||||
} catch (NoSuchAlgorithmException e) {
|
|
||||||
throw new AssertionError(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@RegisterExtension
|
@RegisterExtension
|
||||||
static DynamoDbExtension dynamoDbExtension = DynamoDbExtension.builder()
|
static DynamoDbExtension dynamoDbExtension = DynamoDbExtension.builder()
|
||||||
|
|
Loading…
Reference in New Issue