diff --git a/src/test/java/io/github/hectorvent/floci/services/bedrockagentcore/BedrockAgentCoreInvokeValidateIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/bedrockagentcore/BedrockAgentCoreInvokeValidateIntegrationTest.java index 021ffdd8ab..0e972bc11c 100644 --- a/src/test/java/io/github/hectorvent/floci/services/bedrockagentcore/BedrockAgentCoreInvokeValidateIntegrationTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/bedrockagentcore/BedrockAgentCoreInvokeValidateIntegrationTest.java @@ -1,12 +1,10 @@ package io.github.hectorvent.floci.services.bedrockagentcore; +import io.github.hectorvent.floci.testing.IndependentServiceSettingsProfile; import io.quarkus.test.junit.QuarkusTest; -import io.quarkus.test.junit.QuarkusTestProfile; import io.quarkus.test.junit.TestProfile; import org.junit.jupiter.api.Test; -import java.util.Map; - import static io.restassured.RestAssured.given; import static org.hamcrest.Matchers.equalTo; @@ -14,18 +12,14 @@ import static org.hamcrest.Matchers.equalTo; * Verifies the opt-in existence check (issue #11). With * {@code validate-runtime-exists=true}, invoking an unknown runtime ARN returns 404 * while invoking a real runtime's ARN still returns the canned body. + * + *

The setting comes from {@link IndependentServiceSettingsProfile}, which this class shares + * with other classes that each call a different service. */ @QuarkusTest -@TestProfile(BedrockAgentCoreInvokeValidateIntegrationTest.ValidateProfile.class) +@TestProfile(IndependentServiceSettingsProfile.class) class BedrockAgentCoreInvokeValidateIntegrationTest { - public static class ValidateProfile implements QuarkusTestProfile { - @Override - public Map getConfigOverrides() { - return Map.of("floci.services.bedrock-agent-core.validate-runtime-exists", "true"); - } - } - private static final String CREATE = """ { "agentRuntimeName": "invAgent", diff --git a/src/test/java/io/github/hectorvent/floci/services/cloudfront/CloudFrontCustomOriginServingTest.java b/src/test/java/io/github/hectorvent/floci/services/cloudfront/CloudFrontCustomOriginServingTest.java index a3c63283ed..0f16c54db3 100644 --- a/src/test/java/io/github/hectorvent/floci/services/cloudfront/CloudFrontCustomOriginServingTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/cloudfront/CloudFrontCustomOriginServingTest.java @@ -13,8 +13,8 @@ import io.github.hectorvent.floci.services.cloudfront.model.Origin; import io.github.hectorvent.floci.services.cloudfront.model.OriginRequestPolicy; import io.github.hectorvent.floci.services.cloudfront.model.PublicKey; import io.github.hectorvent.floci.services.cloudfront.model.ResponseHeadersPolicy; +import io.github.hectorvent.floci.testing.IndependentServiceSettingsProfile; import io.quarkus.test.junit.QuarkusTest; -import io.quarkus.test.junit.QuarkusTestProfile; import io.quarkus.test.junit.TestProfile; import io.restassured.RestAssured; import io.restassured.response.Response; @@ -59,8 +59,15 @@ import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTimeoutPreemptively; import static org.junit.jupiter.api.Assertions.assertTrue; +/** + * Serves distributions from custom origins that the tests start on 127.0.0.1. + * + *

CloudFront refuses an origin at a private address unless its host is allowed. The allowance + * for 127.0.0.1 comes from {@link IndependentServiceSettingsProfile}, which this class shares with + * other classes that each call a different service. + */ @QuarkusTest -@TestProfile(CloudFrontCustomOriginServingTest.PrivateOriginProfile.class) +@TestProfile(IndependentServiceSettingsProfile.class) class CloudFrontCustomOriginServingTest { /** The AWS managed CachingDisabled cache policy, which forwards no viewer values. */ @@ -1085,11 +1092,4 @@ class CloudFrontCustomOriginServingTest { behavior.setViewerProtocolPolicy("allow-all"); return behavior; } - - public static final class PrivateOriginProfile implements QuarkusTestProfile { - @Override - public Map getConfigOverrides() { - return Map.of("floci.services.cloudfront.allowed-private-origin-hosts", "127.0.0.1"); - } - } } diff --git a/src/test/java/io/github/hectorvent/floci/services/cognito/CognitoTokenValidityLimitsOffIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/cognito/CognitoTokenValidityLimitsOffIntegrationTest.java index b25bbdafc6..e296b08f00 100644 --- a/src/test/java/io/github/hectorvent/floci/services/cognito/CognitoTokenValidityLimitsOffIntegrationTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/cognito/CognitoTokenValidityLimitsOffIntegrationTest.java @@ -1,15 +1,13 @@ package io.github.hectorvent.floci.services.cognito; import com.fasterxml.jackson.databind.JsonNode; +import io.github.hectorvent.floci.testing.IndependentServiceSettingsProfile; import io.github.hectorvent.floci.testing.RestAssuredJsonUtils; import io.quarkus.test.junit.QuarkusTest; -import io.quarkus.test.junit.QuarkusTestProfile; import io.quarkus.test.junit.TestProfile; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import java.util.Map; - import static io.github.hectorvent.floci.services.cognito.CognitoCustomDomainFixtures.jwtPayload; import static io.github.hectorvent.floci.services.cognito.CognitoRestAssuredUtils.cognitoAction; import static io.github.hectorvent.floci.services.cognito.CognitoRestAssuredUtils.cognitoJson; @@ -18,9 +16,12 @@ import static org.junit.jupiter.api.Assertions.assertEquals; /** * With {@code floci.services.cognito.enforce-token-validity-limits=false}, an app client keeps tokens * shorter than AWS allows, as tests of what happens when a token expires want. + * + *

The setting comes from {@link IndependentServiceSettingsProfile}, which this class shares + * with other classes that each call a different service. */ @QuarkusTest -@TestProfile(CognitoTokenValidityLimitsOffIntegrationTest.TokenValidityLimitsOffProfile.class) +@TestProfile(IndependentServiceSettingsProfile.class) class CognitoTokenValidityLimitsOffIntegrationTest { private static final String PASSWORD = "Perm1234!"; @@ -59,11 +60,4 @@ class CognitoTokenValidityLimitsOffIntegrationTest { JsonNode idToken = jwtPayload(result.path("IdToken").asText()); assertEquals(60, idToken.path("exp").asLong() - idToken.path("iat").asLong()); } - - public static final class TokenValidityLimitsOffProfile implements QuarkusTestProfile { - @Override - public Map getConfigOverrides() { - return Map.of("floci.services.cognito.enforce-token-validity-limits", "false"); - } - } } diff --git a/src/test/java/io/github/hectorvent/floci/services/iam/IamSeededAccountAliasIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/iam/IamSeededAccountAliasIntegrationTest.java index a7ea7ff31c..91abac7ca7 100644 --- a/src/test/java/io/github/hectorvent/floci/services/iam/IamSeededAccountAliasIntegrationTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/iam/IamSeededAccountAliasIntegrationTest.java @@ -1,35 +1,29 @@ package io.github.hectorvent.floci.services.iam; +import io.github.hectorvent.floci.testing.IndependentServiceSettingsProfile; import io.quarkus.test.junit.QuarkusTest; -import io.quarkus.test.junit.QuarkusTestProfile; import io.quarkus.test.junit.TestProfile; import org.junit.jupiter.api.Test; -import java.util.Map; - +import static io.github.hectorvent.floci.testing.IndependentServiceSettingsProfile.IAM_ACCOUNT_ALIAS; import static io.restassured.RestAssured.given; import static org.hamcrest.Matchers.equalTo; /** * Verifies that {@code floci.services.iam.account-alias} seeds the alias at startup, so callers * that read an account alias find one without creating it first. + * + *

The alias, {@link IndependentServiceSettingsProfile#IAM_ACCOUNT_ALIAS}, comes from + * {@link IndependentServiceSettingsProfile}, which this class shares with other classes that each + * call a different service. */ @QuarkusTest -@TestProfile(IamSeededAccountAliasIntegrationTest.SeededAliasProfile.class) +@TestProfile(IndependentServiceSettingsProfile.class) class IamSeededAccountAliasIntegrationTest { - private static final String SEEDED_ALIAS = "seeded-alias"; - private static final String IAM_CREDENTIAL = "AWS4-HMAC-SHA256 Credential=test/20260227/us-east-1/iam/aws4_request"; - public static class SeededAliasProfile implements QuarkusTestProfile { - @Override - public Map getConfigOverrides() { - return Map.of("floci.services.iam.account-alias", SEEDED_ALIAS); - } - } - @Test void configuredAliasIsSeededAtStartup() { given() @@ -40,14 +34,14 @@ class IamSeededAccountAliasIntegrationTest { .then() .statusCode(200) .body("ListAccountAliasesResponse.ListAccountAliasesResult.AccountAliases.member", - equalTo(SEEDED_ALIAS)); + equalTo(IAM_ACCOUNT_ALIAS)); } @Test void recreatingTheSeededAliasIsRejected() { given() .formParam("Action", "CreateAccountAlias") - .formParam("AccountAlias", SEEDED_ALIAS) + .formParam("AccountAlias", IAM_ACCOUNT_ALIAS) .header("Authorization", IAM_CREDENTIAL) .when() .post("/") @@ -80,7 +74,7 @@ class IamSeededAccountAliasIntegrationTest { given() .formParam("Action", "CreateAccountAlias") - .formParam("AccountAlias", SEEDED_ALIAS) + .formParam("AccountAlias", IAM_ACCOUNT_ALIAS) .header("Authorization", IAM_CREDENTIAL) .when() .post("/") diff --git a/src/test/java/io/github/hectorvent/floci/services/kinesis/KinesisListShardsTokenExpiryIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/kinesis/KinesisListShardsTokenExpiryIntegrationTest.java index 8ab143cfb5..c796633935 100644 --- a/src/test/java/io/github/hectorvent/floci/services/kinesis/KinesisListShardsTokenExpiryIntegrationTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/kinesis/KinesisListShardsTokenExpiryIntegrationTest.java @@ -2,16 +2,14 @@ package io.github.hectorvent.floci.services.kinesis; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ObjectNode; +import io.github.hectorvent.floci.testing.IndependentServiceSettingsProfile; import io.github.hectorvent.floci.testing.RestAssuredJsonUtils; import io.quarkus.test.junit.QuarkusTest; -import io.quarkus.test.junit.QuarkusTestProfile; import io.quarkus.test.junit.TestProfile; import io.restassured.response.Response; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import java.util.Map; - import static io.restassured.RestAssured.given; import static org.hamcrest.Matchers.equalTo; @@ -19,9 +17,12 @@ import static org.hamcrest.Matchers.equalTo; * Proves the ListShards NextToken expiry is driven by the * {@code floci.services.kinesis.list-shards-next-token-ttl-millis} setting: with the TTL lowered to * zero, the second page is rejected instead of waiting out AWS's 300 second window. + * + *

The setting comes from {@link IndependentServiceSettingsProfile}, which this class shares + * with other classes that each call a different service. */ @QuarkusTest -@TestProfile(KinesisListShardsTokenExpiryIntegrationTest.ZeroTtlProfile.class) +@TestProfile(IndependentServiceSettingsProfile.class) class KinesisListShardsTokenExpiryIntegrationTest { private static final String KINESIS_CONTENT_TYPE = "application/x-amz-json-1.1"; @@ -69,11 +70,4 @@ class KinesisListShardsTokenExpiryIntegrationTest { .statusCode(400) .body("__type", equalTo("ExpiredNextTokenException")); } - - public static final class ZeroTtlProfile implements QuarkusTestProfile { - @Override - public Map getConfigOverrides() { - return Map.of("floci.services.kinesis.list-shards-next-token-ttl-millis", "0"); - } - } } diff --git a/src/test/java/io/github/hectorvent/floci/services/neptune/NeptuneOpenCypherIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/neptune/NeptuneOpenCypherIntegrationTest.java index ce16de8c98..1a8dc1716e 100644 --- a/src/test/java/io/github/hectorvent/floci/services/neptune/NeptuneOpenCypherIntegrationTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/neptune/NeptuneOpenCypherIntegrationTest.java @@ -1,7 +1,7 @@ package io.github.hectorvent.floci.services.neptune; +import io.github.hectorvent.floci.testing.IndependentServiceSettingsProfile; import io.quarkus.test.junit.QuarkusTest; -import io.quarkus.test.junit.QuarkusTestProfile; import io.quarkus.test.junit.TestProfile; import org.junit.jupiter.api.Test; import org.neo4j.driver.AuthTokens; @@ -9,7 +9,6 @@ import org.neo4j.driver.Driver; import org.neo4j.driver.GraphDatabase; import org.neo4j.driver.Session; -import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -23,9 +22,12 @@ import static org.junit.jupiter.api.Assertions.assertEquals; *

The default Gremlin backend ({@code tinkerpop/gremlin-server}) does NOT understand * openCypher/Bolt, so before {@code db-type} support existed this test could not pass — * the proxied port served a Gremlin WebSocket endpoint, not a Bolt endpoint. + * + *

{@code db-type=neo4j} comes from {@link IndependentServiceSettingsProfile}, which this class + * shares with other classes that each call a different service. */ @QuarkusTest -@TestProfile(NeptuneOpenCypherIntegrationTest.Neo4jDbTypeProfile.class) +@TestProfile(IndependentServiceSettingsProfile.class) class NeptuneOpenCypherIntegrationTest { private static final String FORM = "application/x-www-form-urlencoded"; @@ -85,11 +87,4 @@ class NeptuneOpenCypherIntegrationTest { } return Integer.parseInt(m.group(1)); } - - public static final class Neo4jDbTypeProfile implements QuarkusTestProfile { - @Override - public Map getConfigOverrides() { - return Map.of("floci.services.neptune.db-type", "neo4j"); - } - } } diff --git a/src/test/java/io/github/hectorvent/floci/services/route53/Route53VpcAssociationTransientErrorIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/route53/Route53VpcAssociationTransientErrorIntegrationTest.java index 3a56afc077..55d32bdb10 100644 --- a/src/test/java/io/github/hectorvent/floci/services/route53/Route53VpcAssociationTransientErrorIntegrationTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/route53/Route53VpcAssociationTransientErrorIntegrationTest.java @@ -1,32 +1,31 @@ package io.github.hectorvent.floci.services.route53; +import io.github.hectorvent.floci.testing.IndependentServiceSettingsProfile; import io.quarkus.test.junit.QuarkusTest; -import io.quarkus.test.junit.QuarkusTestProfile; import io.quarkus.test.junit.TestProfile; import org.junit.jupiter.api.Test; import java.time.Duration; -import java.util.Map; import static io.restassured.RestAssured.given; import static org.awaitility.Awaitility.await; import static org.hamcrest.Matchers.containsString; +/** + * Verifies that a VPC association or authorization change on a private hosted zone, made while the + * previous one is still in progress, is refused with {@code PriorRequestNotComplete} or + * {@code ConcurrentModification}, and that a retry succeeds once the previous change is done. + * + *

The 150 ms the previous change stays in progress comes from + * {@link IndependentServiceSettingsProfile}, which this class shares with other classes that each + * call a different service. + */ @QuarkusTest -@TestProfile(Route53VpcAssociationTransientErrorIntegrationTest.DelayProfile.class) +@TestProfile(IndependentServiceSettingsProfile.class) class Route53VpcAssociationTransientErrorIntegrationTest { private static final String XML = "application/xml"; - public static final class DelayProfile implements QuarkusTestProfile { - @Override - public Map getConfigOverrides() { - return Map.of( - "floci.storage.mode", "memory", - "floci.services.route53.vpc-association-control-plane-delay-ms", "150"); - } - } - @Test void associationOverlapReturnsPriorRequestNotCompleteThenRetrySucceeds() { String zoneId = createPrivateZone( diff --git a/src/test/java/io/github/hectorvent/floci/services/scheduler/SchedulerRateFirstOccurrenceIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/scheduler/SchedulerRateFirstOccurrenceIntegrationTest.java index 4c5be659f6..78997fea51 100644 --- a/src/test/java/io/github/hectorvent/floci/services/scheduler/SchedulerRateFirstOccurrenceIntegrationTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/scheduler/SchedulerRateFirstOccurrenceIntegrationTest.java @@ -6,9 +6,9 @@ import io.github.hectorvent.floci.config.EmulatorConfig; import io.github.hectorvent.floci.services.scheduler.model.Schedule; import io.github.hectorvent.floci.services.sqs.SqsService; import io.github.hectorvent.floci.services.sqs.model.Message; +import io.github.hectorvent.floci.testing.IndependentServiceSettingsProfile; import io.github.hectorvent.floci.testing.RestAssuredJsonUtils; import io.quarkus.test.junit.QuarkusTest; -import io.quarkus.test.junit.QuarkusTestProfile; import io.quarkus.test.junit.TestProfile; import jakarta.inject.Inject; import org.junit.jupiter.api.AfterEach; @@ -29,17 +29,19 @@ import static io.restassured.RestAssured.given; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; +/** + * Verifies that a rate schedule first fires at its stored start date, or at its creation date when + * it has none, whether it is created or updated directly or through a Step Functions SDK task. + * + *

Each test ticks a dispatcher of its own at chosen instants, so the background dispatcher is + * off: {@code floci.services.scheduler.invocation-enabled=false} comes from + * {@link IndependentServiceSettingsProfile}, which this class shares with other classes that each + * call a different service. + */ @QuarkusTest -@TestProfile(SchedulerRateFirstOccurrenceIntegrationTest.ManualDispatch.class) +@TestProfile(IndependentServiceSettingsProfile.class) class SchedulerRateFirstOccurrenceIntegrationTest { - public static class ManualDispatch implements QuarkusTestProfile { - @Override - public Map getConfigOverrides() { - return Map.of("floci.services.scheduler.invocation-enabled", "false"); - } - } - private static final ObjectMapper MAPPER = new ObjectMapper(); @Inject diff --git a/src/test/java/io/github/hectorvent/floci/testing/IndependentServiceSettingsProfile.java b/src/test/java/io/github/hectorvent/floci/testing/IndependentServiceSettingsProfile.java new file mode 100644 index 0000000000..013fbd10c3 --- /dev/null +++ b/src/test/java/io/github/hectorvent/floci/testing/IndependentServiceSettingsProfile.java @@ -0,0 +1,65 @@ +package io.github.hectorvent.floci.testing; + +import io.quarkus.test.junit.QuarkusTestProfile; + +import java.util.Map; + +/** + * One setting each for services that only one class in this group calls, for the classes that + * test those settings. Quarkus builds the application once per distinct profile class, so they + * share this one rather than each declaring their own. + * + *

The overrides, and who relies on them: + *

+ * + *

Each override is inert for the other classes. Each one is read by a single service: the + * Bedrock AgentCore data plane on an invocation, IAM's account alias actions, Kinesis ListShards, + * Neptune cluster creation, Route53 VPC association and authorization, CloudFront origin fetches, + * Cognito app client validation, and the Scheduler dispatcher. Each class is the only one here + * that calls its service, so no override reaches another class, and neither does anything a class + * leaves behind. + * + *

A class joins only if no other class here calls its service. One that shares a service with + * a class already here takes a profile of its own. + */ +public class IndependentServiceSettingsProfile implements QuarkusTestProfile { + + public static final String IAM_ACCOUNT_ALIAS = "seeded-alias"; + + @Override + public Map getConfigOverrides() { + return Map.of( + "floci.services.bedrock-agent-core.validate-runtime-exists", "true", + "floci.services.iam.account-alias", IAM_ACCOUNT_ALIAS, + "floci.services.kinesis.list-shards-next-token-ttl-millis", "0", + "floci.services.neptune.db-type", "neo4j", + "floci.services.route53.vpc-association-control-plane-delay-ms", "150", + "floci.services.cloudfront.allowed-private-origin-hosts", "127.0.0.1", + "floci.services.cognito.enforce-token-validity-limits", "false", + "floci.services.scheduler.invocation-enabled", "false"); + } +}