mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-18 16:39:13 +00:00
feat(tokens-repo): reset function
This commit is contained in:
parent
9ffd67fa19
commit
95e200bfc5
|
@ -11,6 +11,7 @@ from selfprivacy_api.utils.redis_pool import RedisPool
|
|||
from selfprivacy_api.models.tokens.token import Token
|
||||
from selfprivacy_api.models.tokens.recovery_key import RecoveryKey
|
||||
from selfprivacy_api.models.tokens.new_device_key import NewDeviceKey
|
||||
from selfprivacy_api.repositories.tokens.exceptions import TokenNotFound
|
||||
|
||||
TOKENS_PREFIX = "token_repo:tokens:"
|
||||
NEW_DEVICE_KEY_REDIS_KEY = "token_repo:new_device_key"
|
||||
|
@ -40,6 +41,10 @@ class RedisTokensRepository(AbstractTokensRepository):
|
|||
key = RedisTokensRepository._token_redis_key(input_token)
|
||||
r.delete(key)
|
||||
|
||||
def reset(self):
|
||||
for token in self.get_tokens():
|
||||
self.delete_token(token)
|
||||
|
||||
def get_recovery_key(self) -> Optional[RecoveryKey]:
|
||||
"""Get the recovery key"""
|
||||
raise NotImplementedError
|
||||
|
|
|
@ -159,8 +159,7 @@ def empty_json_repo(empty_keys):
|
|||
@pytest.fixture
|
||||
def empty_redis_repo():
|
||||
repo = RedisTokensRepository()
|
||||
for token in repo.get_tokens():
|
||||
repo.delete_token(token)
|
||||
repo.reset()
|
||||
assert repo.get_tokens() == []
|
||||
return repo
|
||||
|
||||
|
|
Loading…
Reference in a new issue