Example #1
0
    def test_authenticate_two_factor_with_next_url(self):
        fake_session = sessions.Session(data={'next_url': '/someendpoint/'})
        sessions.set_session(fake_session)

        response = authenticate_two_factor(self.user)
        assert_true(isinstance(response, BaseResponse))

        assert_equal(
            response.location,
            u'{0}?next=%2Fsomeendpoint%2F'.format(web_url_for('two_factor')))
        assert_equal(response.status_code, 302)
Example #2
0
 def test_verify_two_factor_with_valid_code(self):
     fake_session = sessions.Session(
         data={
             'two_factor_auth': {
                 'auth_user_username': self.user.username,
                 'auth_user_id': self.user._primary_key,
                 'auth_user_fullname': self.user.fullname,
             }
         })
     sessions.set_session(fake_session)
     response = verify_two_factor(
         self.user._id, _valid_code(self.user_settings.totp_secret))
     assert_true(isinstance(response, BaseResponse))
     assert_equal(response.location, u'/dashboard/')
     assert_equal(response.status_code, 302)
Example #3
0
 def setUp(self):
     decoratorapp = Flask('decorators')
     self.ctx = decoratorapp.test_request_context()
     self.ctx.push()
     # TODO: Think of something better @sloria @jmcarp
     sessions.set_session(sessions.Session())