Arag / tests /unit /test_redis_url.py
AuthorBot
P0 security: async backup, widget CORS, Redis auth.
937692a
Raw
History Blame Contribute Delete
694 Bytes
"""Unit tests for Redis URL auth helper (R-055)."""
from app.core.redis_url import redis_url_has_auth, redis_url_with_auth
class TestRedisUrlWithAuth:
def test_injects_password(self):
url = redis_url_with_auth("redis://localhost:6379/0", "secret")
assert url == "redis://:secret@localhost:6379/0"
assert redis_url_has_auth(url)
def test_skips_when_password_present(self):
url = "redis://:existing@localhost:6379/0"
assert redis_url_with_auth(url, "new") == url
def test_empty_password_unchanged(self):
url = "redis://localhost:6379/0"
assert redis_url_with_auth(url, "") == url
assert not redis_url_has_auth(url)