Fix logic of methods and tests fetching identities

they were resturned the opposite they said to return.
master
juga 2 years ago
parent 86d894feb3
commit 0620198cc4

@ -36,13 +36,13 @@ class GNUnetRest:
def fetch_identity_keyhash(self, identity_name):
"""Returns the hash of the public key of an identity by name."""
r = requests.get(self.identity_hash + identity_name)
return r.json()['name'] if r.ok else (False, r.reason)
r = requests.get(self.identity_name + identity_name)
return r.json()['pubkey'] if r.ok else (False, r.reason)
def fetch_identity_name(self, key_hash):
"""Returns the name of an identity specified by public key."""
r = requests.get(self.identity_name + key_hash)
return r.json()['pubkey'] if r.ok else (False, r.reason)
"""Returns the name of an identity specified by the key hash."""
r = requests.get(self.identity_hash + key_hash)
return r.json()['name'] if r.ok else (False, r.reason)
def fetch_namestore_default_identity(self):
"""Returns the default identity of subsystem 'namestore'."""

@ -33,21 +33,21 @@ def test_list_identities():
assert "bob" == identities[1]['name']
def test_fetch_identity_hash():
r = REST_CLIENT.fetch_identity_name("alice")
def test_fetch_identity_keyhash():
r = REST_CLIENT.fetch_identity_keyhash("alice")
assert 52 == len(r)
def test_fetch_identity_name():
# First fetch the hash, since we don't know it.
keyhash = REST_CLIENT.fetch_identity_name("alice")
r = REST_CLIENT.fetch_identity_keyhash(keyhash)
keyhash = REST_CLIENT.fetch_identity_keyhash("alice")
r = REST_CLIENT.fetch_identity_name(keyhash)
assert "alice" == r
def test_change_identity_name():
assert REST_CLIENT.change_identity_name("bob", "carol")
r = REST_CLIENT.fetch_identity_name("carol")
r = REST_CLIENT.fetch_identity_keyhash("carol")
assert 52 == len(r)

Loading…
Cancel
Save