Ejemplo n.º 1
0
    def test_attestation_setter(self):
        authenticator = Authenticator()

        authenticator.attestation = AttestationObject(base64.b64decode(ATTESTATION_OBJECT))

        self.assertEqual(authenticator.attestation_data, ATTESTATION_OBJECT)
        self.assertEqual(authenticator.credential_id_data, CREDENTIAL_ID)
Ejemplo n.º 2
0
    def test_credential_getter(self):
        authenticator = Authenticator(attestation_data=ATTESTATION_OBJECT)

        self.assertEqual(authenticator.credential.aaguid, b'\0' * 16)
        self.assertEqual(authenticator.credential.credential_id,
                         base64.b64decode(CREDENTIAL_ID))
        self.assertIsInstance(authenticator.credential.public_key, ES256)
Ejemplo n.º 3
0
 def test_metadata_attestation_keys(self):
     metadata = AuthenticatorMetadata.objects.create(
         identifier="['3be6d2c06ff2e7b07c9d9e28c020b00d07c815c8']",
         detailed_metadata_entry=json.dumps(
             DETAILED_METADATA_ATTESTATION_KEYS))
     authenticator = Authenticator(attestation_data=ATTESTATION_OBJECT_U2F)
     self.assertEqual(authenticator.metadata, metadata)
Ejemplo n.º 4
0
 def test_metadata_aaguid_wrong_cert(self):
     AuthenticatorMetadata.objects.create(
         identifier='95442b2e-f15e-4def-b270-efb106facb4e',
         detailed_metadata_entry=json.dumps(DETAILED_METADATA_WRONG_CERT))
     authenticator = Authenticator(
         attestation_data=ATTESTATION_OBJECT_AAGUID)
     self.assertIsNone(authenticator.metadata)
Ejemplo n.º 5
0
 def test_metadata_u2f_no_extension(self):
     metadata = AuthenticatorMetadata.objects.create(
         identifier="['ed5bdb96011e3d457d858af39e30ac57c5ac95e6']",
         detailed_metadata_entry=json.dumps(
             DETAILED_METADATA_ATTESTATION_KEYS_NO_EXT))
     authenticator = Authenticator(
         attestation_data=ATTESTATION_OBJECT_U2F_NO_EXT)
     self.assertEqual(authenticator.metadata, metadata)
Ejemplo n.º 6
0
 def test_metadata_missing(self):
     status = {'statusReports': [{'status': 'FIDO_CERTIFIED'}]}
     metadata = AuthenticatorMetadata.objects.create(
         identifier='95442b2e-f15e-4def-b270-efb106facb4e',
         detailed_metadata_entry='',
         metadata_entry=json.dumps(status))
     authenticator = Authenticator(
         attestation_data=ATTESTATION_OBJECT_AAGUID)
     self.assertEqual(authenticator.metadata, metadata)
Ejemplo n.º 7
0
 def test_metadata_multiple(self):
     AuthenticatorMetadata.objects.create(
         identifier="['3be6d2c06ff2e7b07c9d9e28c020b00d07c815c8']",
         detailed_metadata_entry=json.dumps(DETAILED_METADATA_ATTESTATION_KEYS))
     AuthenticatorMetadata.objects.create(
         identifier="['3be6d2c06ff2e7b07c9d9e28c020b00d07c815c8', 'blabla']",
         detailed_metadata_entry=json.dumps(DETAILED_METADATA_ATTESTATION_KEYS),
         url='example_url')
     authenticator = Authenticator(attestation_data=ATTESTATION_OBJECT_U2F)
     self.assertIsNone(authenticator.metadata)
Ejemplo n.º 8
0
 def test_metadata_md3(self):
     status = {
         'statusReports': [{
             'status': 'FIDO_CERTIFIED'
         }],
         'metadataStatement': DETAILED_METADATA_ATTESTATION_KEYS
     }
     metadata = AuthenticatorMetadata.objects.create(
         identifier="['3be6d2c06ff2e7b07c9d9e28c020b00d07c815c8']",
         detailed_metadata_entry='',
         metadata_entry=json.dumps(status))
     authenticator = Authenticator(attestation_data=ATTESTATION_OBJECT_U2F)
     self.assertEqual(authenticator.metadata, metadata)
Ejemplo n.º 9
0
    def test_attestation_getter(self):
        authenticator = Authenticator(attestation_data=ATTESTATION_OBJECT)

        self.assertEqual(authenticator.attestation.fmt, 'fido-u2f')
        self.assertIsInstance(authenticator.attestation.auth_data,
                              AuthenticatorData)
Ejemplo n.º 10
0
    def test_credential_id_getter(self):
        authenticator = Authenticator(
            credential_id_data='Q1JFREVOVElBTF9JRA==')

        self.assertEqual(authenticator.credential_id, b'CREDENTIAL_ID')
Ejemplo n.º 11
0
 def test_metadata_no_identifier(self):
     authenticator = Authenticator(
         attestation_data=ATTESTATION_OBJECT_NO_ATTESTATION_HANDED)
     self.assertIsNone(authenticator.metadata)
Ejemplo n.º 12
0
 def test_metadata_attestation_keys_no_match(self):
     authenticator = Authenticator(attestation_data=ATTESTATION_OBJECT_U2F)
     self.assertIsNone(authenticator.metadata)
Ejemplo n.º 13
0
 def test_metadata_aaguid_no_match(self):
     authenticator = Authenticator(
         attestation_data=ATTESTATION_OBJECT_AAGUID)
     self.assertIsNone(authenticator.metadata)
Ejemplo n.º 14
0
 def test_identifier_u2f_no_ext(self):
     authenticator = Authenticator(
         attestation_data=ATTESTATION_OBJECT_U2F_NO_EXT)
     self.assertEqual(authenticator.identifier,
                      "ed5bdb96011e3d457d858af39e30ac57c5ac95e6")
Ejemplo n.º 15
0
 def test_identifier_u2f(self):
     authenticator = Authenticator(attestation_data=ATTESTATION_OBJECT_U2F)
     self.assertEqual(authenticator.identifier,
                      "3be6d2c06ff2e7b07c9d9e28c020b00d07c815c8")
Ejemplo n.º 16
0
 def test_identifier_aaguid(self):
     authenticator = Authenticator(
         attestation_data=ATTESTATION_OBJECT_AAGUID)
     self.assertEqual(authenticator.identifier,
                      "95442b2e-f15e-4def-b270-efb106facb4e")