Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix invalid value for property api_endpoint_overrides/storage #1683

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions gslib/tests/test_shim_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -1082,7 +1082,7 @@ def test_gcs_json_endpoint_translation(self):
self.assertEqual(
env_vars, {
'CLOUDSDK_API_ENDPOINT_OVERRIDES_STORAGE':
'https://foo_host:1234/storage/v2',
'https://foo_host:1234/storage/v2/',
})

def test_gcs_json_endpoint_translation_with_missing_port(self):
Expand All @@ -1094,10 +1094,11 @@ def test_gcs_json_endpoint_translation_with_missing_port(self):
}):
flags, env_vars = self._fake_command._translate_boto_config()
self.assertEqual(flags, [])
self.assertEqual(env_vars, {
'CLOUDSDK_API_ENDPOINT_OVERRIDES_STORAGE':
'https://foo_host/storage/v2',
})
self.assertEqual(
env_vars, {
'CLOUDSDK_API_ENDPOINT_OVERRIDES_STORAGE':
'https://foo_host/storage/v2/',
})

def test_gcs_json_endpoint_translation_usees_default_version_v1(self):
with _mock_boto_config(
Expand All @@ -1110,9 +1111,24 @@ def test_gcs_json_endpoint_translation_usees_default_version_v1(self):
self.assertEqual(
env_vars, {
'CLOUDSDK_API_ENDPOINT_OVERRIDES_STORAGE':
'https://foo_host:1234/storage/v1'
'https://foo_host:1234/storage/v1/'
})

def test_gcs_json_endpoint_translation_should_start_with_https(self):
carlosmerec marked this conversation as resolved.
Show resolved Hide resolved
with _mock_boto_config({'Credentials': {'gs_json_host': 'foo_host',}}):
flags, env_vars = self._fake_command._translate_boto_config()
self.assertEqual(flags, [])
self.assertTrue(
env_vars['CLOUDSDK_API_ENDPOINT_OVERRIDES_STORAGE'].startswith(
'https://'))

def test_gcs_json_endpoint_translation_should_end_with_trailing_slash(self):
carlosmerec marked this conversation as resolved.
Show resolved Hide resolved
with _mock_boto_config({'Credentials': {'gs_json_host': 'foo_host',}}):
flags, env_vars = self._fake_command._translate_boto_config()
self.assertEqual(flags, [])
self.assertTrue(
env_vars['CLOUDSDK_API_ENDPOINT_OVERRIDES_STORAGE'].endswith('v1/'))

def test_s3_endpoint_translation(self):
with _mock_boto_config(
{'Credentials': {
Expand Down
4 changes: 2 additions & 2 deletions gslib/utils/shim_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ def _get_gcs_json_endpoint_from_boto_config(config):
gs_json_port = config.get('Credentials', 'gs_json_port')
port = ':' + gs_json_port if gs_json_port else ''
json_api_version = config.get('Credentials', 'json_api_version', 'v1')
return 'https://{}{}/storage/{}'.format(gs_json_host, port,
json_api_version)
return 'https://{}{}/storage/{}/'.format(gs_json_host, port,
json_api_version)
return None


Expand Down