| 123456789101112131415 |
- import pytest
- from zbt.infrastructure.redis.keys import RedisKeyBuilder
- def test_redis_key_builder_uses_stage_prefix_and_rejects_unsafe_segments() -> None:
- keys = RedisKeyBuilder("ins:s1:")
- assert keys.auth_otp("mobile-sha256") == "ins:s1:auth:otp:mobile-sha256"
- assert keys.auth_session("session-01") == "ins:s1:auth:session:session-01"
- assert keys.agent_run_events("run-01") == "ins:s1:agent:run:run-01:events"
- assert keys.payment_lock("payment-01") == "ins:s1:lock:payment:payment-01"
- with pytest.raises(ValueError, match="Redis Key"):
- keys.auth_session("other:namespace")
|