test(tokens-repo): untie double new device auth from json
parent
367ba51c9d
commit
592d62f53f
|
@ -347,49 +347,15 @@ def test_graphql_authorize_new_device_with_invalid_key(
|
||||||
|
|
||||||
|
|
||||||
def test_graphql_get_and_authorize_used_key(client, authorized_client, tokens_file):
|
def test_graphql_get_and_authorize_used_key(client, authorized_client, tokens_file):
|
||||||
response = authorized_client.post(
|
mnemonic_key = graphql_get_new_device_key(authorized_client)
|
||||||
"/graphql",
|
|
||||||
json={"query": NEW_DEVICE_KEY_MUTATION},
|
|
||||||
)
|
|
||||||
assert_ok(response, "getNewDeviceApiKey")
|
|
||||||
mnemonic_key = response.json()["data"]["getNewDeviceApiKey"]["key"]
|
|
||||||
assert mnemonic_key.split(" ").__len__() == 12
|
|
||||||
key = Mnemonic(language="english").to_entropy(mnemonic_key).hex()
|
|
||||||
assert read_json(tokens_file)["new_device"]["token"] == key
|
|
||||||
|
|
||||||
response = client.post(
|
graphql_authorize_new_device(client, mnemonic_key, "new_device")
|
||||||
"/graphql",
|
devices = graphql_get_devices(authorized_client)
|
||||||
json={
|
|
||||||
"query": AUTHORIZE_WITH_NEW_DEVICE_KEY_MUTATION,
|
|
||||||
"variables": {
|
|
||||||
"input": {
|
|
||||||
"key": mnemonic_key,
|
|
||||||
"deviceName": "new_token",
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
)
|
|
||||||
assert_ok(response, "authorizeWithNewDeviceApiKey")
|
|
||||||
assert (
|
|
||||||
read_json(tokens_file)["tokens"][2]["token"]
|
|
||||||
== response.json()["data"]["authorizeWithNewDeviceApiKey"]["token"]
|
|
||||||
)
|
|
||||||
assert read_json(tokens_file)["tokens"][2]["name"] == "new_token"
|
|
||||||
|
|
||||||
response = client.post(
|
response = graphql_try_auth_new_device(client, mnemonic_key, "new_device2")
|
||||||
"/graphql",
|
|
||||||
json={
|
|
||||||
"query": AUTHORIZE_WITH_NEW_DEVICE_KEY_MUTATION,
|
|
||||||
"variables": {
|
|
||||||
"input": {
|
|
||||||
"key": mnemonic_key,
|
|
||||||
"deviceName": "test_token2",
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
)
|
|
||||||
assert_errorcode(response, "authorizeWithNewDeviceApiKey", 404)
|
assert_errorcode(response, "authorizeWithNewDeviceApiKey", 404)
|
||||||
assert read_json(tokens_file)["tokens"].__len__() == 3
|
|
||||||
|
assert graphql_get_devices(authorized_client) == devices
|
||||||
|
|
||||||
|
|
||||||
def test_graphql_get_and_authorize_key_after_12_minutes(
|
def test_graphql_get_and_authorize_key_after_12_minutes(
|
||||||
|
|
Loading…
Reference in New Issue