Skip to content

Commit

Permalink
Route53: create_hosted_zone() now returns the Location (#6492)
Browse files Browse the repository at this point in the history
  • Loading branch information
bblommers authored Jul 7, 2023
1 parent 5f1ccb2 commit 47bca5b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions moto/route53/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ def list_or_create_hostzone_response(self, request: Any, full_url: str, headers:
delegation_set_id=delegation_set_id,
)
template = Template(CREATE_HOSTED_ZONE_RESPONSE)
headers = {
"Location": f"https://route53.amazonaws.com/2013-04-01/hostedzone/{new_zone.id}"
}
return 201, headers, template.render(zone=new_zone)

elif request.method == "GET":
Expand Down
8 changes: 6 additions & 2 deletions tests/test_route53/test_route53.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@

import botocore
import pytest
import requests

from moto import mock_ec2, mock_route53
from moto import mock_ec2, mock_route53, settings


@mock_route53
Expand All @@ -28,6 +29,10 @@ def test_create_hosted_zone():
delegation["NameServers"].should.contain("ns-2050.awsdns-66.org")
delegation["NameServers"].should.contain("ns-2051.awsdns-67.co.uk")

location = response["Location"]
if not settings.TEST_SERVER_MODE:
assert "<Name>testdns.aws.com.</Name>" in requests.get(location).text


@mock_route53
def test_list_hosted_zones():
Expand Down Expand Up @@ -481,7 +486,6 @@ def test_list_or_change_tags_for_resource_request():
@mock_ec2
@mock_route53
def test_list_hosted_zones_by_name():

# Create mock VPC so we can get a VPC ID
ec2c = boto3.client("ec2", region_name="us-east-1")
vpc_id = ec2c.create_vpc(CidrBlock="10.1.0.0/16").get("Vpc").get("VpcId")
Expand Down

0 comments on commit 47bca5b

Please sign in to comment.