Repository navigation
feat(serverpod_test): Support Object userIdentifier in AuthenticationOverride, matching AuthenticationInfo - #3672
Conversation
📝 WalkthroughWalkthroughThe changes update the Changes
Sequence Diagram(s)sequenceDiagram
participant Test as Test Case
participant Builder as TestSessionBuilder
participant AuthOverride as AuthenticationOverride
participant AuthInfo as AuthenticationInfo
Test->>Builder: buildSession(authenticationInfo(userIdentifier, scopes))
Builder->>AuthOverride: authenticationInfo(userIdentifier, scopes)
AuthOverride->>AuthInfo: create AuthenticationInfo(userIdentifier, scopes)
AuthInfo-->>Builder: AuthenticationInfo instance
Builder-->>Test: Session with AuthenticationInfo
Test->>AuthInfo: Access userId or userIdentifier
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms (58)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
packages/serverpod_test/lib/src/test_session_builder.dart (2)
7-14: Doc comment out-of-sync with signatureThe sentence still refers to a singular
scope, while the parameter is nowSet<Scope> scopes. Minor, but worth fixing to avoid confusion.-/// Sets the session to be authenticated with the provided `userIdentifier` and `scope`. +/// Sets the session to be authenticated with the provided `userIdentifier` and `scopes`.
111-119: Update constructor doc to match new parameter name
userIdentifierreplaceduserId, yet the preceding comment line 110 doesn’t mention it. Aligning the doc keeps the API self-describing.-/// Creates a new AuthenticationInfoOverride with the provided authentication info. +/// Creates a new AuthenticationInfoOverride for the supplied `userIdentifier`, `scopes`, and optional `authId`.
…ionOverride`, matching `AuthenticationInfo`
7dbef1d to
c36ef0a
Compare
SandPod
left a comment
There was a problem hiding this comment.
Please add a test for this change.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (3)
packages/serverpod_test/test/test_session_builder_test.dart (3)
7-10: Avoid brittle hard-cast – assert type first or leverage pattern matching.Casting the return value with
as AuthenticationInfoOverridewill throw at runtime if the factory implementation ever changes.
A safer pattern:final authOverride = AuthenticationOverride.authenticationInfo(123, {}); expect(authOverride, isA<AuthenticationInfoOverride>()); final authenticationOverride = authOverride as AuthenticationInfoOverride;or, in Dart ≥3.0, use pattern matching:
switch (AuthenticationOverride.authenticationInfo(123, {}) ) { case AuthenticationInfoOverride(:var authenticationInfo): // use authenticationInfo here }
27-33: Nit: consolidate repetitive setup via parameterised test data.The two
groupblocks differ only in the identifier type. You could drive both scenarios from a single list of tuples:for (final (description, identifier, expectedUserId, expectThrows) in [ ('int', 123, 123, false), ('UUID', UuidValue.fromString(uuidString), null, true), ]) { … }This reduces duplication and keeps future cases easy to add.
35-42: Explicitly assert the thrownFormatExceptionmessage (optional).Verifying just the exception type is fine, but checking the message ensures the failure mode remains user-friendly if the implementation changes.
expect( () => authenticationOverride.authenticationInfo.userId, throwsA(predicate((e) => e is FormatException && e.message.contains('non-integer userIdentifier'))) );
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/serverpod_test/lib/src/test_session_builder.dart(3 hunks)packages/serverpod_test/test/test_session_builder_test.dart(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/serverpod_test/lib/src/test_session_builder.dart
⏰ Context from checks skipped due to timeout of 90000ms (58)
- GitHub Check: Module integration tests in modules/new_serverpod_auth/serverpod_auth_profile/serverpod_auth_profile_server with Flutter 3.24.0
- GitHub Check: Module integration tests in modules/new_serverpod_auth/serverpod_auth_session/serverpod_auth_session_server with Flutter 3.32.1
- GitHub Check: Module integration tests in modules/new_serverpod_auth/serverpod_auth_session/serverpod_auth_session_server with Flutter 3.24.0
- GitHub Check: Module integration tests in modules/serverpod_auth/serverpod_auth_server with Flutter 3.24.0
- GitHub Check: Module integration tests in modules/new_serverpod_auth/serverpod_auth_email_account/serverpod_auth_email_account_server with Flutter 3.32.1
- GitHub Check: Module integration tests in modules/serverpod_auth/serverpod_auth_server with Flutter 3.32.1
- GitHub Check: Module integration tests in modules/new_serverpod_auth/serverpod_auth_profile/serverpod_auth_profile_server with Flutter 3.32.1
- GitHub Check: Module integration tests in tests/serverpod_test_nonvector/serverpod_test_nonvector_server with Flutter 3.32.1
- GitHub Check: Module integration tests in modules/new_serverpod_auth/serverpod_auth_jwt/serverpod_auth_jwt_server with Flutter 3.24.0
- GitHub Check: Module integration tests in modules/new_serverpod_auth/serverpod_auth_jwt/serverpod_auth_jwt_server with Flutter 3.32.1
- GitHub Check: Module integration tests in tests/serverpod_test_module/serverpod_test_module_server with Flutter 3.32.1
- GitHub Check: Module integration tests in tests/serverpod_test_nonvector/serverpod_test_nonvector_server with Flutter 3.24.0
- GitHub Check: Module integration tests in modules/new_serverpod_auth/serverpod_auth_email_account/serverpod_auth_email_account_server with Flutter 3.24.0
- GitHub Check: Bootstrap tests (3.32.1, windows-latest, tests/bootstrap_project)
- GitHub Check: Module integration tests in tests/serverpod_test_module/serverpod_test_module_server with Flutter 3.24.0
- GitHub Check: Bootstrap tests (3.32.1, ubuntu-latest, tests/bootstrap_project)
- GitHub Check: Migration e2e tests (3.32.1)
- GitHub Check: Bootstrap tests (3.24.0, ubuntu-latest, tests/bootstrap_project)
- GitHub Check: CLI e2e tests (3.32.1, ubuntu-latest, tests/serverpod_cli_e2e_test)
- GitHub Check: CLI e2e tests (3.24.0, ubuntu-latest, tests/serverpod_cli_e2e_test)
- GitHub Check: Unit tests Web (3.32.1, windows-latest)
- GitHub Check: Serverpod integration tests (server) (3.32.1)
- GitHub Check: Migration e2e tests (3.24.0)
- GitHub Check: Unit tests Web (3.24.0, windows-latest)
- GitHub Check: Flutter unit tests (3.32.1, ubuntu-latest, packages/serverpod_flutter)
- GitHub Check: Bootstrap tests (3.24.0, windows-latest, tests/bootstrap_project)
- GitHub Check: Flutter unit tests (3.24.0, windows-latest, packages/serverpod_flutter)
- GitHub Check: Flutter unit tests (3.32.1, windows-latest, packages/serverpod_flutter)
- GitHub Check: Unit tests Web (3.32.1, ubuntu-latest)
- GitHub Check: Flutter unit tests (3.24.0, ubuntu-latest, packages/serverpod_flutter)
- GitHub Check: Serverpod integration tests (server) (3.24.0)
- GitHub Check: Version change test
- GitHub Check: Unit tests Web (3.24.0, ubuntu-latest)
- GitHub Check: Serverpod integration tests (3.32.1, packages/serverpod_shared)
- GitHub Check: Serverpod concurrent integration tests (server) (3.32.1)
- GitHub Check: Serverpod E2E IO tests (3.32.1)
- GitHub Check: Serverpod concurrent integration tests (server) (3.24.0)
- GitHub Check: Serverpod integration tests (3.24.0, packages/serverpod_shared)
- GitHub Check: Serverpod E2E web tests (3.32.1)
- GitHub Check: Serverpod E2E web tests (3.24.0)
- GitHub Check: Serverpod E2E IO tests (3.24.0)
- GitHub Check: Serverpod integration tests (flutter)
- GitHub Check: Unit tests IO (3.32.1, windows-latest)
- GitHub Check: Unit tests IO (3.32.1, ubuntu-latest)
- GitHub Check: Unit tests IO (3.24.0, windows-latest)
- GitHub Check: Unit tests IO (3.24.0, ubuntu-latest)
- GitHub Check: update pubspecs (3.24.0)
- GitHub Check: dart analyze downgrade (3.32.1, windows-latest)
- GitHub Check: update pubspecs (3.32.1)
- GitHub Check: dart analyze downgrade (3.24.0, ubuntu-latest)
- GitHub Check: serverpod generate (3.24.0)
- GitHub Check: dart analyze latest (3.32.1, ubuntu-latest)
- GitHub Check: dart analyze downgrade (3.32.1, ubuntu-latest)
- GitHub Check: dart analyze (3.24.0, ubuntu-latest)
- GitHub Check: serverpod generate (3.32.1)
- GitHub Check: dart analyze downgrade (3.24.0, windows-latest)
- GitHub Check: dart analyze latest (3.32.1, windows-latest)
- GitHub Check: dart analyze (3.24.0, windows-latest)
🔇 Additional comments (1)
packages/serverpod_test/test/test_session_builder_test.dart (1)
1-3: Imports look good.The selected imports give the test access to all required types (
AuthenticationOverride,AuthenticationInfoOverride,UuidValue,testhelpers).
No missing or unused imports detected.
@SandPod Done. I had to expose the low-level class though (for testing). I just did a minimal update, though I think we could also make this a proper Let me know if I should further refactor this or if we better leave it as is for now. |
SandPod
left a comment
There was a problem hiding this comment.
Can this implementation be aligned to validate the actual code?
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/serverpod_test/lib/src/test_session_builder.dart(2 hunks)tests/serverpod_test_server/test_integration/test_tools/test_session_builder_test.dart(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/serverpod_test/lib/src/test_session_builder.dart
⏰ Context from checks skipped due to timeout of 90000ms (58)
- GitHub Check: Bootstrap tests (3.32.1, ubuntu-latest, tests/bootstrap_project)
- GitHub Check: Bootstrap tests (3.32.1, windows-latest, tests/bootstrap_project)
- GitHub Check: Module integration tests in modules/new_serverpod_auth/serverpod_auth_email_account/serverpod_auth_email_account_server with Flutter 3.24.0
- GitHub Check: Serverpod integration tests (flutter)
- GitHub Check: CLI e2e tests (3.24.0, ubuntu-latest, tests/serverpod_cli_e2e_test)
- GitHub Check: Module integration tests in tests/serverpod_test_nonvector/serverpod_test_nonvector_server with Flutter 3.24.0
- GitHub Check: CLI e2e tests (3.32.1, ubuntu-latest, tests/serverpod_cli_e2e_test)
- GitHub Check: Version change test
- GitHub Check: Serverpod concurrent integration tests (server) (3.24.0)
- GitHub Check: Migration e2e tests (3.32.1)
- GitHub Check: Bootstrap tests (3.24.0, ubuntu-latest, tests/bootstrap_project)
- GitHub Check: Migration e2e tests (3.24.0)
- GitHub Check: Module integration tests in modules/serverpod_auth/serverpod_auth_server with Flutter 3.32.1
- GitHub Check: dart analyze downgrade (3.32.1, ubuntu-latest)
- GitHub Check: Serverpod concurrent integration tests (server) (3.32.1)
- GitHub Check: Module integration tests in modules/serverpod_auth/serverpod_auth_server with Flutter 3.24.0
- GitHub Check: Module integration tests in tests/serverpod_test_module/serverpod_test_module_server with Flutter 3.24.0
- GitHub Check: Module integration tests in modules/new_serverpod_auth/serverpod_auth_profile/serverpod_auth_profile_server with Flutter 3.32.1
- GitHub Check: Module integration tests in modules/new_serverpod_auth/serverpod_auth_jwt/serverpod_auth_jwt_server with Flutter 3.32.1
- GitHub Check: serverpod generate (3.32.1)
- GitHub Check: Bootstrap tests (3.24.0, windows-latest, tests/bootstrap_project)
- GitHub Check: Unit tests Web (3.32.1, windows-latest)
- GitHub Check: Module integration tests in modules/new_serverpod_auth/serverpod_auth_session/serverpod_auth_session_server with Flutter 3.24.0
- GitHub Check: Module integration tests in tests/serverpod_test_nonvector/serverpod_test_nonvector_server with Flutter 3.32.1
- GitHub Check: Module integration tests in modules/new_serverpod_auth/serverpod_auth_profile/serverpod_auth_profile_server with Flutter 3.24.0
- GitHub Check: Module integration tests in modules/new_serverpod_auth/serverpod_auth_session/serverpod_auth_session_server with Flutter 3.32.1
- GitHub Check: Module integration tests in modules/new_serverpod_auth/serverpod_auth_email_account/serverpod_auth_email_account_server with Flutter 3.32.1
- GitHub Check: Module integration tests in tests/serverpod_test_module/serverpod_test_module_server with Flutter 3.32.1
- GitHub Check: Unit tests Web (3.24.0, windows-latest)
- GitHub Check: Module integration tests in modules/new_serverpod_auth/serverpod_auth_jwt/serverpod_auth_jwt_server with Flutter 3.24.0
- GitHub Check: update pubspecs (3.24.0)
- GitHub Check: Unit tests Web (3.32.1, ubuntu-latest)
- GitHub Check: Unit tests Web (3.24.0, ubuntu-latest)
- GitHub Check: dart analyze (3.24.0, ubuntu-latest)
- GitHub Check: update pubspecs (3.32.1)
- GitHub Check: Flutter unit tests (3.32.1, windows-latest, packages/serverpod_flutter)
- GitHub Check: dart analyze downgrade (3.32.1, windows-latest)
- GitHub Check: Serverpod E2E IO tests (3.24.0)
- GitHub Check: serverpod generate (3.24.0)
- GitHub Check: dart analyze downgrade (3.24.0, windows-latest)
- GitHub Check: Unit tests IO (3.24.0, windows-latest)
- GitHub Check: dart analyze downgrade (3.24.0, ubuntu-latest)
- GitHub Check: Flutter unit tests (3.32.1, ubuntu-latest, packages/serverpod_flutter)
- GitHub Check: dart analyze latest (3.32.1, ubuntu-latest)
- GitHub Check: Flutter unit tests (3.24.0, windows-latest, packages/serverpod_flutter)
- GitHub Check: Serverpod integration tests (server) (3.24.0)
- GitHub Check: Unit tests IO (3.32.1, ubuntu-latest)
- GitHub Check: Unit tests IO (3.24.0, ubuntu-latest)
- GitHub Check: Unit tests IO (3.32.1, windows-latest)
- GitHub Check: Flutter unit tests (3.24.0, ubuntu-latest, packages/serverpod_flutter)
- GitHub Check: dart analyze latest (3.32.1, windows-latest)
- GitHub Check: Serverpod integration tests (3.32.1, packages/serverpod_shared)
- GitHub Check: Serverpod integration tests (3.24.0, packages/serverpod_shared)
- GitHub Check: dart analyze (3.24.0, windows-latest)
- GitHub Check: Serverpod E2E web tests (3.24.0)
- GitHub Check: Serverpod integration tests (server) (3.32.1)
- GitHub Check: Serverpod E2E IO tests (3.32.1)
- GitHub Check: Serverpod E2E web tests (3.32.1)
🔇 Additional comments (1)
tests/serverpod_test_server/test_integration/test_tools/test_session_builder_test.dart (1)
47-50: Verify thatUuidValueis in the re-export chain
UuidValue.fromStringcompiles only ifUuidValueis re-exported bypackage:serverpod/serverpod.dart.
If not, add an explicit import:import 'package:serverpod_serialization/serverpod_serialization.dart' show UuidValue;Please confirm with a quick build or grep that the symbol is reachable.
This reverts commit 8e2e6f7.
b1bfe63 to
b38b49b
Compare
Summary by CodeRabbit