mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-26 14:01:30 +00:00
test(tokens-repo): agnostic recovery keys testing
This commit is contained in:
parent
c86eb8b786
commit
6f400911fc
|
@ -143,7 +143,7 @@ def mock_token_generate(mocker):
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_recovery_key_generate(mocker):
|
def mock_recovery_key_generate(mocker):
|
||||||
mock = mocker.patch(
|
mock = mocker.patch(
|
||||||
"selfprivacy_api.repositories.tokens.json_tokens_repository.RecoveryKey.generate",
|
"selfprivacy_api.models.tokens.recovery_key.RecoveryKey.generate",
|
||||||
autospec=True,
|
autospec=True,
|
||||||
return_value=RecoveryKey(
|
return_value=RecoveryKey(
|
||||||
key="889bf49c1d3199d71a2e704718772bd53a422020334db051",
|
key="889bf49c1d3199d71a2e704718772bd53a422020334db051",
|
||||||
|
@ -156,7 +156,7 @@ def mock_recovery_key_generate(mocker):
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def empty_json_repo(tokens):
|
def empty_json_repo(empty_keys):
|
||||||
repo = JsonTokensRepository()
|
repo = JsonTokensRepository()
|
||||||
for token in repo.get_tokens():
|
for token in repo.get_tokens():
|
||||||
repo.delete_token(token)
|
repo.delete_token(token)
|
||||||
|
@ -297,33 +297,22 @@ def test_refresh_not_found_token(some_tokens_repo, mock_token_generate):
|
||||||
################
|
################
|
||||||
|
|
||||||
|
|
||||||
def test_get_recovery_key(tokens):
|
def test_get_recovery_key_when_empty(empty_repo):
|
||||||
repo = JsonTokensRepository()
|
repo = empty_repo
|
||||||
|
|
||||||
assert repo.get_recovery_key() == RecoveryKey(
|
|
||||||
key="ed653e4b8b042b841d285fa7a682fa09e925ddb2d8906f54",
|
|
||||||
created_at=datetime(2022, 11, 11, 11, 48, 54, 228038),
|
|
||||||
expires_at=None,
|
|
||||||
uses_left=2,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_get_recovery_key_when_empty(empty_keys):
|
|
||||||
repo = JsonTokensRepository()
|
|
||||||
|
|
||||||
assert repo.get_recovery_key() is None
|
assert repo.get_recovery_key() is None
|
||||||
|
|
||||||
|
|
||||||
def test_create_recovery_key(tokens, mock_recovery_key_generate):
|
def test_create_get_recovery_key(some_tokens_repo, mock_recovery_key_generate):
|
||||||
repo = JsonTokensRepository()
|
repo = some_tokens_repo
|
||||||
|
|
||||||
assert repo.create_recovery_key(uses_left=1, expiration=None) is not None
|
assert repo.create_recovery_key(uses_left=1, expiration=None) is not None
|
||||||
# assert read_json(tokens / "tokens.json")["recovery_token"] == {
|
assert repo.get_recovery_key() == RecoveryKey(
|
||||||
# "token": "889bf49c1d3199d71a2e704718772bd53a422020334db051",
|
key="889bf49c1d3199d71a2e704718772bd53a422020334db051",
|
||||||
# "date": "2022-07-15T17:41:31.675698",
|
created_at=datetime(2022, 7, 15, 17, 41, 31, 675698),
|
||||||
# "expiration": None,
|
expires_at=None,
|
||||||
# "uses_left": 1,
|
uses_left=1,
|
||||||
# }
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_use_mnemonic_recovery_key_when_empty(
|
def test_use_mnemonic_recovery_key_when_empty(
|
||||||
|
|
Loading…
Reference in a new issue