fix(tokens-repository): use_mnemonic_new_device_key() now stores a token

pull/26/head
Houkime 2022-12-12 15:36:38 +00:00
parent 4498003aca
commit 2797c6f88f
2 changed files with 7 additions and 7 deletions

View File

@ -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

View File

@ -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 (