feat(organizations): add management account email configuration and tests (#2749)

Signed-off-by: Matheus André <matheusandr2@gmail.com>
This commit is contained in:
Matheus André authored and GitHub committed 2026-08-29 23:05:29 -04:00
1 parent c18af5b68a
commit 89fd37a5c4
4 files changed
+90 -3

No files matched your search

@@ -352,4 +352,46 @@ class OrganizationsServiceTest {
.getAccountId();
assertNull(disabled.effectiveScpLevels(member));
}
@Test
void managementAccountEmailDefaultsToSynthesizedAddress() {
Organization organization = service.createOrganization(MANAGEMENT_ACCOUNT, "ALL");
assertEquals("master@" + MANAGEMENT_ACCOUNT + ".example.com", organization.getMasterAccountEmail());
}
@Test
void managementAccountEmailOverrideIsUsedForOrganizationAndAccount() {
OrganizationsService configured = new OrganizationsService(
new ObjectMapper(),
AccountAwareStorageBackend.inMemory(MANAGEMENT_ACCOUNT),
AccountAwareStorageBackend.inMemory(MANAGEMENT_ACCOUNT),
AccountAwareStorageBackend.inMemory(MANAGEMENT_ACCOUNT),
AccountAwareStorageBackend.inMemory(MANAGEMENT_ACCOUNT),
AccountAwareStorageBackend.inMemory(MANAGEMENT_ACCOUNT),
AccountAwareStorageBackend.inMemory(MANAGEMENT_ACCOUNT),
true,
"root@corp.example");
Organization organization = configured.createOrganization(MANAGEMENT_ACCOUNT, "ALL");
assertEquals("root@corp.example", organization.getMasterAccountEmail());
assertEquals("root@corp.example",
configured.describeAccount(MANAGEMENT_ACCOUNT, MANAGEMENT_ACCOUNT).getEmail());
assertEquals("root@corp.example",
configured.describeOrganization(MANAGEMENT_ACCOUNT).getMasterAccountEmail());
}
@Test
void malformedManagementAccountEmailOverrideIsRejected() {
assertThrows(IllegalArgumentException.class, () -> new OrganizationsService(
new ObjectMapper(),
AccountAwareStorageBackend.inMemory(MANAGEMENT_ACCOUNT),
AccountAwareStorageBackend.inMemory(MANAGEMENT_ACCOUNT),
AccountAwareStorageBackend.inMemory(MANAGEMENT_ACCOUNT),
AccountAwareStorageBackend.inMemory(MANAGEMENT_ACCOUNT),
AccountAwareStorageBackend.inMemory(MANAGEMENT_ACCOUNT),
AccountAwareStorageBackend.inMemory(MANAGEMENT_ACCOUNT),
true,
"not-an-email"));
}
}