mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(organizations): attach the tags passed to InviteAccountToOrganization (#8048)
This commit is contained in:
1 parent
a27670c4bb
commit
162401b942
8 files changed
+59
-9
No files matched your search
@@ -192,7 +192,7 @@ class Inspector2IntegrationTest {
|
||||
organizationsService.createOrganization(managementAccountId, "ALL");
|
||||
for (String member : members) {
|
||||
Handshake handshake = organizationsService.inviteAccountToOrganization(
|
||||
managementAccountId, member, "ACCOUNT", null);
|
||||
managementAccountId, member, "ACCOUNT", null, null);
|
||||
organizationsService.acceptHandshake(member, handshake.getId());
|
||||
}
|
||||
}
|
||||
|
||||
+11
-1
@@ -92,7 +92,8 @@ class OrganizationsCrossAccountIntegrationTest {
|
||||
@Order(3)
|
||||
void inviteAccountToOrganization() {
|
||||
inviteHandshakeId = organizations(MANAGEMENT_ACCOUNT, "InviteAccountToOrganization",
|
||||
"{\"Target\":{\"Id\":\"" + INVITED_ACCOUNT + "\",\"Type\":\"ACCOUNT\"},\"Notes\":\"join us\"}")
|
||||
"{\"Target\":{\"Id\":\"" + INVITED_ACCOUNT + "\",\"Type\":\"ACCOUNT\"},\"Notes\":\"join us\","
|
||||
+ "\"Tags\":[{\"Key\":\"team\",\"Value\":\"red\"}]}")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
@@ -179,6 +180,15 @@ class OrganizationsCrossAccountIntegrationTest {
|
||||
.body("Accounts.Id", hasItem(INVITED_ACCOUNT))
|
||||
.body("Accounts.find { it.Id == '" + INVITED_ACCOUNT + "' }.JoinedMethod", equalTo("INVITED"))
|
||||
.body("Accounts.find { it.Id == '" + INVITED_ACCOUNT + "' }.Status", equalTo("ACTIVE"));
|
||||
|
||||
organizations(MANAGEMENT_ACCOUNT, "ListTagsForResource", "{\"ResourceId\":\"" + INVITED_ACCOUNT + "\"}")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("Tags", hasSize(1))
|
||||
.body("Tags[0].Key", equalTo("team"))
|
||||
.body("Tags[0].Value", equalTo("red"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -328,7 +328,7 @@ class OrganizationsServiceTest {
|
||||
void anExpiredHandshakeReportsExpiredAndCannotBeAccepted() {
|
||||
service.createOrganization(MANAGEMENT_ACCOUNT, "ALL");
|
||||
Handshake handshake = service.inviteAccountToOrganization(
|
||||
MANAGEMENT_ACCOUNT, OUTSIDER_ACCOUNT, "ACCOUNT", null);
|
||||
MANAGEMENT_ACCOUNT, OUTSIDER_ACCOUNT, "ACCOUNT", null, null);
|
||||
|
||||
handshake.setExpirationTimestamp(Instant.now().minus(1, ChronoUnit.DAYS));
|
||||
handshakes.putForAccount(MANAGEMENT_ACCOUNT, handshake.getId(), handshake);
|
||||
@@ -344,7 +344,7 @@ class OrganizationsServiceTest {
|
||||
void acceptingAnInvitationJoinsTheOrganizationAsAnInvitedMember() {
|
||||
Organization organization = service.createOrganization(MANAGEMENT_ACCOUNT, "ALL");
|
||||
Handshake handshake = service.inviteAccountToOrganization(
|
||||
MANAGEMENT_ACCOUNT, OUTSIDER_ACCOUNT, "ACCOUNT", null);
|
||||
MANAGEMENT_ACCOUNT, OUTSIDER_ACCOUNT, "ACCOUNT", null, null);
|
||||
|
||||
Handshake accepted = service.acceptHandshake(OUTSIDER_ACCOUNT, handshake.getId());
|
||||
assertEquals("ACCEPTED", accepted.getState());
|
||||
@@ -355,11 +355,32 @@ class OrganizationsServiceTest {
|
||||
assertEquals(organization.getId(), service.describeOrganization(OUTSIDER_ACCOUNT).getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
void acceptingAnInvitationAttachesItsTagsToTheAccount() {
|
||||
service.createOrganization(MANAGEMENT_ACCOUNT, "ALL");
|
||||
Handshake handshake = service.inviteAccountToOrganization(
|
||||
MANAGEMENT_ACCOUNT, OUTSIDER_ACCOUNT, "ACCOUNT", null, Map.of("team", "red"));
|
||||
|
||||
service.acceptHandshake(OUTSIDER_ACCOUNT, handshake.getId());
|
||||
|
||||
assertEquals(Map.of("team", "red"), service.listTagsForResource(MANAGEMENT_ACCOUNT, OUTSIDER_ACCOUNT));
|
||||
}
|
||||
|
||||
@Test
|
||||
void anInvalidTagFailsTheWholeInvitation() {
|
||||
service.createOrganization(MANAGEMENT_ACCOUNT, "ALL");
|
||||
|
||||
AwsException error = assertThrows(AwsException.class, () -> service.inviteAccountToOrganization(
|
||||
MANAGEMENT_ACCOUNT, OUTSIDER_ACCOUNT, "ACCOUNT", null, Map.of("", "red")));
|
||||
assertEquals("InvalidInputException", error.getErrorCode());
|
||||
assertTrue(service.listHandshakesForOrganization(MANAGEMENT_ACCOUNT, null, null).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
void memberAccountsCannotPerformManagementActions() {
|
||||
Organization organization = service.createOrganization(MANAGEMENT_ACCOUNT, "ALL");
|
||||
Handshake handshake = service.inviteAccountToOrganization(
|
||||
MANAGEMENT_ACCOUNT, OUTSIDER_ACCOUNT, "ACCOUNT", null);
|
||||
MANAGEMENT_ACCOUNT, OUTSIDER_ACCOUNT, "ACCOUNT", null, null);
|
||||
service.acceptHandshake(OUTSIDER_ACCOUNT, handshake.getId());
|
||||
|
||||
AwsException error = assertThrows(AwsException.class, () -> service.createOrganizationalUnit(
|
||||
|
||||
+1
-1
@@ -343,7 +343,7 @@ class SecurityHubMembersIntegrationTest {
|
||||
|
||||
private void joinOrganization(String managementAccountId, String member) {
|
||||
Handshake handshake = organizationsService.inviteAccountToOrganization(
|
||||
managementAccountId, member, "ACCOUNT", null);
|
||||
managementAccountId, member, "ACCOUNT", null, null);
|
||||
organizationsService.acceptHandshake(member, handshake.getId());
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -148,7 +148,7 @@ class SecurityHubOrganizationIntegrationTest {
|
||||
organizationsService.createOrganization(managementAccountId, "ALL");
|
||||
for (String member : members) {
|
||||
Handshake handshake = organizationsService.inviteAccountToOrganization(
|
||||
managementAccountId, member, "ACCOUNT", null);
|
||||
managementAccountId, member, "ACCOUNT", null, null);
|
||||
organizationsService.acceptHandshake(member, handshake.getId());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user