Skip to content

Commit

Permalink
Add client config ignore endpoint tests
Browse files Browse the repository at this point in the history
Add tests to check that setting the client creation parameter to ignore
the configured endpoint URLs is respected.
  • Loading branch information
kdaily committed Jun 27, 2023
1 parent 18be749 commit 63cb45d
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 2 deletions.
27 changes: 27 additions & 0 deletions tests/functional/configured_endpoint_urls/profile-tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@
"default": {},
"endpoint_url_provided":{
"endpoint_url": "https://client-config.endpoint.aws"
},
"ignore_configured_endpoint_urls": {
"ignore_configured_endpoint_urls": true
},
"provide_and_ignore_configured_endpoint_urls": {
"ignore_configured_endpoint_urls": true,
"endpoint_url": "https://client-config.endpoint.aws"
}
},

Expand Down Expand Up @@ -431,6 +438,16 @@
"endpointUrl": "https://s3.fake-region-10.amazonaws.com"
}
},
{
"name": "All configured endpoints ignored due to ignore client config parameter.",
"profile": "global_and_service_specific_s3",
"client_config": "ignore_configured_endpoint_urls",
"environment": "global_and_service_specific_s3",
"service": "s3",
"output": {
"endpointUrl": "https://s3.fake-region-10.amazonaws.com"
}
},
{
"name": "Environment variable and shared config file configured endpoints ignored due to ignore shared config variable and client configured endpoint is used.",
"profile": "ignore_global_and_service_specific_s3",
Expand All @@ -451,6 +468,16 @@
"endpointUrl": "https://client-config.endpoint.aws"
}
},
{
"name": "Environment variable and shared config file configured endpoints ignored due to ignore client config variable and client configured endpoint is used.",
"profile": "global_and_service_specific_s3",
"client_config": "provide_and_ignore_configured_endpoint_urls",
"environment": "global_and_service_specific_s3",
"service": "s3",
"output": {
"endpointUrl": "https://client-config.endpoint.aws"
}
},
{
"name": "DynamoDB service-specific endpoint url shared config variable is used when service-specific S3 shared config variable is also present.",
"profile": "service_specific_dynamodb_and_s3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import botocore.configprovider
import botocore.utils
from botocore.compat import urlsplit
from botocore.config import Config
from tests import ClientHTTPStubber

ENDPOINT_TESTDATA_FILE = Path(__file__).parent / "profile-tests.json"
Expand Down Expand Up @@ -49,8 +50,10 @@ def create_cases():
'expected_endpoint_url': test_case_data['output'][
'endpointUrl'
],
'client_args': test_suite['client_configs'].get(
test_case_data['client_config'], {}
'client_args': get_create_client_args(
test_suite['client_configs'].get(
test_case_data['client_config'], {}
)
),
'config_file_contents': get_config_file_contents(
test_case_data['profile'], test_suite
Expand All @@ -63,6 +66,24 @@ def create_cases():
)


def get_create_client_args(test_case_client_config):
create_client_args = {}

if 'endpoint_url' in test_case_client_config:
create_client_args['endpoint_url'] = test_case_client_config[
'endpoint_url'
]

if 'ignore_configured_endpoint_urls' in test_case_client_config:
create_client_args['config'] = Config(
ignore_configured_endpoint_urls=test_case_client_config[
'ignore_configured_endpoint_urls'
]
)

return create_client_args


def get_config_file_contents(profile_name, test_suite):
profile = test_suite['profiles'][profile_name]

Expand Down

0 comments on commit 63cb45d

Please sign in to comment.