Exemple #1
0
def test_regenerate_user_recovery_codes():
    user_id = "17"
    auth_user = auth.provision_user(user_id)
    current_recovery_codes = set(recovery_code.code for recovery_code in auth_user.recovery_codes)

    auth.regenerate_user_recovery_codes(user_id)
    new_recovery_codes = set(recovery_code.code for recovery_code in auth_user.recovery_codes)

    assert current_recovery_codes != new_recovery_codes
    assert len(new_recovery_codes) == auth.RECOVERY_CODE_COUNT
Exemple #2
0
def test_regenerate_user_recovery_codes():
    user_id = '17'
    auth_user = auth.provision_user(user_id)
    current_recovery_codes = set(recovery_code.code
                                 for recovery_code in auth_user.recovery_codes)

    auth.regenerate_user_recovery_codes(user_id)
    new_recovery_codes = set(recovery_code.code
                             for recovery_code in auth_user.recovery_codes)

    assert current_recovery_codes != new_recovery_codes
    assert len(new_recovery_codes) == auth.RECOVERY_CODE_COUNT
Exemple #3
0
def user_regenerate_recovery_codes():
    data = request.get_json(force=True)
    try:
        validate(data, USER_RECOVERY_CODE_REGENERATE_SCHEMA)
    except ValidationError as e:
        return jsonify(error_message=str(e), error_code='INVALID_PARAMS'), 400

    auth_user = auth.load_user(data['user_id'])
    if not auth_user:
        return user_not_provisioned_response(data['user_id'])

    auth_user = auth.regenerate_user_recovery_codes(auth_user.user_id)
    return format_auth_user_response(auth_user)
Exemple #4
0
def user_regenerate_recovery_codes():
    data = request.get_json(force=True)
    try:
        validate(data, USER_RECOVERY_CODE_REGENERATE_SCHEMA)
    except ValidationError as e:
        return jsonify(error_message=str(e), error_code='INVALID_PARAMS'), 400

    auth_user = auth.load_user(data['user_id'])
    if not auth_user:
        return user_not_provisioned_response(data['user_id'])

    auth_user = auth.regenerate_user_recovery_codes(auth_user.user_id)
    return format_auth_user_response(auth_user)