Esempio n. 1
0
    def test_success_continue(self, root):
        from kotti.views.login import set_password

        self.form_values({
            "token": "mytoken",
            "email": "myemail",
            "password": "******",
            "continue_to": "http://example.com/here#there",
        })
        self.user.confirm_token = "mytoken"
        context, request = root, DummyRequest(post={"submit": "submit"})
        res = set_password(context, request)

        assert res.status == "302 Found"
        assert res.location == "http://example.com/here#there"
Esempio n. 2
0
    def test_success_continue(self, root):
        from kotti.views.login import set_password

        self.form_values({
            'token': 'mytoken',
            'email': 'myemail',
            'password': '******',
            'continue_to': 'http://example.com/here#there',
        })
        self.user.confirm_token = 'mytoken'
        context, request = root, DummyRequest(post={'submit': 'submit'})
        res = set_password(context, request)

        assert res.status == '302 Found'
        assert res.location == 'http://example.com/here#there'
Esempio n. 3
0
    def test_success_continue(self, root):
        from kotti.views.login import set_password

        self.form_values({
            'token': 'mytoken',
            'email': 'myemail',
            'password': '******',
            'continue_to': 'http://example.com/here#there',
            })
        self.user.confirm_token = 'mytoken'
        context, request = root, DummyRequest(
            post={'submit': 'submit'})
        res = set_password(context, request)

        assert res.status == '302 Found'
        assert res.location == 'http://example.com/here#there'
Esempio n. 4
0
    def test_success_continue(self, root):
        from kotti.views.login import set_password

        self.form_values(
            {
                "token": "mytoken",
                "email": "myemail",
                "password": "******",
                "continue_to": "http://example.com/here#there",
            }
        )
        self.user.confirm_token = "mytoken"
        context, request = root, DummyRequest(post={"submit": "submit"})
        res = set_password(context, request)

        assert res.status == "302 Found"
        assert res.location == "http://example.com/here#there"
Esempio n. 5
0
    def test_wrong_token(self, root):
        from kotti.security import get_principals
        from kotti.views.login import set_password

        self.form_values({
            'token': 'wrongtoken',
            'email': 'myemail',
            'password': '******',
            'continue_to': '',
            })
        self.user.confirm_token = 'mytoken'
        self.user.password = '******'
        context, request = root, DummyRequest(post={'submit': 'submit'})
        res = set_password(context, request)

        assert self.user.confirm_token == 'mytoken'
        assert not get_principals().validate_password(
            'mypassword', self.user.password)
        assert not request.is_response(res)
Esempio n. 6
0
    def test_wrong_token(self, root):
        from kotti.security import get_principals
        from kotti.views.login import set_password

        self.form_values({
            'token': 'wrongtoken',
            'email': 'myemail',
            'password': '******',
            'continue_to': '',
        })
        self.user.confirm_token = 'mytoken'
        self.user.password = '******'
        context, request = root, DummyRequest(post={'submit': 'submit'})
        res = set_password(context, request)

        assert self.user.confirm_token == 'mytoken'
        assert not get_principals().validate_password('mypassword',
                                                      self.user.password)
        assert not request.is_response(res)
Esempio n. 7
0
    def test_wrong_token(self, root):
        from kotti.security import get_principals
        from kotti.views.login import set_password

        self.form_values({
            "token": "wrongtoken",
            "email": "myemail",
            "password": "******",
            "continue_to": "",
        })
        self.user.confirm_token = "mytoken"
        self.user.password = "******"
        context, request = root, DummyRequest(post={"submit": "submit"})
        res = set_password(context, request)

        assert self.user.confirm_token == "mytoken"
        assert not get_principals().validate_password("mypassword",
                                                      self.user.password)
        assert not request.is_response(res)
Esempio n. 8
0
    def test_success(self):
        from kotti.resources import get_root
        from kotti.security import get_principals
        from kotti.views.login import set_password

        self.form_values({
            'token': 'mytoken',
            'email': 'myemail',
            'password': '******',
            'continue_to': '',
        })
        self.user.confirm_token = 'mytoken'
        self.user.password = '******'
        context, request = get_root(), DummyRequest(post={'submit': 'submit'})
        res = set_password(context, request)

        assert self.user.confirm_token is None
        assert get_principals().validate_password('mypassword',
                                                  self.user.password)
        assert res.status == '302 Found'
Esempio n. 9
0
    def test_wrong_token(self, root):
        from kotti.security import get_principals
        from kotti.views.login import set_password

        self.form_values(
            {
                "token": "wrongtoken",
                "email": "myemail",
                "password": "******",
                "continue_to": "",
            }
        )
        self.user.confirm_token = "mytoken"
        self.user.password = "******"
        context, request = root, DummyRequest(post={"submit": "submit"})
        res = set_password(context, request)

        assert self.user.confirm_token == "mytoken"
        assert not get_principals().validate_password("mypassword", self.user.password)
        assert not request.is_response(res)
Esempio n. 10
0
    def test_success(self):
        from kotti.resources import get_root
        from kotti.security import get_principals
        from kotti.views.login import set_password

        self.form_values({
            'token': 'mytoken',
            'email': 'myemail',
            'password': '******',
            'continue_to': '',
            })
        self.user.confirm_token = 'mytoken'
        self.user.password = '******'
        context, request = get_root(), DummyRequest(post={'submit': 'submit'})
        res = set_password(context, request)

        assert self.user.confirm_token is None
        assert get_principals().validate_password(
            'mypassword', self.user.password)
        assert res.status == '302 Found'
Esempio n. 11
0
    def test_success(self, root):
        from kotti.security import get_principals
        from kotti.views.login import set_password

        self.form_values({
            "token": "mytoken",
            "email": "myemail",
            "password": "******",
            "continue_to": "",
        })
        self.user.confirm_token = "mytoken"
        self.user.password = "******"
        context, request = root, DummyRequest(post={"submit": "submit"})
        self.user.last_login_date = None
        res = set_password(context, request)

        assert self.user.confirm_token is None
        assert self.user.last_login_date is not None
        assert get_principals().validate_password("mypassword",
                                                  self.user.password)
        assert res.status == "302 Found"
Esempio n. 12
0
    def test_success(self, root):
        from kotti.security import get_principals
        from kotti.views.login import set_password

        self.form_values(
            {
                "token": "mytoken",
                "email": "myemail",
                "password": "******",
                "continue_to": "",
            }
        )
        self.user.confirm_token = "mytoken"
        self.user.password = "******"
        context, request = root, DummyRequest(post={"submit": "submit"})
        self.user.last_login_date = None
        res = set_password(context, request)

        assert self.user.confirm_token is None
        assert self.user.last_login_date is not None
        assert get_principals().validate_password("mypassword", self.user.password)
        assert res.status == "302 Found"
Esempio n. 13
0
    def test_inactive_user(self, db_session):
        from kotti.resources import get_root
        from kotti.security import get_principals
        from kotti.views.login import set_password

        self.form_values({
            'token': 'mytoken',
            'email': 'myemail',
            'password': '******',
            'continue_to': '',
            })
        self.user.confirm_token = 'mytoken'
        self.user.password = '******'
        context, request = get_root(), DummyRequest(post={'submit': 'submit'})
        self.user.active = False
        self.user.last_login_date = None
        res = set_password(context, request)

        assert self.user.confirm_token == 'mytoken'
        assert self.user.last_login_date is None
        assert not get_principals().validate_password(
            'mypassword', self.user.password)
        assert not request.is_response(res)