示例#1
0
文件: views.py 项目: jbjuin/baserow
    def post(self, request, data):
        """Changes the authenticated user's password if the old password is correct."""

        handler = UserHandler()
        handler.change_password(request.user, data["old_password"],
                                data["new_password"])

        return Response("", status=204)
def test_change_password(data_fixture):
    user = data_fixture.create_user(email='test@localhost', password='******')
    handler = UserHandler()

    with pytest.raises(InvalidPassword):
        handler.change_password(user, 'INCORRECT', 'new')

    user.refresh_from_db()
    assert user.check_password('test')

    user = handler.change_password(user, 'test', 'new')
    assert user.check_password('new')
示例#3
0
def test_change_password(data_fixture):
    user = data_fixture.create_user(email="test@localhost", password="******")
    handler = UserHandler()

    with pytest.raises(InvalidPassword):
        handler.change_password(user, "INCORRECT", "new")

    user.refresh_from_db()
    assert user.check_password("test")

    user = handler.change_password(user, "test", "new")
    assert user.check_password("new")