mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 06:00:46 -05:00
b2bdb2bbe982cada7bb461ff41ea81903958b3e2
8
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
17c40cecbd |
fix(cognito): reject token validity outside AWS's limits (#5160)
* fix(cognito): reject token validity outside AWS's limits CreateUserPoolClient and UpdateUserPoolClient accepted any positive token validity, so a client with one-minute access and ID tokens, or a 20-minute refresh token, worked locally and failed on deploy. AWS allows access and ID tokens between 5 minutes and 1 day and refresh tokens between 60 minutes and 3,650 days, in each token's TokenValidityUnits unit (hours for access and ID tokens, days for refresh tokens, by default). A client outside them now fails with InvalidParameterException "Invalid range for token validity.", the message AWS returns. floci.services.cognito.enforce-token-validity-limits (env FLOCI_SERVICES_COGNITO_ENFORCE_TOKEN_VALIDITY_LIMITS, default true) turns the check off for tests that want tokens shorter than AWS allows. * test(scheduler): start recurring test schedules in the future Since #5610 a rate schedule's first occurrence is its creation time, so a schedule is due the moment it exists. The application's own dispatcher keeps ticking every 10 seconds during @QuarkusTest and sees every schedule, so a tick that lands between CreateSchedule and the test's own dispatcher fires the schedule once more than the test expects. Four tests create an enabled rate(1 minute) schedule and count exact deliveries: recurringScheduleStartsOneExecutionPerOccurrence, stepFunctionsDeleteScheduleStopsFutureOccurrence, rateScheduleDeliversEachOccurrenceWithItsScheduledTime and executionIdsDifferBetweenOccurrences. They now create the schedule through SchedulerTestHarness.createRecurringSchedule, which sets a StartDate a day ahead, and tick past it on their scoped dispatcher. The application's dispatcher skips a schedule before its StartDate, and the test profile and its tick interval stay as they are. * test(compat): poll OpenSearch domain readiness every 250 ms against Floci OpenSearchTest waited for the domain to finish processing in its own loop that slept 5 s between checks and swallowed InterruptedException. Floci flips Processing to false on its own 3 s readiness poll, so the test could sit up to 5 s past the moment the domain was ready. The wait now goes through TestFixtures.await, polling every 250 ms against Floci and keeping the 5 s cadence against real AWS, with the same 3 minute timeout. * fix(opensearch): run domain containers under an init process so a stop ends them at once The OpenSearch image's entrypoint is a bash script that starts the server as its child instead of exec'ing it. Running as PID 1, that script ignores SIGTERM, so every DeleteDomain, and every shutdown for each domain, waited out the whole 5 s stop timeout before Docker sent SIGKILL. The server never saw the SIGTERM either way. Domain containers now run under Docker's init process, which takes the SIGTERM and ends the container at once. Stopping a ready 2.11.1 container took 5.27 s (exit 137) without it and 0.26 s (exit 143) with it, and DeleteDomain in the compatibility OpenSearchTest took 5.3 s. The two startDomain tests' shared setup moves into one helper, which the new init test uses too. * fix(cognito): keep a RefreshTokenValidity of 0 at 30 days in any unit AWS replaces a RefreshTokenValidity of 0 with "the default value of 30 days". Floci stored the bare number 30 in the client's refresh token unit, so a client with RefreshToken=minutes issued 30-minute refresh tokens. With the token validity limits, any later UpdateUserPoolClient that left the validity alone re-checked that stored 30 minutes and failed with "Invalid range for token validity.", for a client Floci had accepted. A 0 now becomes 30 days in the client's refresh token unit (2592000 seconds, 43200 minutes, 720 hours or 30 days), on create and on update, and the limits check runs on that normalized value. Also imports UUID on a test line that spelled it out in full. * fix(cognito): reset the settings UpdateUserPoolClient omits to their defaults AWS: "If you don't provide a value for an attribute, Amazon Cognito sets it to its default value." The developer guide adds that an update with one parameter "sets all others to a default value". Floci kept the stored value of every setting the request left out, so a client could end up with a combination AWS never produces: an AccessTokenValidity of 60 kept from a minutes client, read in the hours of a units-only update, was refused as out of range, where AWS resets the validity and accepts. CreateUserPoolClient and UpdateUserPoolClient now build their settings in one place, with a new client's default for each one the request omits, and the update copies them onto the stored client. ClientName is the exception: the API documents no default for it, so an update without one keeps the name. The id, the secrets, the dates and the branding are not settings and stay as they are. An explicitly empty list still clears the setting. The AuthSessionValidity tests and the boto3 compatibility test that asserted the old keep-on-omit behaviour now expect the 3-minute default. * test: share one self-signed and one user-cert TLS profile across the TLS integration tests CustomDomainTlsIntegrationTest, TlsEnsureHostIntegrationTest, TlsHttp2HostRoutingIntegrationTest and EcrTlsDataPlaneDockerIntegrationTest each declared a self-signed TLS profile whose static block wrote its own CA-issued leaf before boot, and under @QuarkusTest that leaf is the one served. They now share SelfSignedTlsProfile, which writes one leaf for all four: the SANs TlsConfigSource uses by default, without 127.0.0.1, plus the API Gateway custom domain the HTTP/2 test routes to. The custom domain and ensure-host tests connect by IP and expect a name the leaf doesn't cover yet to be refused, and the JDK falls back to the peer address when the SNI name doesn't match, so a 127.0.0.1 SAN would let those handshakes through. The leaf and its metadata are written fresh every run, which also drops hostnames an earlier run learned at runtime, and the container CA bundle the ECR test relied on is written beside them. TlsIntegrationTest and TlsUserCertIntegrationTest declared the same user-provided certificate setup apart from paths. They share UserCertTlsProfile, which keeps the certificate file carrying its private key, since TlsUserCertIntegrationTest checks /_floci/ca.pem never echoes it. Both profiles live in the config test package, beside every class that uses them and the package-private default SAN list, and expose their paths as compile-time constants, so a test can read them without initializing the profile class and rerunning its static block under the running application. Sharing an application also means no class may leave anything behind for the next. TlsHttp2HostRoutingIntegrationTest now removes the bucket, CloudFront public key, key group and distribution, and the REST API, domain name and base path mapping it creates. EcrTlsDataPlaneDockerIntegrationTest deletes the manifest it pushes, TlsIntegrationTest its queue and TlsUserCertIntegrationTest its parameter. CustomDomainTlsIntegrationTest and TlsEnsureHostIntegrationTest already end with a state reset, which keeps the configured names from the profile's metadata, so neither changes the leaf a later class is served. The ECR test's registry container also outlived every run: keep-running-on-shutdown defaults to true and the test config never overrides it, and the next application to start adopted the container by name, a developer's own Floci registry included. SelfSignedTlsProfile now names it in the run's sidecar namespace, which SidecarContainersProfile exposes for this, and stops it at shutdown. The test checks for Docker through SidecarContainersProfile.requireDockerAndImage, so a registry a killed run left behind is removed like any other abandoned sidecar. Part of #4542. --------- Co-authored-by: Priamo <pgermosen@gmail.com> |
||
|
|
c0cb49facc |
fix(cognito): persist app client AuthSessionValidity (#4481)
* fix(cognito): persist app client AuthSessionValidity * test(cognito): cover session validity through the SDK * fix(cognito): align session validity validation with AWS errors |
||
|
|
06007deea8 |
fix(cognito): default ExplicitAuthFlows to refresh, SRP and custom auth (#4081)
A user pool client created without ExplicitAuthFlows was treated as allowing every auth flow, where AWS defaults such a client to ALLOW_REFRESH_TOKEN_AUTH, ALLOW_USER_SRP_AUTH and ALLOW_CUSTOM_AUTH. USER_PASSWORD_AUTH against a no-list client succeeded on Floci and is refused on AWS. Apply that default at auth time, in the existing gate added by #3974. CreateUserPoolClient, UpdateUserPoolClient and DescribeUserPoolClient keep storing and returning exactly what was normalized, empty when unset, matching AWS: Terraform's Cognito acceptance tests confirm the empty read-back for both an omitted list and an explicit empty one, and materialising the default into storage would fail Terraform apply with an inconsistent-result error. Tests and compatibility fixtures that created a no-list client and then signed in with a flow outside the default now enable that flow on their client. |
||
|
|
61f67cc834 |
fix(cognito): reject unrecognized AuthFlow instead of issuing tokens (#3923)
The default arm of InitiateAuth and AdminInitiateAuth looked the user up by name and issued signed tokens for any AuthFlow value it did not recognize, with no credential check. Reject those values with InvalidParameterException. ADMIN_NO_SRP_AUTH is a valid AdminInitiateAuth flow that previously only worked through that arm, so it now goes through password authentication. |
||
|
|
0a3bc030f6 |
feat(cognito): implement identity provider configuration CRUD (#2858)
* feat(cognito): implement identity provider configuration CRUD CreateIdentityProvider, DescribeIdentityProvider, ListIdentityProviders, UpdateIdentityProvider and DeleteIdentityProvider were unsupported, so infrastructure tooling could not manage a user pool's federated providers. Stores provider configuration alongside the other user pool sub-resources and matches the response and update semantics measured against the live API: - IdpIdentifiers is echoed by create and update only when the request supplied the member, whatever the stored value; describe always returns it - AttributeMapping defaults to username -> sub when the member is absent at create, while an explicitly empty map is stored as given - members a request omits are preserved rather than cleared - a duplicate provider name raises DuplicateProviderException - ListIdentityProviders returns name/type/date summaries, never ProviderDetails Federated sign-in itself is out of scope: Floci has no /oauth2/authorize or /oauth2/idpresponse endpoint, so providers are stored configuration only. * test(cognito): match identity provider exceptions on the SDK error name `rejects.toThrow(/re/)` matches the error message, but the JS SDK maps the wire `__type` onto `error.name` and puts the AWS text in `message`, so the duplicate provider assertion never matched. Assert the name, and pin the enum text with an explicit message matcher. * fix(cognito): delete a pool's identity providers with the pool, and update a copy Two review findings, both reproduced first. DeleteUserPool left provider records behind. A pool recreated on a pinned id (`floci:override-id`) then inherited the dead pool's providers, ProviderDetails client_secret included. Pool deletion now removes them the way it already removes groups. UpdateIdentityProvider mutated the instance the store handed back, so two concurrent updates could interleave into a state matching neither request. It now writes a copy, which makes the losing update simply lose — what AWS does. * fix(cognito): serialise identity provider mutations UpdateIdentityProvider is a read-modify-write: it copies the stored provider, applies only the members the request supplied and writes the whole record back. Two overlapping updates copied the same base, so the later write restored the other's omitted members to their stale values and silently dropped an update. Live Cognito merges omitted members rather than clearing them, and applies that merge atomically, so both updates survive there. One lock now guards every mutating path, since create (check-then-put) and delete (check-then-act) carry the same race, matching the existing identityLinkLock idiom. The regression test runs two writers touching different optional members across 25 rounds; it fails on the first round with the lock reverted. * fix(cognito): guard the pool deletion provider cascade with the same lock DeleteUserPool clears a pool's identity providers outside identityProviderLock, so a create or update interleaving with the cascade could reinstate a provider for a pool that is going away. It now takes the same lock as the mutations it races, closing the last unguarded path in that set. * fix(cognito): recheck the pool under the lock when creating a provider CreateIdentityProvider validated the pool before taking identityProviderLock and never rechecked it, so a DeleteUserPool whose cascade ran in between left the create writing a provider for a pool that no longer exists. It now reasserts the pool inside the lock, immediately before the duplicate check and the write. UpdateIdentityProvider needs no equivalent: the cascade deletes the provider, so its own lookup throws ResourceNotFoundException. The outer validation stays where it is to keep error ordering unchanged for ordinary single-request calls. |
||
|
|
b8f1e22c74 |
feat(cognito): implement log delivery configuration (#2867)
* feat(cognito): implement log delivery configuration SetLogDeliveryConfiguration and GetLogDeliveryConfiguration were unsupported, so a config declaring `aws_cognito_log_delivery_configuration` could not be applied against Floci. The configuration is stored on the user pool and validated the way the live API validates it: - LogLevel accepts ERROR or INFO, EventSource accepts userNotification or userAuthEvents, both reported with AWS's 1-based member path - every entry must name a CloudWatch, Firehose or S3 destination - Set replaces the list rather than merging, so an empty list clears it - Get always returns LogConfigurations, as [] when nothing is configured Floci stores the configuration and delivers nothing: the destination is neither written to nor required to exist, and the pricing-tier gate AWS applies to userAuthEvents is not reproduced. Closes #2855 * fix(cognito): reject a null LogConfigurations instead of clearing the configuration SetLogDeliveryConfiguration treated an omitted, null or wrongly typed LogConfigurations as an empty replacement, so a malformed request returned 200 and erased the pool's stored configuration. AWS rejects all three. An omitted or null member fails validation, and a value of the wrong JSON type fails deserialization: omitted / null -> InvalidParameterException: 1 validation error detected: Value null at 'logConfigurations' failed to satisfy constraint: Member must not be null wrong type -> SerializationException: Expected list or null Also drops two em-dashes from the docs, per AGENTS.md. * fix(cognito): translate malformed LogConfigurations elements the way AWS does A scalar inside the array reached Jackson's convertValue directly, so an IllegalArgumentException escaped as a 500 InternalFailure instead of a client error, and a null element would have failed on the validation loop. AWS answers both without a 500: [1, 2] / ["a string"] -> SerializationException: Expected null [null] -> 200, the null element is dropped Elements are now checked before conversion: nulls are skipped and non-objects raise SerializationException. * fix(cognito): bound LogConfigurations and reject a repeated event source SetLogDeliveryConfiguration validated each element but never checked the list itself, so a request with three or more well-formed configurations, or two naming the same event source, was accepted and stored where AWS rejects it. Measured against Cognito in ap-southeast-1: 3 well-formed configs InvalidParameterException, length constraint on 'logConfigurations', max 2 2 duplicate sources InvalidParameterException, "appear more then once" 3 configs, one bad enum 2 validation errors, the length one reported first unknown pool, bad enum the validation error, not ResourceNotFoundException 0 configs 200 OK The shape checks now run before the pool lookup, matching that last row, and collect every violation into one message instead of throwing on the first. The duplicate and missing-destination complaints share one message with the missing-destination clause first, and each event source is named once however many configurations carry it, as measured. "more then once" is the service's own spelling, kept so the message matches. The length message embeds the request model's toString, which the emulator now reproduces for all three destination shapes and for an absent destination. |
||
|
|
1cccf43f7b |
feat(cognito): include all standard attributes in DescribeUserPool Schema (#642)
* feat(cognito): include all standard attributes in DescribeUserPool SchemaAttributes AWS Cognito always returns all 20 standard OIDC attributes (sub, name, email, phone_number, etc.) in SchemaAttributes when describing a user pool, even if none were explicitly configured. Floci was returning only what was passed in Schema during creation. Adds CognitoStandardAttributes with the full default set and a merge() helper that overlays explicit schema overrides and appends custom: attributes after the standard ones. * test(cognito): add compat tests for standard SchemaAttributes across all SDKs Adds DescribeUserPool SchemaAttributes coverage to all compatibility test suites (AWS CLI/bats, Go, Java, Node, Python, Rust), verifying that all 20 standard OIDC attributes are returned and that sub is required and immutable. |
||
|
|
eeefb729c4 |
test: move compatibility tests into this repo (#225)
* test: move compatibility tests into this repo * fix: add StatisticValues parsing to CloudWatchMetricsJsonHandler * fix: add missing required abstract methods to EmulatorConfig in EventBridgeSchedulerIntegrationTest * test: add sdk tests for multipart S3 copy coverage * fix: cover and fix smithy cbor and multipart s3 copy regressions * test: migrate more test coverage to new folder * test: add missing ec2 expectation in healthcheck test * docs: update READMEs in `./compatibility-tests` |