cors-tests: Default S3_ENDPOINT sensibly

If it's not provided, don't assume localhost; use the scheme/netloc
from OS_STORAGE_URL.

Change-Id: I0877099cb044cf8aaaeb6af0b4e1332fac00b10b
This commit is contained in:
Tim Burke
2025-03-06 17:10:01 -08:00
parent 5554f432f5
commit cfa0094eb4

View File

@@ -40,7 +40,7 @@ DEFAULT_ENV = {
'OS_USERNAME': os.environ.get('ST_USER', 'test:tester'), 'OS_USERNAME': os.environ.get('ST_USER', 'test:tester'),
'OS_PASSWORD': os.environ.get('ST_KEY', 'testing'), 'OS_PASSWORD': os.environ.get('ST_KEY', 'testing'),
'OS_STORAGE_URL': None, 'OS_STORAGE_URL': None,
'S3_ENDPOINT': 'http://localhost:8080', 'S3_ENDPOINT': None,
'S3_USER': 'test:tester', 'S3_USER': 'test:tester',
'S3_KEY': 'testing', 'S3_KEY': 'testing',
} }
@@ -316,6 +316,8 @@ with the --no-setup, --no-serve, and --no-run options.
ENV['OS_USERNAME'], ENV['OS_USERNAME'],
ENV['OS_PASSWORD'], ENV['OS_PASSWORD'],
timeout=1)[0] timeout=1)[0]
if ENV['S3_ENDPOINT'] is None:
ENV['S3_ENDPOINT'] = ENV['OS_STORAGE_URL'].partition('/v1')[0]
url = 'http://%s:%d/#%s' % (args.hostname, args.port, '&'.join( url = 'http://%s:%d/#%s' % (args.hostname, args.port, '&'.join(
'%s=%s' % (urllib.parse.quote(key), urllib.parse.quote(val)) '%s=%s' % (urllib.parse.quote(key), urllib.parse.quote(val))