def test_authentication_decorator_denies_requests_with_no_username(self):
     decorator = authenticate(None)
     
     request = testing.DummyRequest()
     request.session['email'] = '*****@*****.**'
     response = decorator(None, request)
     self.assertEqual(response.status, '403 Forbidden')
    def test_authentication_decorator_accepts_requests_username_and_email(self):
        def my_view(request):
            return HTTPOk()

        decorator = authenticate(my_view)
        
        request = testing.DummyRequest()
        request.session['username'] = '******'
        request.session['email'] = '*****@*****.**'
        response = decorator(testing.DummyResource, request)

        self.assertEqual(response.status, '200 OK')
 def test_authentication_decorator_denies_requests_with_no_session(self):
     decorator = authenticate(None)
     
     request = testing.DummyRequest()
     response = decorator(None, request)
     self.assertEqual(response.status, '403 Forbidden')