mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
* feat(iam): support account aliases Implement ListAccountAliases, CreateAccountAlias and DeleteAccountAlias. An account holds at most one alias: creating a second returns EntityAlreadyExists, and deleting requires the current alias by name so a stale value cannot silently clear it. FLOCI_SERVICES_IAM_ACCOUNT_ALIAS seeds an alias at startup for callers that expect to read one without creating it first. Closes #2101 * fix(iam): make account alias create and delete atomic Concurrent CreateAccountAlias calls could all pass the emptiness check and write, reporting success to every caller while keeping only one value. Unlike a named resource, where racing creates carry the same name and either winner is equivalent, racing alias creates carry different values, so a loser is told their alias was set when another is stored. Guard the check-then-write on both create and delete, and cover it with a concurrency trial asserting exactly one winner. Also track the alias created by the bats delete case in ACCOUNT_ALIAS so teardown clears it if the test fails midway. * fix(iam): match verified AWS account alias semantics and unbreak the test fixture IamServiceTestHelper resolves the package-private IamService constructor reflectively against a hardcoded parameter list, so the extra storage backend broke it at run time with no compile-time signal. Every test using that fixture errored, and one of them hangs on a socket read rather than failing, which is what exhausted the CI job. Extend both lookups to the new arity. Checking the error message against a live AWS account showed the operation itself was modelled wrongly: CreateAccountAlias does not reject a second alias, it replaces the current one. EntityAlreadyExists means the requested name is taken, which for a single-account store is only the alias already held. Create now replaces and rejects just that case, which also makes the message name the alias the caller asked for. DeleteAccountAlias applies the same pattern constraint as create, so a malformed value is a ValidationError. Concurrent creates therefore all succeed with last-write-wins; the trial now asserts the store settles on one of the requested values. Seeding logs when it skips because an alias is already stored, which is otherwise invisible under persistent storage. * fix(test): repair iam.bats after the merge fused test bodies Resolving the merge by keeping both sides concatenated the OIDC and account alias cases as text, which left the create_oidc_provider helper nested inside an alias test and dropped a closing brace, so bats could not parse the file and produced no report at all. Rebuild it from main plus the alias cases, with the alias tracked in setup and teardown. * test(iam): pin account alias isolation, and document the two-dash rule The alias is the only IAM entity keyed by a constant rather than a caller-supplied name, so every account shares one storage key and the separation rests entirely on AccountAwareStorageBackend prefixing. Every integration test here signs as the same account, so that prefixing was never exercised for aliases. The new case pins it: handing both services the store unwrapped fails it. The docs still described the pre-fix constraint. They now carry the consecutive-hyphen rule and note that the ValidationError message, reproduced from AWS verbatim, does not itself mention it. --------- Co-authored-by: Michal Schreiber <michal.p.schreiber@gmail.com> Co-authored-by: Michal Schreiber <michal.schreiber@benefitsystems.pl>