Skip to content

test(auth): add integration tests for password-based authentication at connection time #487

Description

@currantw

Describe the feature

There are currently no integration tests that verify connecting to a password-protected server at connection time using ServerCredentials. The existing UpdateConnectionPasswordTests only test the dynamic password update flow (connecting without a password first, then setting/clearing one). This leaves the initial AUTH handshake during connection establishment untested.

The ServerCredentials class has two password-based constructors:

  • ServerCredentials(string password) — password only (authenticates as default user)
  • ServerCredentials(string? username, string password) — username + password (authenticates as a specific ACL user)

Neither is exercised in any integration test.

Use Case

Password-based authentication is the most common authentication mode for Valkey/Redis. Without tests covering initial connection auth, regressions in the AUTH handshake (or credential passing to glide-core) could go undetected.

Proposed Solution

Add a new integration test class (e.g., PasswordAuthTests) with the following test cases, each parameterized for both standalone and cluster modes:

  1. Connect with correct password — succeeds
  2. Connect with wrong password — fails with expected exception
  3. Connect without credentials when server requires a password — fails with expected exception
  4. Connect with correct username + password — succeeds
  5. Connect with correct username + wrong password — fails with expected exception
  6. Connect with wrong username + correct password — fails with expected exception

Acknowledgements

  • I may be able to implement this feature request
  • This feature might cause a breaking change

Related

  • tests/Valkey.Glide.IntegrationTests/UpdateConnectionPasswordTests.cs — related but only covers dynamic password updates
  • tests/Valkey.Glide.IntegrationTests/IamAuthTests.cs — tests IAM auth path, not password auth
  • sources/Valkey.Glide/ServerCredentials.cs — the class under test

Additional Information

  • The test server utilities (ServerFixture, Server) already support SetPasswordAsync / ClearPasswordAsync, which can be used to configure the server before connecting.
  • ACL user tests will need to create/remove ACL users on the server (e.g., via ACL SETUSER / ACL DELUSER).
  • Tests that mutate server auth state should disable parallel execution to avoid interfering with other tests.

Metadata

Metadata

Assignees

Labels

testsUnit tests, integration tests, or test utilities

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions