mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2025-01-24 17:56:44 +00:00
test(tokens-repo): move null keys and tokens fixtures to json tests
and remove corresponding json files from the folder
This commit is contained in:
parent
84bfa333fa
commit
4492bbe995
|
@ -23,15 +23,28 @@ from tests.common import read_json
|
||||||
|
|
||||||
from test_tokens_repository import ORIGINAL_TOKEN_CONTENT
|
from test_tokens_repository import ORIGINAL_TOKEN_CONTENT
|
||||||
from test_tokens_repository import (
|
from test_tokens_repository import (
|
||||||
tokens,
|
|
||||||
mock_recovery_key_generate,
|
mock_recovery_key_generate,
|
||||||
mock_generate_token,
|
mock_generate_token,
|
||||||
mock_new_device_key_generate,
|
mock_new_device_key_generate,
|
||||||
empty_keys,
|
empty_keys,
|
||||||
null_keys,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def tokens(mocker, datadir):
|
||||||
|
mocker.patch("selfprivacy_api.utils.TOKENS_FILE", new=datadir / "tokens.json")
|
||||||
|
assert read_json(datadir / "tokens.json")["tokens"] == ORIGINAL_TOKEN_CONTENT
|
||||||
|
return datadir
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def null_keys(mocker, datadir):
|
||||||
|
mocker.patch("selfprivacy_api.utils.TOKENS_FILE", new=datadir / "null_keys.json")
|
||||||
|
assert read_json(datadir / "null_keys.json")["recovery_token"] is None
|
||||||
|
assert read_json(datadir / "null_keys.json")["new_device"] is None
|
||||||
|
return datadir
|
||||||
|
|
||||||
|
|
||||||
def test_delete_token(tokens):
|
def test_delete_token(tokens):
|
||||||
repo = JsonTokensRepository()
|
repo = JsonTokensRepository()
|
||||||
input_token = Token(
|
input_token = Token(
|
||||||
|
|
|
@ -55,13 +55,6 @@ ORIGINAL_DEVICE_NAMES = [
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def tokens(mocker, datadir):
|
|
||||||
mocker.patch("selfprivacy_api.utils.TOKENS_FILE", new=datadir / "tokens.json")
|
|
||||||
assert read_json(datadir / "tokens.json")["tokens"] == ORIGINAL_TOKEN_CONTENT
|
|
||||||
return datadir
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def empty_keys(mocker, datadir):
|
def empty_keys(mocker, datadir):
|
||||||
mocker.patch("selfprivacy_api.utils.TOKENS_FILE", new=datadir / "empty_keys.json")
|
mocker.patch("selfprivacy_api.utils.TOKENS_FILE", new=datadir / "empty_keys.json")
|
||||||
|
@ -75,14 +68,6 @@ def empty_keys(mocker, datadir):
|
||||||
return datadir
|
return datadir
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def null_keys(mocker, datadir):
|
|
||||||
mocker.patch("selfprivacy_api.utils.TOKENS_FILE", new=datadir / "null_keys.json")
|
|
||||||
assert read_json(datadir / "null_keys.json")["recovery_token"] is None
|
|
||||||
assert read_json(datadir / "null_keys.json")["new_device"] is None
|
|
||||||
return datadir
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_new_device_key_generate(mocker):
|
def mock_new_device_key_generate(mocker):
|
||||||
mock = mocker.patch(
|
mock = mocker.patch(
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
{
|
|
||||||
"tokens": [
|
|
||||||
{
|
|
||||||
"token": "KG9ni-B-CMPk327Zv1qC7YBQaUGaBUcgdkvMvQ2atFI",
|
|
||||||
"name": "primary_token",
|
|
||||||
"date": "2022-07-15 17:41:31.675698"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"token": "3JKgLOtFu6ZHgE4OU-R-VdW47IKpg-YQL0c6n7bol68",
|
|
||||||
"name": "second_token",
|
|
||||||
"date": "2022-07-15 17:41:31.675698Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"token": "LYiwFDekvALKTQSjk7vtMQuNP_6wqKuV-9AyMKytI_8",
|
|
||||||
"name": "third_token",
|
|
||||||
"date": "2022-07-15T17:41:31.675698Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"token": "dD3CFPcEZvapscgzWb7JZTLog7OMkP7NzJeu2fAazXM",
|
|
||||||
"name": "forth_token",
|
|
||||||
"date": "2022-07-15T17:41:31.675698"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"recovery_token": null,
|
|
||||||
"new_device": null
|
|
||||||
}
|
|
|
@ -1,35 +0,0 @@
|
||||||
{
|
|
||||||
"tokens": [
|
|
||||||
{
|
|
||||||
"token": "KG9ni-B-CMPk327Zv1qC7YBQaUGaBUcgdkvMvQ2atFI",
|
|
||||||
"name": "primary_token",
|
|
||||||
"date": "2022-07-15 17:41:31.675698"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"token": "3JKgLOtFu6ZHgE4OU-R-VdW47IKpg-YQL0c6n7bol68",
|
|
||||||
"name": "second_token",
|
|
||||||
"date": "2022-07-15 17:41:31.675698Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"token": "LYiwFDekvALKTQSjk7vtMQuNP_6wqKuV-9AyMKytI_8",
|
|
||||||
"name": "third_token",
|
|
||||||
"date": "2022-07-15T17:41:31.675698Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"token": "dD3CFPcEZvapscgzWb7JZTLog7OMkP7NzJeu2fAazXM",
|
|
||||||
"name": "forth_token",
|
|
||||||
"date": "2022-07-15T17:41:31.675698"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"recovery_token": {
|
|
||||||
"token": "ed653e4b8b042b841d285fa7a682fa09e925ddb2d8906f54",
|
|
||||||
"date": "2022-11-11T11:48:54.228038",
|
|
||||||
"expiration": null,
|
|
||||||
"uses_left": 2
|
|
||||||
},
|
|
||||||
"new_device": {
|
|
||||||
"token": "2237238de23dc71ab558e317bdb8ff8e",
|
|
||||||
"date": "2022-10-26 20:50:47.973212",
|
|
||||||
"expiration": "2022-10-26 21:00:47.974153"
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue