mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
feat(iam): add AmazonRDSEnhancedMonitoringRole managed policy (#1559)
* feat(iam): add AmazonRDSEnhancedMonitoringRole managed policy Seeds the AmazonRDSEnhancedMonitoringRole service-role policy at startup so callers can attach it to IAM roles without a NotFound error. * test(iam): cover AmazonRDSEnhancedMonitoringRole seeding and attachment Adds an assertion in seedAwsManagedPolicies(), a unit test that attaches the policy to a role, and an integration test that retrieves it via GetPolicy.
This commit is contained in:
1 parent
677dfd6a16
commit
2142ff6e3c
3 files changed
+41
No files matched your search
@@ -235,6 +235,25 @@ class IamIntegrationTest {
|
||||
equalTo("arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(17)
|
||||
void getRdsEnhancedMonitoringPolicy() {
|
||||
given()
|
||||
.formParam("Action", "GetPolicy")
|
||||
.formParam("PolicyArn",
|
||||
"arn:aws:iam::aws:policy/service-role/AmazonRDSEnhancedMonitoringRole")
|
||||
.header("Authorization",
|
||||
"AWS4-HMAC-SHA256 Credential=test/20260227/us-east-1/iam/aws4_request")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("GetPolicyResponse.GetPolicyResult.Policy.PolicyName",
|
||||
equalTo("AmazonRDSEnhancedMonitoringRole"))
|
||||
.body("GetPolicyResponse.GetPolicyResult.Policy.Arn",
|
||||
equalTo("arn:aws:iam::aws:policy/service-role/AmazonRDSEnhancedMonitoringRole"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(9)
|
||||
void stsGetCallerIdentityFallsBackForUnseededFlociAccessKey() {
|
||||
|
||||
@@ -554,6 +554,11 @@ class IamServiceTest {
|
||||
IamPolicy ecrReadOnly = iamService.getPolicy("arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly");
|
||||
assertEquals("AmazonEC2ContainerRegistryReadOnly", ecrReadOnly.getPolicyName());
|
||||
assertEquals("/", ecrReadOnly.getPath());
|
||||
|
||||
IamPolicy rdsMonitoring = iamService.getPolicy(
|
||||
"arn:aws:iam::aws:policy/service-role/AmazonRDSEnhancedMonitoringRole");
|
||||
assertEquals("AmazonRDSEnhancedMonitoringRole", rdsMonitoring.getPolicyName());
|
||||
assertEquals("/service-role/", rdsMonitoring.getPath());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -666,6 +671,19 @@ class IamServiceTest {
|
||||
assertEquals(policyArn, attached.getFirst().getArn());
|
||||
}
|
||||
|
||||
@Test
|
||||
void attachRdsEnhancedMonitoringRolePolicyToRole() {
|
||||
iamService.seedAwsManagedPolicies();
|
||||
iamService.createRole("RdsMonitor", "/", "{}", null, 0, null);
|
||||
|
||||
String policyArn = "arn:aws:iam::aws:policy/service-role/AmazonRDSEnhancedMonitoringRole";
|
||||
iamService.attachRolePolicy("RdsMonitor", policyArn);
|
||||
|
||||
List<IamPolicy> attached = iamService.listAttachedRolePolicies("RdsMonitor", null);
|
||||
assertEquals(1, attached.size());
|
||||
assertEquals(policyArn, attached.getFirst().getArn());
|
||||
}
|
||||
|
||||
@Test
|
||||
void awsManagedPolicyDeleteRejected() {
|
||||
iamService.seedAwsManagedPolicies();
|
||||
|
||||
Reference in new issue
Block a user