def test_add_and_remove_non_resident_credentials(driver, pages): driver = create_rk_disabled_authenticator(driver) pages.load("virtual-authenticator.html") assert driver.virtual_authenticator_id is not None credential = Credential.create_non_resident_credential( bytearray({1, 2, 3, 4}), "localhost", b64decode(BASE64__ENCODED_PK), 0, ) credential2 = Credential.create_non_resident_credential( bytearray({1, 2, 3, 4, 5}), "localhost", b64decode(BASE64__ENCODED_PK), 1, ) driver.add_credential(credential) assert len(driver.get_credentials()) == 1 driver.add_credential(credential2) assert len(driver.get_credentials()) == 2 driver.remove_credential(credential.id) assert len(driver.get_credentials()) == 1 driver.remove_virtual_authenticator() assert driver.virtual_authenticator_id is None
def test_remove_all_credentials(driver): options = VirtualAuthenticatorOptions() options.has_resident_key = True driver.add_virtual_authenticator(options) assert driver.virtual_authenticator_id is not None credential = Credential.create_non_resident_credential( bytearray({1, 2, 3, 4}), "localhost", b64decode(BASE64__ENCODED_PK), 0, ) credential2 = Credential.create_resident_credential( bytearray({1, 2, 3, 4, 5}), "localhost", bytearray({1}), b64decode(BASE64__ENCODED_PK), 1, ) driver.add_credential(credential) assert len(driver.get_credentials()) == 1 driver.add_credential(credential2) assert len(driver.get_credentials()) == 2 driver.remove_all_credentials() assert len(driver.get_credentials()) == 0 driver.remove_virtual_authenticator()
def test_rk_disabled_credentials(data): _id, rp_id, user_handle, privatekey, sign_count = data credential = Credential.create_non_resident_credential( _id, rp_id, privatekey, sign_count) assert credential.id == urlsafe_b64encode(bytearray({1, 2, 3, 4})).decode() assert credential.private_key == urlsafe_b64encode(privatekey).decode() assert credential.sign_count == 0 assert credential.rp_id == "localhost" if credential.is_resident_credential is False: assert True else: assert False if credential.user_handle is None: assert True else: assert False
def test_add_and_remove_non_resident_credentials(driver, pages): driver = create_rk_disabled_ctap2_authenticator(driver) driver.get(pages.url("virtual-authenticator.html", localhost=True)) assert driver.virtual_authenticator_id is not None credential = Credential.create_non_resident_credential( bytearray({1, 2, 3, 4}), "localhost", b64decode(BASE64__ENCODED_PK), 0, ) driver.add_credential(credential) assert get_assertion_for(driver, [1, 2, 3, 4]).get('status', '') == 'OK' driver.remove_virtual_authenticator() assert driver.virtual_authenticator_id is None
def test_add_non_resident_credential_when_authenticator_uses_u2f_protocol( driver, pages): driver = create_rk_disabled_u2f_authenticator(driver) driver.get(pages.url("virtual-authenticator.html", localhost=True)) base64_pk = ''' MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQg8_zMDQDYAxlU-Q hk1Dwkf0v18GZca1DMF3SaJ9HPdmShRANCAASNYX5lyVCOZLzFZzrIKmeZ2jwU RmgsJYxGP__fWN_S-j5sN4tT15XEpN_7QZnt14YvI6uvAgO0uJEboFaZlOEB ''' credential = Credential.create_non_resident_credential( bytearray({1, 2, 3, 4}), "localhost", urlsafe_b64decode(base64_pk), 0, ) driver.add_credential(credential) assert get_assertion_for(driver, [1, 2, 3, 4]).get('status', '') == 'OK' driver.remove_virtual_authenticator()