mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
test(iam): share one IAM enforcement test profile instead of nine identical ones (#4139)
This commit is contained in:
1 parent
2277217438
commit
63c0c3ada5
11 files changed
+38
-91
No files matched your search
+2
-10
@@ -1,11 +1,10 @@
|
||||
package io.github.hectorvent.floci.services.iam;
|
||||
|
||||
import io.github.hectorvent.floci.testing.IamEnforcementProfile;
|
||||
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 java.util.UUID;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
@@ -18,16 +17,9 @@ import static org.hamcrest.Matchers.startsWith;
|
||||
* Floci does not know about stays permissive (backward-compatible).
|
||||
*/
|
||||
@QuarkusTest
|
||||
@TestProfile(AssumeRoleTrustPolicyIntegrationTest.EnforcementProfile.class)
|
||||
@TestProfile(IamEnforcementProfile.class)
|
||||
class AssumeRoleTrustPolicyIntegrationTest {
|
||||
|
||||
public static class EnforcementProfile implements QuarkusTestProfile {
|
||||
@Override
|
||||
public Map<String, String> getConfigOverrides() {
|
||||
return Map.of("floci.services.iam.enforcement-enabled", "true");
|
||||
}
|
||||
}
|
||||
|
||||
private static final String ACCOUNT_A = "111111111111";
|
||||
private static final String ACCOUNT_B = "222222222222";
|
||||
private static final String ACCOUNT_C = "333333333333";
|
||||
|
||||
+2
-10
@@ -1,13 +1,12 @@
|
||||
package io.github.hectorvent.floci.services.iam;
|
||||
|
||||
import io.github.hectorvent.floci.testing.IamEnforcementProfile;
|
||||
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 java.util.UUID;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
@@ -21,7 +20,7 @@ import static org.hamcrest.Matchers.startsWith;
|
||||
* another tenant's, through the real filter, resolver and evaluator.
|
||||
*/
|
||||
@QuarkusTest
|
||||
@TestProfile(DynamoDbFgacEnforcementIntegrationTest.IamEnforcementProfile.class)
|
||||
@TestProfile(IamEnforcementProfile.class)
|
||||
class DynamoDbFgacEnforcementIntegrationTest {
|
||||
|
||||
private static final String DYNAMODB_CONTENT_TYPE = "application/x-amz-json-1.0";
|
||||
@@ -297,11 +296,4 @@ class DynamoDbFgacEnforcementIntegrationTest {
|
||||
return "AWS4-HMAC-SHA256 Credential=" + accessKeyId + "/20260904/" + REGION + "/" + service
|
||||
+ "/aws4_request, SignedHeaders=host, Signature=abc";
|
||||
}
|
||||
|
||||
public static final class IamEnforcementProfile implements QuarkusTestProfile {
|
||||
@Override
|
||||
public Map<String, String> getConfigOverrides() {
|
||||
return Map.of("floci.services.iam.enforcement-enabled", "true");
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-9
@@ -1,7 +1,7 @@
|
||||
package io.github.hectorvent.floci.services.iam;
|
||||
|
||||
import io.github.hectorvent.floci.testing.IamEnforcementProfile;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.quarkus.test.junit.QuarkusTestProfile;
|
||||
import io.quarkus.test.junit.TestProfile;
|
||||
import io.restassured.response.ValidatableResponse;
|
||||
import io.restassured.specification.RequestSpecification;
|
||||
@@ -20,7 +20,7 @@ import static org.hamcrest.Matchers.not;
|
||||
* AttachUserPolicy, DeleteUser) when enforcement is enabled.
|
||||
*/
|
||||
@QuarkusTest
|
||||
@TestProfile(IamManagementActionsEnforcementIntegrationTest.IamEnforcementProfile.class)
|
||||
@TestProfile(IamEnforcementProfile.class)
|
||||
class IamManagementActionsEnforcementIntegrationTest {
|
||||
|
||||
private static final String ACCOUNT_ID = "000000000000";
|
||||
@@ -116,11 +116,4 @@ class IamManagementActionsEnforcementIntegrationTest {
|
||||
return "AWS4-HMAC-SHA256 Credential=" + accessKeyId + "/20260919/" + REGION + "/" + service
|
||||
+ "/aws4_request, SignedHeaders=host, Signature=abc";
|
||||
}
|
||||
|
||||
public static final class IamEnforcementProfile implements QuarkusTestProfile {
|
||||
@Override
|
||||
public Map<String, String> getConfigOverrides() {
|
||||
return Map.of("floci.services.iam.enforcement-enabled", "true");
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-9
@@ -3,8 +3,8 @@ package io.github.hectorvent.floci.services.iam;
|
||||
import io.github.hectorvent.floci.services.iam.model.SessionCreds;
|
||||
import io.github.hectorvent.floci.services.lambda.launcher.LambdaExecutionRoleCredentials;
|
||||
import io.github.hectorvent.floci.services.lambda.model.LambdaFunction;
|
||||
import io.github.hectorvent.floci.testing.IamEnforcementProfile;
|
||||
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.Test;
|
||||
@@ -17,7 +17,7 @@ import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
||||
@QuarkusTest
|
||||
@TestProfile(LambdaExecutionRoleIamEnforcementIntegrationTest.IamEnforcementProfile.class)
|
||||
@TestProfile(IamEnforcementProfile.class)
|
||||
class LambdaExecutionRoleIamEnforcementIntegrationTest {
|
||||
|
||||
private static final String ACCOUNT_ID = "000000000000";
|
||||
@@ -140,11 +140,4 @@ class LambdaExecutionRoleIamEnforcementIntegrationTest {
|
||||
return "AWS4-HMAC-SHA256 Credential=" + accessKeyId + "/20260720/" + REGION + "/" + service
|
||||
+ "/aws4_request, SignedHeaders=host, Signature=abc";
|
||||
}
|
||||
|
||||
public static final class IamEnforcementProfile implements QuarkusTestProfile {
|
||||
@Override
|
||||
public Map<String, String> getConfigOverrides() {
|
||||
return Map.of("floci.services.iam.enforcement-enabled", "true");
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -3,6 +3,7 @@ package io.github.hectorvent.floci.services.iam;
|
||||
import io.github.hectorvent.floci.services.iam.model.SessionCreds;
|
||||
import io.github.hectorvent.floci.services.lambda.launcher.LambdaExecutionRoleCredentials;
|
||||
import io.github.hectorvent.floci.services.lambda.model.LambdaFunction;
|
||||
import io.github.hectorvent.floci.testing.IamEnforcementProfile;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.quarkus.test.junit.TestProfile;
|
||||
import jakarta.inject.Inject;
|
||||
@@ -14,7 +15,7 @@ import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
|
||||
@QuarkusTest
|
||||
@TestProfile(LambdaExecutionRoleIamEnforcementIntegrationTest.IamEnforcementProfile.class)
|
||||
@TestProfile(IamEnforcementProfile.class)
|
||||
class LambdaScopedTablePermissionIntegrationTest {
|
||||
|
||||
private static final String ACCOUNT_ID = "000000000000";
|
||||
|
||||
+2
-11
@@ -1,13 +1,11 @@
|
||||
package io.github.hectorvent.floci.services.iam;
|
||||
|
||||
import io.github.hectorvent.floci.testing.IamEnforcementProfile;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.restassured.specification.RequestSpecification;
|
||||
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.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
@@ -31,7 +29,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
* and everything was denied - including what AWS allows.
|
||||
*/
|
||||
@QuarkusTest
|
||||
@TestProfile(S3ObjectTagConditionEnforcementIntegrationTest.IamEnforcementProfile.class)
|
||||
@TestProfile(IamEnforcementProfile.class)
|
||||
class S3ObjectTagConditionEnforcementIntegrationTest {
|
||||
|
||||
private static final String ADMIN = "test";
|
||||
@@ -238,11 +236,4 @@ class S3ObjectTagConditionEnforcementIntegrationTest {
|
||||
return "AWS4-HMAC-SHA256 Credential=" + accessKeyId + "/20260629/" + REGION + "/" + service
|
||||
+ "/aws4_request, SignedHeaders=host, Signature=abc";
|
||||
}
|
||||
|
||||
public static final class IamEnforcementProfile implements QuarkusTestProfile {
|
||||
@Override
|
||||
public Map<String, String> getConfigOverrides() {
|
||||
return Map.of("floci.services.iam.enforcement-enabled", "true");
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-10
@@ -1,11 +1,10 @@
|
||||
package io.github.hectorvent.floci.services.iam;
|
||||
|
||||
import io.github.hectorvent.floci.testing.IamEnforcementProfile;
|
||||
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 java.util.UUID;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
@@ -13,7 +12,7 @@ import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
|
||||
@QuarkusTest
|
||||
@TestProfile(StsSessionPolicyS3EnforcementIntegrationTest.IamEnforcementProfile.class)
|
||||
@TestProfile(IamEnforcementProfile.class)
|
||||
class StsSessionPolicyS3EnforcementIntegrationTest {
|
||||
|
||||
private static final String CALLER_ACCOUNT_ID = "111122223333";
|
||||
@@ -242,11 +241,4 @@ class StsSessionPolicyS3EnforcementIntegrationTest {
|
||||
return "AWS4-HMAC-SHA256 Credential=" + accessKeyId + "/20260629/" + REGION + "/" + service
|
||||
+ "/aws4_request, SignedHeaders=host, Signature=abc";
|
||||
}
|
||||
|
||||
public static final class IamEnforcementProfile implements QuarkusTestProfile {
|
||||
@Override
|
||||
public Map<String, String> getConfigOverrides() {
|
||||
return Map.of("floci.services.iam.enforcement-enabled", "true");
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-11
@@ -1,17 +1,15 @@
|
||||
package io.github.hectorvent.floci.services.iam;
|
||||
|
||||
import io.github.hectorvent.floci.testing.IamEnforcementProfile;
|
||||
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.containsString;
|
||||
|
||||
@QuarkusTest
|
||||
@TestProfile(StsWebIdentityEnforcementIntegrationTest.EnforcementProfile.class)
|
||||
@TestProfile(IamEnforcementProfile.class)
|
||||
class StsWebIdentityEnforcementIntegrationTest {
|
||||
|
||||
@Test
|
||||
@@ -47,11 +45,4 @@ class StsWebIdentityEnforcementIntegrationTest {
|
||||
.when()
|
||||
.post("/");
|
||||
}
|
||||
|
||||
public static final class EnforcementProfile implements QuarkusTestProfile {
|
||||
@Override
|
||||
public Map<String, String> getConfigOverrides() {
|
||||
return Map.of("floci.services.iam.enforcement-enabled", "true");
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-10
@@ -1,7 +1,7 @@
|
||||
package io.github.hectorvent.floci.services.s3;
|
||||
|
||||
import io.github.hectorvent.floci.testing.IamEnforcementProfile;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.quarkus.test.junit.QuarkusTestProfile;
|
||||
import io.quarkus.test.junit.TestProfile;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -10,7 +10,6 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneOffset;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
@@ -30,7 +29,7 @@ import static org.hamcrest.Matchers.containsString;
|
||||
* - IAM policy evaluation does not depend on the signature itself being checked.
|
||||
*/
|
||||
@QuarkusTest
|
||||
@TestProfile(S3PresignedUrlIamEnforcementIntegrationTest.IamEnforcementProfile.class)
|
||||
@TestProfile(IamEnforcementProfile.class)
|
||||
class S3PresignedUrlIamEnforcementIntegrationTest {
|
||||
|
||||
private static final String REGION = "us-east-1";
|
||||
@@ -168,11 +167,4 @@ class S3PresignedUrlIamEnforcementIntegrationTest {
|
||||
return "AWS4-HMAC-SHA256 Credential=" + accessKeyId + "/20260629/" + REGION + "/" + service
|
||||
+ "/aws4_request, SignedHeaders=host, Signature=abc";
|
||||
}
|
||||
|
||||
public static final class IamEnforcementProfile implements QuarkusTestProfile {
|
||||
@Override
|
||||
public Map<String, String> getConfigOverrides() {
|
||||
return Map.of("floci.services.iam.enforcement-enabled", "true");
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-10
@@ -1,11 +1,10 @@
|
||||
package io.github.hectorvent.floci.services.s3;
|
||||
|
||||
import io.github.hectorvent.floci.testing.IamEnforcementProfile;
|
||||
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 java.util.UUID;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
@@ -27,7 +26,7 @@ import static org.hamcrest.Matchers.containsString;
|
||||
* itself being checked.
|
||||
*/
|
||||
@QuarkusTest
|
||||
@TestProfile(S3VirtualHostIamEnforcementIntegrationTest.IamEnforcementProfile.class)
|
||||
@TestProfile(IamEnforcementProfile.class)
|
||||
class S3VirtualHostIamEnforcementIntegrationTest {
|
||||
|
||||
private static final String REGION = "us-east-1";
|
||||
@@ -144,11 +143,4 @@ class S3VirtualHostIamEnforcementIntegrationTest {
|
||||
return "AWS4-HMAC-SHA256 Credential=" + accessKeyId + "/20260629/" + REGION + "/" + service
|
||||
+ "/aws4_request, SignedHeaders=host, Signature=abc";
|
||||
}
|
||||
|
||||
public static final class IamEnforcementProfile implements QuarkusTestProfile {
|
||||
@Override
|
||||
public Map<String, String> getConfigOverrides() {
|
||||
return Map.of("floci.services.iam.enforcement-enabled", "true");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package io.github.hectorvent.floci.testing;
|
||||
|
||||
import io.quarkus.test.junit.QuarkusTestProfile;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Turns IAM enforcement on, and nothing else. Quarkus restarts and re-augments the application
|
||||
* once per distinct profile class, so the classes that need only this override share this one
|
||||
* rather than each declaring an identical nested profile.
|
||||
*/
|
||||
public class IamEnforcementProfile implements QuarkusTestProfile {
|
||||
|
||||
@Override
|
||||
public Map<String, String> getConfigOverrides() {
|
||||
return Map.of("floci.services.iam.enforcement-enabled", "true");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user