Exemplo n.º 1
0
 def get_credentials(self) -> List[Credential]:
     """
     Returns the list of credentials owned by the authenticator.
     """
     credential_data = self.execute(
         Command.GET_CREDENTIALS,
         {'authenticatorId': self._authenticator_id})
     return [
         Credential.from_dict(credential)
         for credential in credential_data['value']
     ]
Exemplo n.º 2
0
def test_from_dict():
    data = {
        "credentialId": urlsafe_b64encode(bytearray({1, 2, 3, 4})).decode(),
        "isResidentCredential": True,
        "rpId": "localhost",
        "userHandle": urlsafe_b64encode(bytearray({1})).decode(),
        "privateKey": BASE64__ENCODED_PK,
        "signCount": 0,
    }

    credential = Credential.from_dict(data)

    key = urlsafe_b64decode(BASE64__ENCODED_PK)

    assert credential.id == urlsafe_b64encode(bytearray({1, 2, 3, 4})).decode()
    if credential.is_resident_credential is True:
        assert True
    else:
        assert False
    assert credential.rp_id == "localhost"
    assert credential.user_handle == urlsafe_b64encode(bytearray({1})).decode()
    assert credential.private_key == urlsafe_b64encode(key).decode()
    assert credential.sign_count == 0