fix(identitystore): self-heal the bootstrap identity store on hasIdentityStore (#3387)

EmulatorInfoController.performReset() runs every Resettable.clear() (which
re-seeds SsoAdminService's default d-9067f2a3c1 instance) before calling
StorageFactory.clearAll(), which wipes the `instances` backend again right
after. Once any test in the same JVM fork hits /state/reset or /state/nuke,
the default identity store never comes back, so every later SCIM request's
hasIdentityStore check 401s for the rest of that fork — this is why
ScimIntegrationTest passes in isolation but fails in the full suite (#3386).

hasIdentityStore now self-heals the same way listInstances() already does,
by ensuring the bootstrap instance exists before checking.
This commit is contained in:
Priamo Germosen authored and GitHub committed 2026-09-10 21:07:00 -04:00
1 parent 051a2f09db
commit b87ee5bd4a
2 files changed
+19 -1

No files matched your search

@@ -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;
@@ -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;
@BeforeEach
void 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());
}
@Test
void createTrustedTokenIssuerPersistsOidcConfigurationAndSupportsIdempotency() {
ObjectNode request = trustedTokenIssuerRequest("IssuerOne", "tti-token-one");