Esempio n. 1
0
    def test_login(self):
        from .views import login
        data = requests.get('http://personatestuser.org/email_with_assertion/http%3A%2F%2Fsomeaudience').json()
        email = data['email']
        assertion = data['assertion']

        request = testing.DummyRequest()
        request.params['assertion'] = assertion
        request.params['csrf_token'] = request.session.get_csrf_token()
        request.params['came_from'] = '/'
        response = login(request)

        self.assertEqual(response, {'redirect': '/', 'success': True})
        self.assertEqual(self.security_policy.remembered, email)
Esempio n. 2
0
    def test_login(self):
        from .views import login
        data = requests.get(
            'http://personatestuser.org/email_with_assertion/http%3A%2F%2Fsomeaudience'
        ).json()
        email = data['email']
        assertion = data['assertion']

        request = testing.DummyRequest()
        request.params['assertion'] = assertion
        request.params['csrf_token'] = request.session.get_csrf_token()
        request.params['came_from'] = '/'
        response = login(request)

        self.assertEqual(response, {'redirect': '/', 'success': True})
        self.assertEqual(self.security_policy.remembered, email)
Esempio n. 3
0
    def test_login(self):
        from pyramid_persona.views import login
        data = requests.get('http://personatestuser.org/email_with_assertion/http%3A%2F%2Fsomeaudience').json()
        assertion = data['assertion']

        request = testing.DummyRequest()
        request.environ['HTTP_HOST'] = 'http://someaudience'
        request.params['assertion'] = assertion
        request.params['csrf_token'] = request.session.get_csrf_token()
        request.params['came_from'] = '/'
        result = login(request)

        from pyramid.renderers import render_to_response
        response = render_to_response('json', result, request=request)

        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.text, '{"redirect": "/", "success": true}')
Esempio n. 4
0
    def test_login(self):
        from pyramid_persona.views import login
        data = requests.get(
            'http://personatestuser.org/email_with_assertion/http%3A%2F%2Fsomeaudience'
        ).json()
        assertion = data['assertion']

        request = testing.DummyRequest()
        request.environ['HTTP_HOST'] = 'http://someaudience'
        request.params['assertion'] = assertion
        request.params['csrf_token'] = request.session.get_csrf_token()
        request.params['came_from'] = '/'
        result = login(request)

        from pyramid.renderers import render_to_response
        response = render_to_response('json', result, request=request)

        import json
        self.assertEqual(response.status_code, 200)
        self.assertEqual(json.loads(response.text), {
            "redirect": "/",
            "success": True
        })