Example #1
0
 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/'))
Example #2
0
 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/'))
Example #3
0
 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)
Example #4
0
 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/'))
Example #5
0
 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))
Example #6
0
 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))
Example #7
0
 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/'))
Example #8
0
 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/"))
Example #9
0
 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)
Example #10
0
 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)
Example #11
0
 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/'))
Example #12
0
 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()
Example #13
0
 def test_people_list_requires_auth(self):
     url = '/people/'
     response = self.client.get(url)
     assert_redirects(response, utils.get_login_url(url))
Example #14
0
 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/'))
Example #15
0
 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/'))
Example #16
0
 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/'))
Example #17
0
 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/'))
Example #18
0
 def test_page_requires_authentication(self):
     url = '/accounts/password/change/done/'
     response = self.client.get(url)
     assert_redirects(response, utils.get_login_url(url))
Example #19
0
 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/'))
Example #20
0
 def test_profile_requires_authentication(self):
     url = '/accounts/profile/'
     response = self.client.get(url)
     assert_redirects(response, utils.get_login_url(url))
Example #21
0
 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/'))
Example #22
0
 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/'))
Example #23
0
 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/'))
Example #24
0
 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/'))
Example #25
0
 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/"))
Example #26
0
 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/'))