From 2797c6f88f4309b72695e86409028bf335129bb9 Mon Sep 17 00:00:00 2001 From: Houkime <> Date: Mon, 12 Dec 2022 15:36:38 +0000 Subject: [PATCH] fix(tokens-repository): use_mnemonic_new_device_key() now stores a token --- .../repositories/tokens/json_tokens_repository.py | 2 +- .../test_repository/test_tokens_repository.py | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/selfprivacy_api/repositories/tokens/json_tokens_repository.py b/selfprivacy_api/repositories/tokens/json_tokens_repository.py index 55316d6..12826ba 100644 --- a/selfprivacy_api/repositories/tokens/json_tokens_repository.py +++ b/selfprivacy_api/repositories/tokens/json_tokens_repository.py @@ -147,7 +147,7 @@ class JsonTokensRepository(AbstractTokensRepository): if not self._assert_mnemonic(new_device_key.key, mnemonic_phrase): raise NewDeviceKeyNotFound("Phrase is not token!") - new_token = Token.generate(device_name=device_name) + new_token = self.create_token(device_name=device_name) self.delete_new_device_key() return new_token diff --git a/tests/test_graphql/test_repository/test_tokens_repository.py b/tests/test_graphql/test_repository/test_tokens_repository.py index df56444..bdad6d8 100644 --- a/tests/test_graphql/test_repository/test_tokens_repository.py +++ b/tests/test_graphql/test_repository/test_tokens_repository.py @@ -499,14 +499,14 @@ def test_use_mnemonic_new_device_key( repo = empty_repo assert repo.get_new_device_key() is not None - assert ( - repo.use_mnemonic_new_device_key( - device_name="imnew", - mnemonic_phrase="captain ribbon toddler settle symbol minute step broccoli bless universe divide bulb", - ) - is not None + new_token = repo.use_mnemonic_new_device_key( + device_name="imnew", + mnemonic_phrase="captain ribbon toddler settle symbol minute step broccoli bless universe divide bulb", ) + assert new_token.device_name == "imnew" + assert new_token in repo.get_tokens() + # we must delete the key after use with pytest.raises(NewDeviceKeyNotFound): assert (