def test_membership_requires_authentication(self): request = utils.get_request( 'post', '/hub/community/membership/', user=utils.get_anon_mock()) response = views.hub_membership(request, 'community') eq_(response.status_code, 302) eq_(response['Location'], utils.get_login_url('/hub/community/membership/'))
def test_entry_request_requires_authentication(self): request = utils.get_request( 'get', '/challenges/foo/enter/abc/', user=utils.get_anon_mock()) response = views.challenge_entry(request, 'foo', 'abc') eq_(response.status_code, 302) eq_(response['Location'], utils.get_login_url('/challenges/foo/enter/abc/'))
def test_decorator_require_authenticated_user(self): request = self.factory.get('/custom-url/') request.user = _get_non_auth_user_mock() view = decorators.group_required(['foo'])(dummy_view) response = view(request) expected_url = utils.get_login_url('http%3A//testserver/custom-url/') eq_(response['Location'], expected_url)
def test_entry_detail_requires_authentication(self): request = utils.get_request( 'get', '/challenges/gigabit/app/', user=utils.get_anon_mock()) response = views.entry_detail(request, 'gigabit', 'app') eq_(response.status_code, 302) eq_(response['Location'], utils.get_login_url('/challenges/gigabit/app/'))
def test_profile_update_requires_authentication(self): url = '/accounts/profile/' data = { 'name': 'John Donne', } response = self.client.post(url, data) assert_redirects(response, utils.get_login_url(url))
def test_post_request_requires_authentication(self): url = '/accounts/password/change/' payload = { 'old_password': '******', 'new_password1': 'hello123', 'new_password2': 'hell0123', } response = self.client.post(url, payload) assert_redirects(response, utils.get_login_url(url))
def test_view_requires_authentication(self): request = utils.get_request( 'get', '/org/foo/edit/', user=utils.get_anon_mock()) response = views.organization_edit(request, 'foo') eq_(response.status_code, 302) eq_(response['Location'], utils.get_login_url('/org/foo/edit/'))
def test_view_requires_authentication(self): request = utils.get_request("get", "/org/foo/edit/", user=utils.get_anon_mock()) response = views.organization_edit(request, "foo") eq_(response.status_code, 302) eq_(response["Location"], utils.get_login_url("/org/foo/edit/"))
def test_export_requires_login(self): request = self.factory.get('/app/blue/export/') request.user = utils.get_anon_mock() response = views.app_export(request, 'blue') expected_url = utils.get_login_url('/app/blue/export/') eq_(response['Location'], expected_url)
def test_anon_post_requires_login(self): request = self.factory.post('/app/app/version/', {}) request.user = utils.get_anon_mock() response = views.app_version_add(request) expected_url = utils.get_login_url('/app/app/version/') eq_(response['Location'], expected_url)
def test_anon_get_request_require_login(self): request = self.factory.get('/app/my-app/edit/') request.user = utils.get_anon_mock() response = views.app_edit(request) eq_(response['Location'], utils.get_login_url('/app/my-app/edit/'))
def test_people_page_detail_requires_auth(self): user = fixtures.get_user('us-ignite') fixtures.get_profile(user=user, name='us ignite', slug='ignite') response = self.client.get('/people/ignite/') assert_redirects(response, utils.get_login_url('/people/ignite/')) _teardown_profiles()
def test_people_list_requires_auth(self): url = '/people/' response = self.client.get(url) assert_redirects(response, utils.get_login_url(url))
def test_dashboard_requires_authentication(self): request = utils.get_request( 'get', '/dashboard/', user=utils.get_anon_mock()) response = views.dashboard(request) eq_(response['Location'], utils.get_login_url('/dashboard/'))
def test_profile_list_requires_authentication(self): request = self.factory.get('/people/') request.user = utils.get_anon_mock() response = views.profile_list(request) eq_(response.status_code, 302) eq_(response['Location'], utils.get_login_url('/people/'))
def test_anon_request_fails(self): user = utils.get_anon_mock() request = utils.get_request('get', '/hub/community/edit/', user=user) response = views.hub_edit(request, 'community') eq_(response.status_code, 302) eq_(response['Location'], utils.get_login_url('/hub/community/edit/'))
def test_hub_application_requires_login(self): request = utils.get_request( 'get', '/hub/apply/', user=utils.get_anon_mock()) response = views.hub_application(request) eq_(response.status_code, 302) eq_(response['Location'], utils.get_login_url('/hub/apply/'))
def test_page_requires_authentication(self): url = '/accounts/password/change/done/' response = self.client.get(url) assert_redirects(response, utils.get_login_url(url))
def test_application_post_request_require_login(self): request = self.factory.post('/app/my-app/edit/', _get_message_payload()) request.user = utils.get_anon_mock() response = views.app_edit(request) eq_(response['Location'], utils.get_login_url('/app/my-app/edit/'))
def test_profile_requires_authentication(self): url = '/accounts/profile/' response = self.client.get(url) assert_redirects(response, utils.get_login_url(url))
def test_anon_get_request_require_login(self): request = self.factory.get('/app/b/membership/') request.user = utils.get_anon_mock() response = views.app_membership(request) eq_(response['Location'], utils.get_login_url('/app/b/membership/'))
def test_contact_user_requires_login(self): request = utils.get_request( 'get', '/contact/foo/', user=utils.get_anon_mock()) response = views.contact_user(request, 'foo') eq_(response.status_code, 302) eq_(response['Location'], utils.get_login_url('/contact/foo/'))
def test_application_post_request_require_login(self): request = self.factory.post('/app/my-app/hubs/', {}) request.user = utils.get_anon_mock() response = views.app_hub_membership(request) eq_(response['Location'], utils.get_login_url('/app/my-app/hubs/'))
def test_post_request_profile_requres_authentication(self): request = self.factory.post('/profile/delete/') request.user = utils.get_anon_mock() response = views.user_profile_delete(request) eq_(response.status_code, 302) eq_(response['Location'], utils.get_login_url('/profile/delete/'))
def test_add_event_requires_auth(self): request = utils.get_request("get", "/event/add/", user=utils.get_anon_mock()) response = views.event_add(request) eq_(response.status_code, 302) eq_(response["Location"], utils.get_login_url("/event/add/"))
def test_view_requires_authentication(self): request = utils.get_request( 'get', '/resource/add/', user=utils.get_anon_mock()) response = views.resource_add(request) eq_(response.status_code, 302) eq_(response['Location'], utils.get_login_url('/resource/add/'))