Light, fluffy, and always free - The AWS Local Emulator alternative
fix(identitystore): self-heal the bootstrap identity store on hasIdentityStore (#3387)
Priamo Germosenb87ee5bd4a5c
diff --git a/src/main/java/io/github/hectorvent/floci/services/ssoadmin/SsoAdminService.java b/src/main/java/io/github/hectorvent/floci/services/ssoadmin/SsoAdminService.javaindex f2a9889bf1..fb42f61438 100644--- a/src/main/java/io/github/hectorvent/floci/services/ssoadmin/SsoAdminService.java+++ b/src/main/java/io/github/hectorvent/floci/services/ssoadmin/SsoAdminService.java@@ -224,6 +224,9 @@ public class SsoAdminService implements Resettable {if (identityStoreId == null) {return false;}+ // Self-heals like listInstances(): storageFactory.clearAll() wipes `instances` right after+ // clear() re-seeds it, so /state/reset otherwise leaves the bootstrap instance missing.+ ensureBootstrapInstance(defaultAccountId, defaultRegion);if (instances.scan(key -> true).stream().anyMatch(instance -> identityStoreId.equals(instance.identityStoreId()))) {return true;diff --git a/src/test/java/io/github/hectorvent/floci/services/ssoadmin/SsoAdminServiceTest.java b/src/test/java/io/github/hectorvent/floci/services/ssoadmin/SsoAdminServiceTest.javaindex 443bc66420..c7e0565015 100644--- a/src/test/java/io/github/hectorvent/floci/services/ssoadmin/SsoAdminServiceTest.java+++ b/src/test/java/io/github/hectorvent/floci/services/ssoadmin/SsoAdminServiceTest.java@@ -46,6 +46,7 @@ class SsoAdminServiceTest {private InMemoryStorage<String, ApplicationAccessScope> applicationAccessScopes;private InMemoryStorage<String, ApplicationAuthenticationMethod> applicationAuthenticationMethods;private InMemoryStorage<String, ApplicationGrant> applicationGrants;+ private InMemoryStorage<String, SsoInstance> instances;@BeforeEachvoid setUp() {@@ -54,6 +55,7 @@ class SsoAdminServiceTest {applicationAccessScopes = new InMemoryStorage<>();applicationAuthenticationMethods = new InMemoryStorage<>();applicationGrants = new InMemoryStorage<>();+ instances = new InMemoryStorage<>();service = new SsoAdminService(new InMemoryStorage<String, PermissionSet>(),new InMemoryStorage<String, Assignment>(),@@ -72,7 +74,7 @@ class SsoAdminServiceTest {applicationGrants,new InMemoryStorage<String, String>(),new InMemoryStorage<String, Map<String, String>>(),- new InMemoryStorage<String, SsoInstance>(),+ instances,new InMemoryStorage<String, InstanceUpdateState>(),new InMemoryStorage<String, String>(),new InMemoryStorage<String, Boolean>(),@@ -87,6 +89,19 @@ class SsoAdminServiceTest {service.ensureBootstrapInstance(ACCOUNT_ID, "us-east-1");}+ @Test+ void hasIdentityStoreSelfHealsAfterStorageFactoryClearsInstancesPostReset() {+ // Mirrors EmulatorInfoController.performReset(): every Resettable.clear() (including+ // this service's, which re-seeds the bootstrap instance) runs, then+ // StorageFactory.clearAll() wipes every backing store again, including `instances`.+ service.clear();+ instances.clear();+ assertTrue(instances.get(ACCOUNT_ID).isEmpty());++ assertTrue(service.hasIdentityStore(service.getIdentityStoreId()));+ assertTrue(instances.get(ACCOUNT_ID).isPresent());+ }+@Testvoid createTrustedTokenIssuerPersistsOidcConfigurationAndSupportsIdempotency() {ObjectNode request = trustedTokenIssuerRequest("IssuerOne", "tti-token-one");