def create_fido2_keys_user(user_id): user = get_user_and_accounts(user_id) data = request.get_json() cbor_data = cbor.decode(base64.b64decode(data["payload"])) validate(data, fido2_key_schema) id = uuid.uuid4() key = decode_and_register(cbor_data, get_fido2_session(user_id)) save_fido2_key(Fido2Key(id=id, user_id=user_id, name=cbor_data["name"], key=key)) _update_alert(user, changes={'security_key_created': None}) return jsonify({"id": id})
def sample_fido2_key(notify_db, notify_db_session): user = create_user() key = Fido2Key(name='sample key', key="abcd", user_id=user.id) save_fido2_key(key) return key
def test_save_fido2_key_should_create_new_fido2_key(sample_user): fido2_key = Fido2Key(**{'user': sample_user, 'name': "Name", 'key': "Key"}) save_fido2_key(fido2_key) assert Fido2Key.query.count() == 1
def test_list_fido2_keys(sample_fido2_key): Fido2Key(**{'user': sample_fido2_key.user, 'name': "Name", 'key': "Key"}) keys = list_fido2_keys(sample_fido2_key.user.id) assert len(keys) == 2
def test_list_fido2_keys(sample_fido2_key): Fido2Key(**{"user": sample_fido2_key.user, "name": "Name", "key": "Key"}) keys = list_fido2_keys(sample_fido2_key.user.id) assert len(keys) == 2
def test_save_fido2_key_should_create_new_fido2_key(sample_user): fido2_key = Fido2Key(**{"user": sample_user, "name": "Name", "key": "Key"}) save_fido2_key(fido2_key) assert Fido2Key.query.count() == 1