Пример #1
0
 def testVerifyCSRFToken_Truncated(self, mock_time):
     mock_time.return_value = self.base_clock
     token = self.valid_token[:4]
     with self.assertRaises(struct.error):
         csrfutil.verify_csrf_token(token, self.test_user)
     mock_time.reset_mock()
     token = 'a'
     self.assertFalse(csrfutil.verify_csrf_token(token, self.test_user))
     mock_time.assert_not_called()
Пример #2
0
 def testVerifyCSRFToken_Truncated(self, mock_time):
     mock_time.return_value = self.base_clock
     token = self.valid_token[:4]
     with self.assertRaises(struct.error):
         csrfutil.verify_csrf_token(token, self.test_user)
     mock_time.reset_mock()
     token = 'a'
     self.assertFalse(csrfutil.verify_csrf_token(token, self.test_user))
     mock_time.assert_not_called()
Пример #3
0
 def testVerifyCSRFToken_TamperedTime(self, mock_time):
     mock_time.return_value = self.base_clock
     token = self.valid_token.replace('dMv', 'xxx')
     self.assertFalse(csrfutil.verify_csrf_token(token, self.test_user))
     mock_time.assert_called_once_with()
Пример #4
0
 def testVerifyCSRFToken_Expired(self, mock_time):
     mock_time.return_value = self.base_clock + (60 * 60 * 60)
     self.assertFalse(
         csrfutil.verify_csrf_token(self.valid_token, self.test_user))
     mock_time.assert_called_once_with()
Пример #5
0
 def testVerifyCSRFToken_Valid(self, mock_time):
     mock_time.return_value = self.base_clock
     self.assertTrue(
         csrfutil.verify_csrf_token(self.valid_token, self.test_user))
     mock_time.assert_called_once_with()
Пример #6
0
 def testVerifyCSRFToken_TamperedTime(self, mock_time):
     mock_time.return_value = self.base_clock
     token = self.valid_token.replace('dMv', 'xxx')
     self.assertFalse(csrfutil.verify_csrf_token(token, self.test_user))
     mock_time.assert_called_once_with()
Пример #7
0
 def testVerifyCSRFToken_Expired(self, mock_time):
     mock_time.return_value = self.base_clock + (60 * 60 * 60)
     self.assertFalse(csrfutil.verify_csrf_token(
         self.valid_token, self.test_user))
     mock_time.assert_called_once_with()
Пример #8
0
 def testVerifyCSRFToken_Valid(self, mock_time):
     mock_time.return_value = self.base_clock
     self.assertTrue(csrfutil.verify_csrf_token(
         self.valid_token, self.test_user))
     mock_time.assert_called_once_with()