mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2025-01-25 18:26:34 +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.token import Token
|
||||||
from selfprivacy_api.models.tokens.recovery_key import RecoveryKey
|
from selfprivacy_api.models.tokens.recovery_key import RecoveryKey
|
||||||
from selfprivacy_api.models.tokens.new_device_key import NewDeviceKey
|
from selfprivacy_api.models.tokens.new_device_key import NewDeviceKey
|
||||||
|
from selfprivacy_api.repositories.tokens.exceptions import TokenNotFound
|
||||||
|
|
||||||
TOKENS_PREFIX = "token_repo:tokens:"
|
TOKENS_PREFIX = "token_repo:tokens:"
|
||||||
NEW_DEVICE_KEY_REDIS_KEY = "token_repo:new_device_key"
|
NEW_DEVICE_KEY_REDIS_KEY = "token_repo:new_device_key"
|
||||||
|
@ -40,6 +41,10 @@ class RedisTokensRepository(AbstractTokensRepository):
|
||||||
key = RedisTokensRepository._token_redis_key(input_token)
|
key = RedisTokensRepository._token_redis_key(input_token)
|
||||||
r.delete(key)
|
r.delete(key)
|
||||||
|
|
||||||
|
def reset(self):
|
||||||
|
for token in self.get_tokens():
|
||||||
|
self.delete_token(token)
|
||||||
|
|
||||||
def get_recovery_key(self) -> Optional[RecoveryKey]:
|
def get_recovery_key(self) -> Optional[RecoveryKey]:
|
||||||
"""Get the recovery key"""
|
"""Get the recovery key"""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
|
@ -159,8 +159,7 @@ def empty_json_repo(empty_keys):
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def empty_redis_repo():
|
def empty_redis_repo():
|
||||||
repo = RedisTokensRepository()
|
repo = RedisTokensRepository()
|
||||||
for token in repo.get_tokens():
|
repo.reset()
|
||||||
repo.delete_token(token)
|
|
||||||
assert repo.get_tokens() == []
|
assert repo.get_tokens() == []
|
||||||
return repo
|
return repo
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue