update
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/e459ef68 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/e459ef68 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/e459ef68 Branch: refs/heads/trunk Commit: e459ef6812441e391399815b0364363d1cb477f8 Parents: 06c8ccb Author: andy <andymahe...@gmail.com> Authored: Sat Jun 17 17:40:36 2017 -0400 Committer: andy <andymahe...@gmail.com> Committed: Sat Jun 17 17:40:36 2017 -0400 ---------------------------------------------------------------------- libcloud/test/container/test_gke.py | 30 +++++++++++++++++++++++++----- libcloud/test/secrets.py-dist | 4 ++++ 2 files changed, 29 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/e459ef68/libcloud/test/container/test_gke.py ---------------------------------------------------------------------- diff --git a/libcloud/test/container/test_gke.py b/libcloud/test/container/test_gke.py index faa35c1..f38e5f5 100644 --- a/libcloud/test/container/test_gke.py +++ b/libcloud/test/container/test_gke.py @@ -35,9 +35,9 @@ from libcloud.compute.base import Node, StorageVolume from libcloud.test import MockHttp from libcloud.test.compute import TestCaseMixin -from libcloud.test.file_fixtures import ComputeFileFixtures +from libcloud.test.file_fixtures import ContainerFileFixtures -from libcloud.test.secrets import GCE_PARAMS, GCE_KEYWORD_PARAMS +from libcloud.test.secrets import GKE_PARAMS, GKE_KEYWORD_PARAMS class GKEContainerDriverTestCase(GoogleTestCase, TestCaseMixin): @@ -50,10 +50,10 @@ class GKEContainerDriverTestCase(GoogleTestCase, TestCaseMixin): datacenter = 'us-central1-a' def setUp(self): - GCEMockHttp.test = self - GCENodeDriver.connectionCls.conn_class = GCEMockHttp + GKEMockHttp.test = self + GKEContainerDriver.connectionCls.conn_class = GCEMockHttp GoogleBaseAuthConnection.conn_class = GoogleAuthMockHttp - GCEMockHttp.type = None + GKEMockHttp.type = None kwargs = GCE_KEYWORD_PARAMS.copy() kwargs['auth_type'] = 'IA' kwargs['datacenter'] = self.datacenter @@ -61,3 +61,23 @@ class GKEContainerDriverTestCase(GoogleTestCase, TestCaseMixin): def test_default_scopes(self): self.assertEqual(self.driver.scopes, None) + + +class GCEMockHttp(MockHttp): + fixtures = ContainerFileFixtures('gce') + json_hdr = {'content-type': 'application/json; charset=UTF-8'} + + def _get_method_name(self, type, use_param, qs, path): + api_path = '/container/%s' % API_VERSION + project_path = '/projects/%s' % GKE_KEYWORD_PARAMS['project'] + path = path.replace(api_path, '') + # This replace is separate, since there is a call with a different + # project name + path = path.replace(project_path, '') + # The path to get project information is the base path, so use a fake + # '/project' path instead + if not path: + path = '/project' + method_name = super(GKEMockHttp, self)._get_method_name( + type, use_param, qs, path) + return method_name http://git-wip-us.apache.org/repos/asf/libcloud/blob/e459ef68/libcloud/test/secrets.py-dist ---------------------------------------------------------------------- diff --git a/libcloud/test/secrets.py-dist b/libcloud/test/secrets.py-dist index b7faf32..1b30bf2 100644 --- a/libcloud/test/secrets.py-dist +++ b/libcloud/test/secrets.py-dist @@ -24,6 +24,10 @@ GANDI_PARAMS = ('user',) GCE_PARAMS = ('em...@developer.gserviceaccount.com', 'key') # Service Account Authentication # GCE_PARAMS = ('client_id', 'client_secret') # Installed App Authentication GCE_KEYWORD_PARAMS = {'project': 'project_name'} +GKE_PARAMS = ('em...@developer.gserviceaccount.com', 'key') # Service Account Authentication +# GCE_PARAMS = ('client_id', 'client_secret') # Installed App Authentication +GKE_KEYWORD_PARAMS = {'project': 'project_name'} + HOSTINGCOM_PARAMS = ('user', 'secret') IBM_PARAMS = ('user', 'secret') ONAPP_PARAMS = ('key')