Add support for AWS China endpoints (#3661)
This commit is contained in:
		
							parent
							
								
									f50d80ede6
								
							
						
					
					
						commit
						24ed6c8d34
					
				@ -1,7 +1,7 @@
 | 
			
		||||
from __future__ import unicode_literals
 | 
			
		||||
from .responses import LambdaResponse
 | 
			
		||||
 | 
			
		||||
url_bases = [r"https?://lambda\.(.+)\.amazonaws\.com(|.cn)"]
 | 
			
		||||
url_bases = [r"https?://lambda\.(.+)\.amazonaws\.com"]
 | 
			
		||||
 | 
			
		||||
response = LambdaResponse()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -661,9 +661,14 @@ class BaseBackend:
 | 
			
		||||
 | 
			
		||||
        urls = {}
 | 
			
		||||
        for url_base in url_bases:
 | 
			
		||||
            # The default URL_base will look like: http://service.[..].amazonaws.com/...
 | 
			
		||||
            # This extension ensures support for the China regions
 | 
			
		||||
            cn_url_base = re.sub(r"amazonaws\\?.com$", "amazonaws.com.cn", url_base)
 | 
			
		||||
            for url_path, handler in unformatted_paths.items():
 | 
			
		||||
                url = url_path.format(url_base)
 | 
			
		||||
                urls[url] = handler
 | 
			
		||||
                cn_url = url_path.format(cn_url_base)
 | 
			
		||||
                urls[cn_url] = handler
 | 
			
		||||
 | 
			
		||||
        return urls
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -4664,7 +4664,9 @@ class SubnetBackend(object):
 | 
			
		||||
 | 
			
		||||
    def get_all_subnets(self, subnet_ids=None, filters=None):
 | 
			
		||||
        # Extract a list of all subnets
 | 
			
		||||
        matches = itertools.chain(*[x.values() for x in self.subnets.values()])
 | 
			
		||||
        matches = itertools.chain(
 | 
			
		||||
            *[x.copy().values() for x in self.subnets.copy().values()]
 | 
			
		||||
        )
 | 
			
		||||
        if subnet_ids:
 | 
			
		||||
            matches = [sn for sn in matches if sn.id in subnet_ids]
 | 
			
		||||
            if len(subnet_ids) > len(matches):
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,6 @@
 | 
			
		||||
from __future__ import unicode_literals
 | 
			
		||||
from .responses import TokenResponse
 | 
			
		||||
 | 
			
		||||
url_bases = [r"https?://sts\.(.*\.)?amazonaws\.com(|.cn)"]
 | 
			
		||||
url_bases = [r"https?://sts\.(.*\.)?amazonaws\.com"]
 | 
			
		||||
 | 
			
		||||
url_paths = {"{0}/$": TokenResponse.dispatch}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										12
									
								
								tests/test_batch/test_batch.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								tests/test_batch/test_batch.py
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,12 @@
 | 
			
		||||
import boto3
 | 
			
		||||
import pytest
 | 
			
		||||
 | 
			
		||||
from moto import mock_batch
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@pytest.mark.parametrize("region", ["us-west-2", "cn-northwest-1"])
 | 
			
		||||
@mock_batch
 | 
			
		||||
def test_batch_regions(region):
 | 
			
		||||
    client = boto3.client("batch", region_name=region)
 | 
			
		||||
    resp = client.describe_jobs(jobs=[""])
 | 
			
		||||
    resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)
 | 
			
		||||
@ -924,6 +924,14 @@ def test_state_machine_get_execution_history_contains_expected_success_events_wh
 | 
			
		||||
    execution_history["events"].should.equal(expected_events)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@pytest.mark.parametrize("region", ["us-west-2", "cn-northwest-1"])
 | 
			
		||||
@mock_stepfunctions
 | 
			
		||||
def test_stepfunction_regions(region):
 | 
			
		||||
    client = boto3.client("stepfunctions", region_name=region)
 | 
			
		||||
    resp = client.list_state_machines()
 | 
			
		||||
    resp["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@mock_stepfunctions
 | 
			
		||||
@mock_sts
 | 
			
		||||
@mock.patch.dict(os.environ, {"SF_EXECUTION_HISTORY_TYPE": "FAILURE"})
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user