Path: blob/develop/tests/unit/customizations/test_overridesslcommonname.py
1567 views
# Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.1#2# Licensed under the Apache License, Version 2.0 (the "License"). You3# may not use this file except in compliance with the License. A copy of4# the License is located at5#6# http://aws.amazon.com/apache2.0/7#8# or in the "license" file accompanying this file. This file is9# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF10# ANY KIND, either express or implied. See the License for the specific11# language governing permissions and limitations under the License.1213from awscli.testutils import create_clidriver14from awscli.customizations.overridesslcommonname import (15update_endpoint_url,16SSL_COMMON_NAMES,17)1819import pytest20import argparse212223def parameters():24for service, regions in SSL_COMMON_NAMES.items():25for region in regions:26yield (service, region)272829@pytest.fixture30def parsed_globals():31pg = argparse.Namespace()32pg.endpoint_url = None33pg.region = None34return pg353637@pytest.fixture38def session():39driver = create_clidriver()40return driver.session414243@pytest.mark.parametrize("service,region", parameters())44def test_update_endpoint_url(parsed_globals, session, service, region):45parsed_globals.command = service46session.set_config_variable("region", region)47update_endpoint_url(session, parsed_globals)48assert parsed_globals.endpoint_url == (49f"https://{SSL_COMMON_NAMES[service][region]}"50)515253@pytest.mark.parametrize("service,region", parameters())54def test_url_modified_from_event(parsed_globals, session, service, region):55assert parsed_globals.endpoint_url is None56parsed_globals.command = service57session.set_config_variable("region", region)58session.emit(59f"before-building-argument-table-parser.{service}",60args=[],61session=session,62argument_table={},63parsed_globals=parsed_globals,64)65assert parsed_globals.endpoint_url == (66f"https://{SSL_COMMON_NAMES[service][region]}"67)686970def test_dont_modify_provided_url(parsed_globals, session):71parsed_globals.endpoint_url = "http://test.com"72parsed_globals.command = "sqs"73update_endpoint_url(session, parsed_globals)74assert parsed_globals.endpoint_url == "http://test.com"757677