Esempio n. 1
0
 def test__deletes_nonce(self):
     oauth_consumer_key = factory.make_string(18)
     oauth_token = factory.make_string(18)
     oauth_nonce = randint(0, 99999)
     Nonce.objects.create(consumer_key=oauth_consumer_key,
                          token_key=oauth_token,
                          key=oauth_nonce)
     oauth_env = {
         'oauth_consumer_key': oauth_consumer_key,
         'oauth_token': oauth_token,
         'oauth_nonce': oauth_nonce,
     }
     request = make_request(oauth_env=oauth_env)
     views.delete_oauth_nonce(request)
     with ExpectedException(Nonce.DoesNotExist):
         Nonce.objects.get(consumer_key=oauth_consumer_key,
                           token_key=oauth_token,
                           key=oauth_nonce)
Esempio n. 2
0
 def test_skips_missing_nonce(self):
     oauth_consumer_key = factory.make_string(18)
     oauth_token = factory.make_string(18)
     oauth_nonce = randint(0, 99999)
     oauth_env = {
         "oauth_consumer_key": oauth_consumer_key,
         "oauth_token": oauth_token,
         "oauth_nonce": oauth_nonce,
     }
     request = make_request(oauth_env=oauth_env)
     # No exception is raised.
     self.assertIsNone(views.delete_oauth_nonce(request))
Esempio n. 3
0
 def test_skips_oauth_request_with_missing_param(self):
     missing_params = ("oauth_consumer_key", "oauth_token", "oauth_nonce")
     for missing_param in missing_params:
         request = make_request(missing_oauth_param=missing_param)
         # No exception is raised.
         self.assertIsNone(views.delete_oauth_nonce(request))
Esempio n. 4
0
 def test_skips_non_oauth_request(self):
     request = make_request(env={"HTTP_AUTHORIZATION": ""})
     # No exception is raised.
     self.assertIsNone(views.delete_oauth_nonce(request))