Пример #1
0
def test_create_existing_user_fails() -> None:
    username = "******"
    password = "******"
    create_new_user(username, password)

    with pytest.raises(UsernameExistsError):
        create_new_user(username, password)
Пример #2
0
def _init_admin_user():
    try:
        create_new_user(
            username=ADMIN_USERNAME,
            password=str(uuid.uuid4()),
            is_admin=True,
            first_name="Mrs.",
            last_name="Hudson",
        )
    except UsernameExistsError:
        pass
Пример #3
0
def test_get_user_kyc() -> None:
    username = "******"
    password = "******"
    first_name = "first name"
    last_name = "last_name"
    user_id = create_new_user(username, password, False, first_name, last_name)
    update_user(user_id=user_id, country="US", city="New York")
    kyc_info = get_additional_user_kyc_info(user_id)
    assert kyc_info == {
        "payload_type": "KYC_DATA",
        "payload_version": 1,
        "type": "individual",
        "given_name": first_name,
        "surname": last_name,
        "dob": "",
        "address": {
            "city": "New York",
            "country": "US",
            "line1": "",
            "line2": "",
            "postal_code": "",
            "state": "",
        },
        "place_of_birth": {
            "city": "New York",
            "country": "US",
            "postal_code": "",
            "state": "",
        },
    }
Пример #4
0
        def post(self):
            user_params = request.json
            username = user_params["username"]
            password = user_params["password"]
            try:
                user_id = user_service.create_new_user(username, password)
            except UsernameExistsError as e:
                return self.respond_with_error(HTTPStatus.CONFLICT, str(e))

            token_id = user_service.add_token(user_id)
            return token_id, HTTPStatus.OK
Пример #5
0
def test_update_user_password() -> None:
    username = "******"
    password = "******"
    user_id = create_new_user(username, password)

    password2 = "updatedsupersecurepassword"
    update_password(user_id, password2)

    assert (authorize(username=username,
                      password=password) == types.LoginError.WRONG_PASSWORD)
    assert authorize(username=username,
                     password=password2) == types.LoginError.SUCCESS
Пример #6
0
def test_create_user() -> None:
    username = "******"
    password = "******"
    create_new_user(username, password)

    assert authorize(username=username, password=password)