test_redis_keys.py 613 B

123456789101112131415
  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:s2:")
  5. assert keys.auth_otp("mobile-sha256") == "ins:s2:auth:otp:mobile-sha256"
  6. assert keys.auth_session("session-01") == "ins:s2:auth:session:session-01"
  7. assert keys.agent_run_events("run-01") == "ins:s2:agent:run:run-01:events"
  8. assert keys.payment_lock("payment-01") == "ins:s2:lock:payment:payment-01"
  9. with pytest.raises(ValueError, match="Redis Key"):
  10. keys.auth_session("other:namespace")