def test_refresh_tokens_callback(self): orig_token = make_uaa_oauth_token(2) refreshed_token = make_uaa_oauth_token(2) self.assertNotEqual(orig_token['access_token'], refreshed_token['access_token']) prepare_request(cc_api_url, 'GET', 'info', body=cc_v2_info) prepare_request(uaa_api_url, 'POST', 'oauth/token', body=orig_token, version=None) prepare_request(cc_api_url, 'GET', 'apps') prepare_request(uaa_api_url, 'POST', 'oauth/token', body=refreshed_token, version=None) prepare_request(cc_api_url, 'GET', 'apps') cc = cf_api.new_cloud_controller( cc_api_url, client_id='abc', client_secret='', verify_ssl=False, ) cc.set_refresh_tokens_callback() app = cc.apps().get().resource self.assertIsInstance(app, cf_api.Resource) self.assertEqual(cc.uaa.get_access_token().to_string(), orig_token['access_token']) time.sleep(2) app = cc.apps().get().resource self.assertIsInstance(app, cf_api.Resource) self.assertEqual(cc.uaa.get_access_token().to_string(), refreshed_token['access_token'])
def test_get_all_resources(self): prepare_request(cc_api_url, 'GET', 'apps', body=make_response_list(2, 'apps', 1, next_url='apps')) prepare_request(cc_api_url, 'GET', 'apps', body=make_response_list(2, 'apps', 1)) cc = cf_api.new_cloud_controller( cc_api_url, client_id='abc', client_secret='', verify_ssl=False, ) req = cc.apps() apps = cc.get_all_resources(req) self.assertIsInstance(apps, list) self.assertIsInstance(apps[0], cf_api.Resource) self.assertEqual(2, len(apps))
def setUp(self): prepare_request(cc_api_url, 'GET', 'info', body=cc_v2_info) prepare_request(uaa_api_url, 'POST', 'oauth/token', body=uaa_oauth_token, version=None)
def wrap(self): req = prepare_request(self.cc, method, endpoint, guid1, relation, guid2, **kwargs) return func(self, req)