示例#1
0
    def test_change_password_good_is_password_changed(self):
        from c2cgeoportal_geoportal.views.login import Login
        import crypt

        request = self._create_request_obj(
            params={"lang": "en"},
            POST={
                "login": "******",
                "oldPassword": "******",
                "newPassword": "******",
                "confirmNewPassword": "******",
            },
        )

        from c2cgeoportal_commons.models import DBSession
        from c2cgeoportal_commons.models.static import User

        user = DBSession.query(User).filter_by(username="******").one()
        assert user.is_password_changed is False
        assert user._password == crypt.crypt("__test_user1", user._password)
        login = Login(request)
        self.assertNotEqual(login.change_password(), None)
        user = DBSession.query(User).filter_by(username="******").one()
        assert user.is_password_changed is True
        assert user._password == crypt.crypt("1234", user._password)
示例#2
0
    def test_change_password_different(self):
        from pyramid.httpexceptions import HTTPBadRequest
        from c2cgeoportal_geoportal.views.login import Login

        request = self._create_request_obj(
            username="******",
            params={"lang": "en"},
            POST={
                "oldPassword": "******",
                "newPassword": "******",
                "confirmNewPassword": "******"
            },
        )
        login = Login(request)
        with pytest.raises(HTTPBadRequest):
            login.change_password()