Repository: libcloud Updated Branches: refs/heads/trunk 5c962166e -> 1437fc317
Fix _is_gcs_s3 to accept access keys of more than 20 chars Google Cloud Storage currently emits access keys of more than 20 characters Signed-off-by: Rick van de Loo <rickvande...@gmail.com> Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/9b9aae72 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/9b9aae72 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/9b9aae72 Branch: refs/heads/trunk Commit: 9b9aae720d34698b6284f8b6800fd8ae569ecb82 Parents: 5c96216 Author: Yoan Tournade <y...@ytotech.com> Authored: Fri Dec 28 01:54:29 2018 +0100 Committer: Rick van de Loo <rickvande...@gmail.com> Committed: Fri Jan 4 11:10:47 2019 +0100 ---------------------------------------------------------------------- libcloud/common/google.py | 7 +++++-- libcloud/test/common/test_google.py | 9 +++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/9b9aae72/libcloud/common/google.py ---------------------------------------------------------------------- diff --git a/libcloud/common/google.py b/libcloud/common/google.py index 806e022..9648ee1 100644 --- a/libcloud/common/google.py +++ b/libcloud/common/google.py @@ -610,9 +610,12 @@ class GoogleAuthType(object): @staticmethod def _is_gcs_s3(user_id): """ - Checks S3 key format: 20 alphanumeric chars starting with GOOG. + Checks S3 key format: alphanumeric chars starting with GOOG. """ - return len(user_id) == 20 and user_id.startswith('GOOG') + return ( + len(user_id) >= 20 and len(user_id) < 30 and user_id + .startswith('GOOG') + ) @staticmethod def _is_sa(user_id): http://git-wip-us.apache.org/repos/asf/libcloud/blob/9b9aae72/libcloud/test/common/test_google.py ---------------------------------------------------------------------- diff --git a/libcloud/test/common/test_google.py b/libcloud/test/common/test_google.py index a166910..d01dc42 100644 --- a/libcloud/test/common/test_google.py +++ b/libcloud/test/common/test_google.py @@ -60,7 +60,9 @@ GCE_PARAMS_JSON_KEY = ('em...@developer.gserviceaccount.com', JSON_KEY) GCE_PARAMS_KEY = ('em...@developer.gserviceaccount.com', KEY_STR) GCE_PARAMS_IA = ('client_id', 'client_secret') GCE_PARAMS_GCE = ('foo', 'bar') -GCS_S3_PARAMS = ('GOOG0123456789ABCXYZ', # GOOG + 16 alphanumeric chars +GCS_S3_PARAMS_20 = ('GOOG0123456789ABCXYZ', # GOOG + 16 alphanumeric chars + '0102030405060708091011121314151617181920') # 40 base64 chars +GCS_S3_PARAMS_24 = ('GOOGDF5OVRRGU4APFNSTVCXI', # GOOG + 20 alphanumeric chars '0102030405060708091011121314151617181920') # 40 base64 chars STUB_UTCNOW = _utcnow() @@ -230,7 +232,10 @@ class GoogleAuthTypeTest(GoogleTestCase): self.assertEqual(GoogleAuthType.guess_type(GCE_PARAMS[0]), GoogleAuthType.SA) self.assertEqual( - GoogleAuthType.guess_type(GCS_S3_PARAMS[0]), + GoogleAuthType.guess_type(GCS_S3_PARAMS_20[0]), + GoogleAuthType.GCS_S3) + self.assertEqual( + GoogleAuthType.guess_type(GCS_S3_PARAMS_24[0]), GoogleAuthType.GCS_S3) self.assertEqual(GoogleAuthType.guess_type(GCE_PARAMS_GCE[0]), GoogleAuthType.GCE)