Skip to content

Commit

Permalink
AUT-3916: Corrections to tests following rebase.
Browse files Browse the repository at this point in the history
Changes brought in from main that renamed some of the environment
variables are now reflected in the integration tests.

Use new IDReverificationStateExtension Junit extension to support the
use ot the new IDReverificationStateService in the integration tests.
  • Loading branch information
andrew-moores committed Jan 17, 2025
1 parent bb2dde9 commit d7726f4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ class AuthSigningKeyJWKSIntegrationTest extends ApiGatewayHandlerIntegrationTest

@BeforeAll
static void setupEnvironment() {
environment.set("MFA_RESET_JAR_SIGNING_KEY_ALIAS", mfaResetJarSigningKey.getKeyId());
environment.set(
"IPV_REVERIFICATION_REQUESTS_SIGNING_KEY_ALIAS", mfaResetJarSigningKey.getKeyId());

try (KmsClient kmsClient = getKmsClient()) {
GetPublicKeyRequest getPublicKeyRequest =
Expand Down Expand Up @@ -99,7 +100,7 @@ void shouldReturnJWKSetContainingTheReverificationSigningKey() {

@Test
void shouldNotAllowExceptionsToEscape() {
environment.set("MFA_RESET_JAR_SIGNING_KEY_ALIAS", "wrong-key-alias");
environment.set("IPV_REVERIFICATION_REQUESTS_SIGNING_KEY_ALIAS", "wrong-key-alias");

handler = new MfaResetJarJwkHandler(new ConfigurationService());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import uk.gov.di.authentication.sharedtest.basetest.ApiGatewayHandlerIntegrationTest;
import uk.gov.di.authentication.sharedtest.doubles.MetricsLoggerTestDouble;
import uk.gov.di.authentication.sharedtest.extensions.CloudWatchExtension;
import uk.gov.di.authentication.sharedtest.extensions.IDReverificationStateExtension;
import uk.gov.di.authentication.sharedtest.extensions.KmsKeyExtension;
import uk.gov.di.authentication.sharedtest.extensions.RedisExtension;
import uk.org.webcompere.systemstubs.environment.EnvironmentVariables;
Expand Down Expand Up @@ -65,7 +66,7 @@ class MfaResetAuthorizeHandlerIntegrationTest extends ApiGatewayHandlerIntegrati
new KmsKeyExtension("mfa-reset-storage-token-signing-key", KeyUsageType.SIGN_VERIFY);

@RegisterExtension
private static final KmsKeyExtension mfaResetJarSigningKey =
private static final KmsKeyExtension ipvReverificationRequestsSigningKey =
new KmsKeyExtension("mfa-reset-jar-signing-key", KeyUsageType.SIGN_VERIFY);

@RegisterExtension
Expand All @@ -75,14 +76,20 @@ class MfaResetAuthorizeHandlerIntegrationTest extends ApiGatewayHandlerIntegrati
@RegisterExtension
private static final CloudWatchExtension cloudwatchExtension = new CloudWatchExtension();

@RegisterExtension
private static final IDReverificationStateExtension idReverificationStateExtension =
new IDReverificationStateExtension();

@BeforeAll
static void setupEnvironment() {
environment.set("TXMA_AUDIT_QUEUE_URL", txmaAuditQueue.getQueueUrl());
environment.set("IPV_AUTHORISATION_CLIENT_ID", "test-client-id");
environment.set(
"MFA_RESET_STORAGE_TOKEN_SIGNING_KEY_ALIAS",
mfaResetStorageTokenSigningKey.getKeyId());
environment.set("MFA_RESET_JAR_SIGNING_KEY_ID", mfaResetJarSigningKey.getKeyId());
environment.set(
"IPV_REVERIFICATION_REQUESTS_SIGNING_KEY_ALIAS",
ipvReverificationRequestsSigningKey.getKeyId());

createTestIPVEncryptionKeyPair();
putIPVPublicKeyInEnvironmentVariableUntilIPVJWKSAvailable();
Expand Down Expand Up @@ -110,7 +117,7 @@ private static void putIPVPublicKeyInEnvironmentVariableUntilIPVJWKSAvailable()
Base64.getEncoder().encodeToString(rsaKey.toRSAPublicKey().getEncoded());

environment.set(
"IPV_AUTHORIZATION_PUBLIC_KEY",
"IPV_PUBLIC_ENCRYPTION_KEY",
"-----BEGIN PUBLIC KEY-----\n"
+ base64PublicKey
+ "\n-----END PUBLIC KEY-----");
Expand Down Expand Up @@ -144,9 +151,11 @@ void setup() throws Json.JsonException {

@Test
void shouldAuthenticateMfaReset() {
idReverificationStateExtension.store("orch-redirect-url", "client-session-id");

var response =
makeRequest(
Optional.of(new MfaResetRequest(USER_EMAIL)),
Optional.of(new MfaResetRequest(USER_EMAIL, "")),
constructFrontendHeaders(sessionId, sessionId),
Map.of());

Expand All @@ -160,7 +169,9 @@ void shouldAuthenticateMfaReset() {

private static void checkCorrectKeysUsedViaIntegrationWithKms(String body) {
var kmsAccessInterceptor = ConfigurationService.getKmsAccessInterceptor();
assertTrue(kmsAccessInterceptor.wasKeyUsedToSign(mfaResetJarSigningKey.getKeyId()));
assertTrue(
kmsAccessInterceptor.wasKeyUsedToSign(
ipvReverificationRequestsSigningKey.getKeyId()));
assertTrue(
kmsAccessInterceptor.wasKeyUsedToSign(mfaResetStorageTokenSigningKey.getKeyId()));
ObjectMapper objectMapper = new ObjectMapper();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ class ReverificationResultHandlerIntegrationTest extends ApiGatewayHandlerIntegr

@BeforeAll
static void setupEnvironment() {
environment.set("MFA_RESET_JAR_SIGNING_KEY_ALIAS", mfaResetJarSigningKey.getKeyId());
environment.set(
"IPV_REVERIFICATION_REQUESTS_SIGNING_KEY_ALIAS", mfaResetJarSigningKey.getKeyId());
environment.set("IPV_AUTHORISATION_CLIENT_ID", "test-client-id");
environment.set("IPV_AUDIENCE", "test-audience");
environment.set("TXMA_AUDIT_QUEUE_URL", txmaAuditQueue.getQueueUrl());
Expand Down

0 comments on commit d7726f4

Please sign in to comment.