Skip to content

test(redis): fix the security handshake mock for redis-py 8.2 - #3393

Merged
borisalekseev merged 2 commits into
mainfrom
fix/redis-security-mock-transport
Nov 24, 2026
Merged

borisalekseev merged 2 commits into
mainfrom
fix/redis-security-mock-transport

Conversation

@Lancetnik

Copy link
Copy Markdown
Member

Summary

redis-py 8.2 checks whether the asyncio transport is closing before writing a command. The Redis security examples used a bare MagicMock, so the client treated the connection as closed before it could authenticate. The TLS-only test passed even when its ping returned false. Failing CI job

The test transport now stays open and feeds replies to a real StreamReader as redis-py sends commands.

TLS                HELLO 3 → protocol 3, PING → PONG
TLS + credentials  AUTH or HELLO ... AUTH → WRONGPASS

The tests assert a successful ping and an authentication error using the client's default protocol.

Evidence

Ran both cases in tests/docs/redis/test_security.py on Python 3.13.

redis-py main This branch
5.3.1 2 passed 2 passed
8.1.0 2 passed 2 passed
8.2.0 Plaintext test raised ConnectionError 2 passed

Ruff and mypy passed on the changed file. An additional check on 5.0.0 failed on both revisions because FastStream calls Redis.from_pool before opening the connection.

Merge Danger

Reverting this test-only change restores the previous mock.

Codex assisted with the patch and ran the checks above.

Sehat1137
Sehat1137 previously approved these changes Nov 23, 2026
@Sehat1137
Sehat1137 added this pull request to the merge queue Nov 23, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 23, 2026
@Lancetnik
Lancetnik added this pull request to the merge queue Nov 24, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 24, 2026
@Lancetnik
Lancetnik added this pull request to the merge queue Nov 24, 2026
@Lancetnik
Lancetnik removed this pull request from the merge queue due to a manual request Nov 24, 2026
Redis 8.12 refuses to start a cluster with an unauthenticated bus by default. Bind the test nodes to loopback and explicitly allow the local plaintext bus in CI and Compose. Print the container logs if CI times out waiting for the cluster.
@github-actions github-actions Bot added documentation Improvements or additions to documentation github_actions Pull requests that update GitHub Actions code labels Nov 24, 2026
@borisalekseev
borisalekseev added this pull request to the merge queue Nov 24, 2026
Merged via the queue into main with commit 1acf41a Nov 24, 2026
30 checks passed
@borisalekseev
borisalekseev deleted the fix/redis-security-mock-transport branch November 24, 2026 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation github_actions Pull requests that update GitHub Actions code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants