conflicts

This commit is contained in:
usmankb 2020-04-08 22:00:48 +05:30
commit 8542309fc9
3 changed files with 45 additions and 43 deletions

View File

@ -610,12 +610,12 @@ class RestAPI(BaseModel):
return self.deployments.pop(deployment_id)
class DomainName(BaseModel,dict):
class DomainName(BaseModel, dict):
def __init__(self, domain_name, **kwargs):
super(DomainName, self).__init__()
self["domainName"] = domain_name
self["regionalDomainName"] = domain_name,
self["distributionDomainName"] = domain_name,
self["regionalDomainName"] = domain_name
self["distributionDomainName"] = domain_name
self["domainNameStatus"] = "AVAILABLE"
self["domainNameStatusMessage"] = "Domain Name Available"
self["regionalHostedZoneId"] = "Z2FDTNDATAQYW2"
@ -628,31 +628,21 @@ class DomainName(BaseModel,dict):
if kwargs.get("certificate_body"):
self["certificateBody"] = kwargs.get("certificate_body")
if kwargs.get("tags"):
self["tags"] = kwargs.get("tags" )
self["tags"] = kwargs.get("tags")
if kwargs.get("security_policy"):
self["securityPolicy"] = kwargs.get("security_policy")
if kwargs.get("certificate_chain"):
self["certificateChain"] = kwargs.get("certificate_chain")
if kwargs.get("regional_certificate_name"):
self["regionalCertificateName"] = kwargs.get(
"regional_certificate_name"
)
self["regionalCertificateName"] = kwargs.get("regional_certificate_name")
if kwargs.get("certificate_private_key"):
self["certificatePrivateKey"] = kwargs.get(
"certificate_private_key"
)
self["certificatePrivateKey"] = kwargs.get("certificate_private_key")
if kwargs.get("regional_certificate_arn"):
self["regionalCertificateArn"] = kwargs.get(
"regional_certificate_arn"
)
self["regionalCertificateArn"] = kwargs.get("regional_certificate_arn")
if kwargs.get("endpoint_configuration"):
self["endpointConfiguration"] = kwargs.get(
"endpoint_configuration"
)
self["endpointConfiguration"] = kwargs.get("endpoint_configuration")
if kwargs.get("generate_cli_skeleton"):
self["generateCliSkeleton"] = kwargs.get(
"generate_cli_skeleton"
)
self["generateCliSkeleton"] = kwargs.get("generate_cli_skeleton")
class APIGatewayBackend(BaseBackend):
@ -1048,16 +1038,21 @@ class APIGatewayBackend(BaseBackend):
except Exception:
return False
def create_domain_name(self,domain_name,
certificate_name=None,certificate_private_key=None,
tags=None, certificate_arn=None,
certificate_body=None,
certificate_chain=None,
regional_certificate_name=None,
regional_certificate_arn=None,
endpoint_configuration=None,
security_policy=None,
generate_cli_skeleton=None):
def create_domain_name(
self,
domain_name,
certificate_name=None,
tags=None,
certificate_arn=None,
certificate_body=None,
certificate_private_key=None,
certificate_chain=None,
regional_certificate_name=None,
regional_certificate_arn=None,
endpoint_configuration=None,
security_policy=None,
generate_cli_skeleton=None,
):
if not domain_name:
raise InvalidDomainName()
@ -1072,7 +1067,8 @@ class APIGatewayBackend(BaseBackend):
regional_certificate_name=regional_certificate_name,
regional_certificate_arn=regional_certificate_arn,
endpoint_configuration=endpoint_configuration,
tags=tags, security_policy=security_policy,
tags=tags,
security_policy=security_policy,
generate_cli_skeleton=generate_cli_skeleton,
)

View File

@ -546,8 +546,7 @@ class APIGatewayResponse(BaseResponse):
certificate_body = self._get_param("certificateBody")
certificate_private_key = self._get_param(
"certificatePrivateKey"
)
)
certificate_chain = self._get_param("certificateChain")
regional_certificate_name = self._get_param(
"regionalCertificateName"
@ -563,12 +562,18 @@ class APIGatewayResponse(BaseResponse):
"generateCliSkeleton"
)
domain_name_resp = self.backend.create_domain_name(
domain_name, certificate_name,
certificate_private_key,tags, certificate_arn,
certificate_body, certificate_chain,
regional_certificate_name, regional_certificate_arn,
endpoint_configuration, security_policy,
generate_cli_skeleton
domain_name,
certificate_name,
tags,
certificate_arn,
certificate_body,
certificate_private_key,
certificate_chain,
regional_certificate_name,
regional_certificate_arn,
endpoint_configuration,
security_policy,
generate_cli_skeleton,
)
return 200, {}, json.dumps(domain_name_resp)
@ -592,7 +597,6 @@ class APIGatewayResponse(BaseResponse):
if domain_name is not None:
domain_names = self.backend.get_domain_name(domain_name)
return 200, {}, json.dumps(domain_names)
except DomainNameNotFound as error:
return (
error.code,
@ -603,3 +607,4 @@ class APIGatewayResponse(BaseResponse):
)

View File

@ -1490,10 +1490,11 @@ def test_create_domain_names():
test_certificate_name = "test.certificate"
test_certificate_private_key = "testPrivateKey"
# success case with valid params
response = client.create_domain_name(domainName=domain_name,
certificateName=test_certificate_name,
certificatePrivateKey=test_certificate_private_key)
response = client.create_domain_name(
domainName=domain_name,
certificateName=test_certificate_name,
certificatePrivateKey=test_certificate_private_key,
)
response["domainName"].should.equal(domain_name)
response["certificateName"].should.equal(test_certificate_name)
# without domain name it should throw BadRequestException