Example #1
0
 def test_log_not_logged_in(self, mock_capture):
     session_record = Session()
     set_session(session_record)
     sentry.log_exception()
     mock_capture.assert_called_with(extra={
         'session': {},
     }, )
 def test_log_not_logged_in(self, mock_capture):
     session_record = Session()
     set_session(session_record)
     sentry.log_exception()
     mock_capture.assert_called_with(
         extra={
             'session': {},
         },
     )
Example #3
0
 def test_log_logged_in(self, mock_capture):
     user = UserFactory()
     session_record = Session()
     session_record.data['auth_user_id'] = user._id
     set_session(session_record)
     sentry.log_exception()
     mock_capture.assert_called_with(extra={
         'session': {
             'auth_user_id': user._id,
         },
     }, )
Example #4
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 #5
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)
 def test_log_logged_in(self, mock_capture):
     user = UserFactory()
     session_record = Session()
     session_record.data['auth_user_id'] = user._id
     set_session(session_record)
     sentry.log_exception()
     mock_capture.assert_called_with(
         extra={
             'session': {
                 'auth_user_id': user._id,
             },
         },
     )
Example #7
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 #8
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 #9
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(Session())
Example #10
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(Session())