def test_refresh_token(self): api = APIManager("CLIENT_ID", "CLIENT_SECRET", self.server.path) api.access_token['requested_at'] = datetime.datetime.now( ) - datetime.timedelta(hours=2) self.assertFalse(api.is_access_token_valid()) api.get("api_manager?parameter") self.assertTrue(api.is_access_token_valid())
def test_refresh_token(self): api = APIManager("CLIENT_ID", "CLIENT_SECRET", self.server.path, compression_enabled=False, backoff_config=None, token_override=None) api.access_token['requested_at'] = datetime.datetime.now( ) - datetime.timedelta(hours=2) self.assertFalse(api.is_access_token_valid()) api.get("/api/v3/api_manager?parameter") self.assertTrue(api.is_access_token_valid())
def test_authorization_static_token(self): api = APIManager(None, None, self.server.path, compression_enabled=False, backoff_config=None, token_override="static_token") r = api.get("/api/v3/api_manager") self.assertIn('Authorization', r.request.headers) self.assertEqual(r.request.headers['Authorization'], 'Bearer static_token') r = api.post("/api/v3/api_manager", {}) self.assertIn('Authorization', r.request.headers) self.assertEqual(r.request.headers['Authorization'], 'Bearer static_token') r = api.put("/api/v3/api_manager", {}) self.assertIn('Authorization', r.request.headers) self.assertEqual(r.request.headers['Authorization'], 'Bearer static_token') r = api.delete("/api/v3/api_manager") self.assertIn('Authorization', r.request.headers) self.assertEqual(r.request.headers['Authorization'], 'Bearer static_token')