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

This commit is contained in:
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): if not self._assert_mnemonic(new_device_key.key, mnemonic_phrase):
raise NewDeviceKeyNotFound("Phrase is not token!") 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() self.delete_new_device_key()
return new_token return new_token

View file

@ -499,14 +499,14 @@ def test_use_mnemonic_new_device_key(
repo = empty_repo repo = empty_repo
assert repo.get_new_device_key() is not None assert repo.get_new_device_key() is not None
assert ( new_token = repo.use_mnemonic_new_device_key(
repo.use_mnemonic_new_device_key( device_name="imnew",
device_name="imnew", mnemonic_phrase="captain ribbon toddler settle symbol minute step broccoli bless universe divide bulb",
mnemonic_phrase="captain ribbon toddler settle symbol minute step broccoli bless universe divide bulb",
)
is not None
) )
assert new_token.device_name == "imnew"
assert new_token in repo.get_tokens()
# we must delete the key after use # we must delete the key after use
with pytest.raises(NewDeviceKeyNotFound): with pytest.raises(NewDeviceKeyNotFound):
assert ( assert (