test_redis_keys.py 682 B

12345678910111213141516
  1. import pytest
  2. from zbt.infrastructure.redis.keys import RedisKeyBuilder
  3. def test_redis_key_builder_uses_stage_prefix_and_rejects_unsafe_segments() -> None:
  4. keys = RedisKeyBuilder("ins:s3:")
  5. assert keys.auth_otp("mobile-sha256") == "ins:s3:auth:otp:mobile-sha256"
  6. assert keys.auth_session("session-01") == "ins:s3:auth:session:session-01"
  7. assert keys.agent_run_events("run-01") == "ins:s3:agent:run:run-01:events"
  8. assert keys.payment_lock("payment-01") == "ins:s3:lock:payment:payment-01"
  9. assert keys.worker_lock("refund") == "ins:s3:worker:lock:refund"
  10. with pytest.raises(ValueError, match="Redis Key"):
  11. keys.auth_session("other:namespace")