Exemplo n.º 1
0
 def test_generate_oauth_signature_valid_no_client_keys(self):
     consumer = Consumer(CONSUMER_TOKEN, CONSUMER_SECRET)
     client = Client()
     service = Service(consumer)
     parameters = OauthParameters(nonce=DETERM_NONCE, oauth_consumer_key=CONSUMER_TOKEN, timestamp=DETERM_TIMESTAMP)
     signature = service._generate_signature(URL, METHOD, client, parameters, QUERY)
     assert (signature == EXPECTED_SIGNATURE_EMPTY_CLIENT)
Exemplo n.º 2
0
 def check_random_oauth_signature(self):
     random.seed()
     debug('Using seed {}'.format(random.getstate))
     methods = ('GET', 'POST', 'PUT', 'DELETE')
     consumer = Consumer(hashlib.sha1(str(random.random())).hexdigest()[:30],
                         hashlib.sha1(str(random.random())).hexdigest()[:30])
     client = Client(hashlib.sha1(str(random.random())).hexdigest()[:30],
                     hashlib.sha1(str(random.random())).hexdigest()[:20])
     method = methods[random.randint(0, len(methods) - 1)]
     url = 'https://www.example.com'
     oauth_parameters = OauthParameters(nonce=hashlib.sha1(str(random.random())).hexdigest(),
                                        oauth_consumer_key=consumer.consumer_key,
                                        timestamp=str(random.randint(0, 2 ** 32 - 1)))
     service = Service(consumer)
     signature = service._generate_signature(url, method, client, oauth_parameters)
     assert signature
Exemplo n.º 3
0
 def test_generate_oauth_signature_null_method(self):
     consumer = Consumer(CONSUMER_TOKEN, CONSUMER_SECRET)
     client = Client()
     service = Service(consumer)
     parameters = OauthParameters(nonce=DETERM_NONCE, oauth_consumer_key=CONSUMER_TOKEN, timestamp=DETERM_TIMESTAMP)
     service._generate_signature('', METHOD, client, parameters, QUERY)