Add active API key count to profile response - #651
Merged
Merged
Conversation
There was a problem hiding this comment.
Important
The profile reports fewer active API keys than the creation limit counts when keys have expired, so users can be told they have capacity but still be rejected when creating a key.
Reviewed changes: Reviewed the optional profile API key count, its OpenAPI schema, and handler tests against the key lifecycle and the mobile consumer contract.
- Profile response: Appends a nullable count and queries unrevoked, unexpired keys owned by the profile user.
- Contract and tests: Regenerates OpenAPI and exercises count filtering and JSON serialization; updates the color scheme test fixture for the new dependency.
GPT Sol | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes: Re-reviewed the active API key creation limit and its tests since the previous Pullfrog review.
- Aligned quota: Shared the active-key predicate between the profile count and the creation limit, so expired keys no longer consume capacity.
- Covered key states: Added exact-count tests for active, expired, revoked, and other-account keys at the creation limit.
GPT Sol | 𝕏
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Change
Adds optional
activeApiKeyCounttoProfileResponseinsrc/Orbit.Application/Profile/Queries/GetProfileQuery.cs. The profile handler uses the existing API key repository count operation with the authenticated profile user ID. It excludes revoked keys and keys whose UTC expiry has passed. The API key list and its emailed code requirement remain in place.Regenerates
src/Orbit.Api/openapi.jsonfor the appended response field. Updates the profile handler tests intests/Orbit.Application.Tests/Queries/Profile/GetProfileQueryHandlerTests.csand the constructor setup intests/Orbit.Application.Tests/Behaviors/ColorSchemeRoundTripTests.cs.The count query runs in the database and returns only an integer. The profile response exposes no API key name, prefix, secret, or date.
An active key is one that is neither revoked nor expired. One shared predicate defines it for both the profile count and the five-key creation limit, so expired keys no longer block creating a new key.
Links thomasluizon/orbit-tickets#919.
Assumptions
Test evidence
dotnet test tests/Orbit.Application.Tests --filter FullyQualifiedName~GetProfileQueryHandlerTests.Handle_UserFound_ReturnsProfile --no-restoreexited 0 with the existing test before the change.dotnet test tests/Orbit.Application.Tests --filter FullyQualifiedName~GetProfileQueryHandlerTests --verbosity quietpassed all 34 tests, including zero, one, and several active keys with revoked, expired, and foreign account keys excluded.dotnet build Orbit.slnx --verbosity quietcompleted with zero errors.dotnet test --verbosity quietpassed all 8,068 tests.dotnet test tests/Orbit.Application.Tests --filter 'FullyQualifiedName~CreateApiKeyCommandHandlerTests|FullyQualifiedName~GetProfileQueryHandlerTests.Handle_CountsOnlyCallersActiveApiKeys' --no-restoreexited0; 10 passed.Handle_CountsOnlyCallersActiveKeysAgainstLimittheory:dotnet test tests/Orbit.Application.Tests --filter 'FullyQualifiedName~CreateApiKeyCommandHandlerTests.Handle_CountsOnlyCallersActiveKeysAgainstLimit' --no-restoreexited1before the fix. All four cases failed because expired keys were counted.0; 14 passed.env -u LANG LC_ALL=en_US.UTF-8 dotnet build Orbit.slnxexited0with zero errors.dotnet test Orbit.slnxexited0; 8,072 tests passed.Manual steps
None.