def testDecorator_GET(self):
     called = mock.Mock()
     called.__name__ = 'called'
     wrapped = csrfutil.csrf_protect(called)
     with self.app.test_request_context('/'):
         wrapped()
     called.assert_called_once()
Beispiel #2
0
 def testDecorator_GET(self):
     called = mock.Mock()
     called.__name__ = 'called'
     wrapped = csrfutil.csrf_protect(called)
     with self.app.test_request_context('/'):
         wrapped()
     called.assert_called_once()
 def testDecorator_Passes(self, mock_verify):
     mock_verify.return_value = True
     called = mock.Mock()
     called.__name__ = 'called'
     wrapped = csrfutil.csrf_protect(called)
     with self.app.test_request_context('/?csrftoken=x', method='POST'):
         wrapped()
     called.assert_called_once()
Beispiel #4
0
 def testDecorator_Passes(self, mock_verify):
     mock_verify.return_value = True
     called = mock.Mock()
     called.__name__ = 'called'
     wrapped = csrfutil.csrf_protect(called)
     with self.app.test_request_context('/?csrftoken=x', method='POST'):
         wrapped()
     called.assert_called_once()
 def testDecorator_Fails(self, mock_verify):
     mock_verify.return_value = False
     called = mock.Mock()
     called.__name__ = 'called'
     wrapped = csrfutil.csrf_protect(called)
     with self.app.test_request_context('/', method='POST'):
         with self.assertRaises(exceptions.Forbidden):
             wrapped()
     called.assert_not_called()
Beispiel #6
0
 def testDecorator_Fails(self, mock_verify):
     mock_verify.return_value = False
     called = mock.Mock()
     called.__name__ = 'called'
     wrapped = csrfutil.csrf_protect(called)
     with self.app.test_request_context('/', method='POST'):
         with self.assertRaises(exceptions.Forbidden):
             wrapped()
     called.assert_not_called()