def test_partial_token_if_user_not_set_no_showstopper(self): """pipeline step handles set session token if user is not set""" request = create_request() strategy = load_strategy(request=request) strategy.request.session['partial_pipeline_token'] = 'test-token' backend = GithubOAuth2(strategy, '/') require_activation( strategy=strategy, details={}, backend=backend, user=None, pipeline_index=1, )
def test_skip_if_user_not_set(self): """pipeline step is skipped if user is not set""" request = create_request() strategy = load_strategy(request=request) backend = GithubOAuth2(strategy, '/') result = require_activation( strategy=strategy, details={}, backend=backend, user=None, pipeline_index=1, ) self.assertEqual(result, {})
def test_pipeline_returns_html_responseon_get(self): """pipeline step renders http response for GET request and inactive user""" request = create_request() strategy = load_strategy(request=request) backend = GithubOAuth2(strategy, '/') response = require_activation( strategy=strategy, details={}, backend=backend, user=self.user, pipeline_index=1, ) self.assertEqual(response.status_code, 200) self.assertEqual(response['content-type'], 'text/html; charset=utf-8')
def test_skip_if_user_is_active(self): """pipeline step is skipped if user is active""" self.user.requires_activation = UserModel.ACTIVATION_NONE self.user.save() self.assertFalse(self.user.requires_activation) request = create_request() strategy = load_strategy(request=request) backend = GithubOAuth2(strategy, '/') result = require_activation( strategy=strategy, details={}, backend=backend, user=self.user, pipeline_index=1, ) self.assertEqual(result, {})
def test_pipeline_returns_json_response_on_post(self): """pipeline step renders json response for POST request and inactive user""" request = create_request(data={'username': '******'}) strategy = load_strategy(request=request) backend = GithubOAuth2(strategy, '/') response = require_activation( strategy=strategy, details={}, backend=backend, user=self.user, pipeline_index=1, ) self.assertEqual(response.status_code, 200) self.assertEqual(response['content-type'], 'application/json') self.assertJsonResponseEquals(response, { 'step': 'done', 'backend_name': 'GitHub', 'activation': 'admin', 'email': '*****@*****.**', 'username': '******', })