예제 #1
0
 def test_signature_expired(self):
     req = deepcopy(self.req)
     req['headers']['Date'] = eutils.formatdate(int(time()) - 120)
     hs = z(req, self.id_and_key, logger=self.mute_logger)
     req['headers'] = hs.sign_request()
     hv = z(req, self.id_and_key, logger=self.mute_logger)
     self.assertFalse(hv.verify_request())
예제 #2
0
 def test_valid_request(self):
     req = deepcopy(self.req)
     hs = z(req,
            self.id_and_key,
            signature_ttl=120,
            logger=self.mute_logger)
     req['headers'] = hs.sign_request()
     hv = z(req, self.id_and_key, logger=self.mute_logger)
     self.assertTrue(hv.verify_request())
예제 #3
0
 def test_broken_body(self):
     req = deepcopy(self.req)
     hs = z(req,
            self.id_and_key,
            signature_ttl=120,
            logger=self.mute_logger)
     req['headers'] = hs.sign_request()
     req['body'] = 'forsurebodywasntanythinglikethis!'
     hv = z(req, self.id_and_key, logger=self.mute_logger)
     self.assertFalse(hv.verify_request())
예제 #4
0
 def test_bad_digest_header(self):
     req = deepcopy(self.req)
     hs = z(req,
            self.id_and_key,
            signature_ttl=120,
            logger=self.mute_logger)
     req['headers'] = hs.sign_request()
     req['headers']['digest'] = 'bad'
     hv = z(req, self.id_and_key, logger=self.mute_logger)
     self.assertFalse(hv.verify_request())
예제 #5
0
 def test_no_authorize_header(self):
     req = deepcopy(self.req)
     hs = z(req,
            self.id_and_key,
            signature_ttl=120,
            logger=self.mute_logger)
     req['headers'] = hs.sign_request()
     del (req['headers']['authorization'])
     hv = z(req, self.id_and_key, logger=self.mute_logger)
     self.assertFalse(hv.verify_request())
예제 #6
0
 def test_extra_headers(self):
     req = deepcopy(self.req)
     hs = z(req,
            self.id_and_key,
            signature_ttl=120,
            logger=self.mute_logger)
     req['headers'] = hs.sign_request()
     req['headers']['extra_header'] = 'some value'
     hv = z(req, self.id_and_key, logger=self.mute_logger)
     self.assertTrue(hv.verify_request())
예제 #7
0
 def test_100M_body(self):
     req = deepcopy(self.req)
     req['body'] = 100 * (1048576 * 'A')
     hs = z(req,
            self.id_and_key,
            signature_ttl=120,
            logger=self.mute_logger)
     req['headers'] = hs.sign_request()
     hv = z(req, self.id_and_key, logger=self.mute_logger)
     self.assertTrue(hv.verify_request())
예제 #8
0
 def test_none_key_id_request(self):
     pyauthz_api_keys_orig = os.getenv('PYAUTHZ_API_KEYS')
     os.environ['PYAUTHZ_API_KEYS'] = '{"someid": "somekey"}'
     req = deepcopy(self.req)
     hs = z(req,
            self.id_and_key,
            signature_ttl=120,
            logger=self.mute_logger)
     req['headers'] = hs.sign_request()
     hv = z(req, id_and_key=None, logger=self.mute_logger)
     self.assertTrue(hv.verify_request())
     if pyauthz_api_keys_orig:
         os.environ['PYAUTHZ_API_KEYS'] = pyauthz_api_keys_orig