libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anthonys...@apache.org
Subject [1/3] libcloud git commit: google: Prevent GCE auth to hide S3 auth
Date Wed, 09 Nov 2016 22:52:03 GMT
Repository: libcloud
Updated Branches:
  refs/heads/trunk 095db8bfd -> a58a6e5fa


google: Prevent GCE auth to hide S3 auth

GoogleAuthType._is_gce() is going to return True on any GCE instance,
but if there are S3 credentials, they should be used.

Closes #921


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/8bedf247
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/8bedf247
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/8bedf247

Branch: refs/heads/trunk
Commit: 8bedf2472401186ca1038719a0cdd66155f833f5
Parents: 3b515f4
Author: Quentin Pradet <quentin@clustree.com>
Authored: Fri Oct 21 16:46:11 2016 +0400
Committer: Anthony Shaw <anthonyshaw@apache.org>
Committed: Thu Nov 10 09:46:34 2016 +1100

----------------------------------------------------------------------
 libcloud/common/google.py           |  4 ++--
 libcloud/test/common/test_google.py | 13 ++++++++-----
 2 files changed, 10 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/8bedf247/libcloud/common/google.py
----------------------------------------------------------------------
diff --git a/libcloud/common/google.py b/libcloud/common/google.py
index 52577b8..39d94e4 100644
--- a/libcloud/common/google.py
+++ b/libcloud/common/google.py
@@ -583,10 +583,10 @@ class GoogleAuthType(object):
     def guess_type(cls, user_id):
         if cls._is_sa(user_id):
             return cls.SA
-        elif cls._is_gce():
-            return cls.GCE
         elif cls._is_gcs_s3(user_id):
             return cls.GCS_S3
+        elif cls._is_gce():
+            return cls.GCE
         else:
             return cls.IA
 

http://git-wip-us.apache.org/repos/asf/libcloud/blob/8bedf247/libcloud/test/common/test_google.py
----------------------------------------------------------------------
diff --git a/libcloud/test/common/test_google.py b/libcloud/test/common/test_google.py
index 2266ddd..1977dab 100644
--- a/libcloud/test/common/test_google.py
+++ b/libcloud/test/common/test_google.py
@@ -223,16 +223,19 @@ class GoogleInstalledAppAuthConnectionTest(GoogleTestCase):
 class GoogleAuthTypeTest(GoogleTestCase):
 
     def test_guess(self):
-        self.assertEqual(GoogleAuthType.guess_type(GCE_PARAMS[0]),
-                         GoogleAuthType.SA)
         self.assertEqual(GoogleAuthType.guess_type(GCE_PARAMS_IA[0]),
                          GoogleAuthType.IA)
         with mock.patch.object(GoogleAuthType, '_is_gce', return_value=True):
+            # Since _is_gce currently depends on the environment, not on
+            # parameters, other auths should override GCE. It does not make
+            # sense for IA auth to happen on GCE, which is why it's left out.
+            self.assertEqual(GoogleAuthType.guess_type(GCE_PARAMS[0]),
+                             GoogleAuthType.SA)
+            self.assertEqual(
+                GoogleAuthType.guess_type(GCS_S3_PARAMS[0]),
+                GoogleAuthType.GCS_S3)
             self.assertEqual(GoogleAuthType.guess_type(GCE_PARAMS_GCE[0]),
                              GoogleAuthType.GCE)
-        self.assertEqual(
-            GoogleAuthType.guess_type(GCS_S3_PARAMS[0]),
-            GoogleAuthType.GCS_S3)
 
 
 class GoogleOAuth2CredentialTest(GoogleTestCase):


Mime
View raw message