Skip to content

Commit

Permalink
FIX #162 - removed "*." added by client.py, removed often incomplete … (
Browse files Browse the repository at this point in the history
#163)

* FIX #162 - removed "*." added by client.py, removed often incomplete fixes from most providers.

* Removed broken tests - drivers are no longer passed *.domain.tld for wildcards

Co-authored-by: Martin Maney <maney@two14.net>
  • Loading branch information
mmaney and Martin Maney committed Apr 10, 2020
1 parent adece3a commit f3eee58
Show file tree
Hide file tree
Showing 12 changed files with 9 additions and 50 deletions.
2 changes: 0 additions & 2 deletions sewer/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,8 +457,6 @@ def get_identifier_authorization(self, url):
response_json = response.json()
domain = response_json["identifier"]["value"]
wildcard = response_json.get("wildcard")
if wildcard:
domain = "*." + domain

for i in response_json["challenges"]:
if i["type"] == self.auth_provider.auth_type:
Expand Down
2 changes: 0 additions & 2 deletions sewer/dns_providers/acmedns.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ def __init__(self, ACME_DNS_API_USER, ACME_DNS_API_KEY, ACME_DNS_API_BASE_URL):

def create_dns_record(self, domain_name, domain_dns_value):
self.logger.info("create_dns_record")
# if we have been given a wildcard name, strip wildcard
domain_name = domain_name.lstrip("*.")

resolver = Resolver(configure=False)
resolver.nameservers = ["8.8.8.8"]
Expand Down
2 changes: 0 additions & 2 deletions sewer/dns_providers/aliyundns.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,6 @@ def extract_zone(domain_name):
:param str domain_name: the value sewer client passed in, like *.menduo.example.com
:return tuple: root, zone, acme_txt
"""
# if we have been given a wildcard name, strip wildcard
domain_name = domain_name.lstrip("*.")
if domain_name.count(".") > 1:
zone, middle, last = str(domain_name).rsplit(".", 2)
root = ".".join([middle, last])
Expand Down
2 changes: 0 additions & 2 deletions sewer/dns_providers/auroradns.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ def __init__(self, AURORA_API_KEY, AURORA_SECRET_KEY):

def create_dns_record(self, domain_name, domain_dns_value):
self.logger.info("create_dns_record")
# if we have been given a wildcard name, strip wildcard
domain_name = domain_name.lstrip("*.")

extractedDomain = tldextract.extract(domain_name)
domainSuffix = extractedDomain.domain + "." + extractedDomain.suffix
Expand Down
4 changes: 0 additions & 4 deletions sewer/dns_providers/cloudflare.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ def find_dns_zone(self, domain_name):

def create_dns_record(self, domain_name, domain_dns_value):
self.logger.info("create_dns_record")
# if we have been given a wildcard name, strip wildcard
domain_name = domain_name.lstrip("*.")
self.find_dns_zone(domain_name)

url = urllib.parse.urljoin(
Expand Down Expand Up @@ -110,8 +108,6 @@ def create_dns_record(self, domain_name, domain_dns_value):

def delete_dns_record(self, domain_name, domain_dns_value):
self.logger.info("delete_dns_record")
# if we have been given a wildcard name, strip wildcard
domain_name = domain_name.lstrip("*.")

class MockResponse(object):
def __init__(self, status_code=200, content="mock-response"):
Expand Down
6 changes: 3 additions & 3 deletions sewer/dns_providers/cloudns.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
from . import common


### FIX ME ### this assumes there are only two levels above the host (no bbc.co.uk eg.)


def _split_domain_name(domain_name):
"""ClouDNS requires the domain name and host to be split."""
full_domain_name = "_acme-challenge.{}".format(domain_name)
Expand All @@ -15,9 +18,6 @@ def _split_domain_name(domain_name):
domain_name = ".".join(domain_parts[-2:])
host = ".".join(domain_parts[:-2])

if host == "_acme-challenge.*":
host = "_acme-challenge"

return domain_name, host


Expand Down
9 changes: 6 additions & 3 deletions sewer/dns_providers/dnspod.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ def __init__(self, DNSPOD_ID, DNSPOD_API_KEY, DNSPOD_API_BASE_URL="https://dnsap

def create_dns_record(self, domain_name, domain_dns_value):
self.logger.info("create_dns_record")
# if we have been given a wildcard name, strip wildcard
domain_name = domain_name.lstrip("*.")
subd = ""

### FIX ME ### domain is exactly last two parts (no bbc.co.uk eg.)

if domain_name.count(".") != 1: # not top level domain
pos = domain_name.rfind(".", 0, domain_name.rfind("."))
subd = domain_name[:pos]
Expand Down Expand Up @@ -68,8 +69,10 @@ def create_dns_record(self, domain_name, domain_dns_value):

def delete_dns_record(self, domain_name, domain_dns_value):
self.logger.info("delete_dns_record")
domain_name = domain_name.lstrip("*.")
subd = ""

### FIX ME ### domain is exactly last two parts (no bbc.co.uk eg.)

if domain_name.count(".") != 1: # not top level domain
pos = domain_name.rfind(".", 0, domain_name.rfind("."))
subd = domain_name[:pos]
Expand Down
2 changes: 0 additions & 2 deletions sewer/dns_providers/duckdns.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ def __init__(self, duckdns_token, DUCKDNS_API_BASE_URL="https://www.duckdns.org"

def _common_dns_record(self, logger_info, domain_name, payload_end_arg):
self.logger.info("{0}".format(logger_info))
# if we have been given a wildcard name, strip wildcard
domain_name = domain_name.lstrip("*.")
# add provider domain to the domain name if not present
provider_domain = ".duckdns.org"
if domain_name.rfind(provider_domain) == -1:
Expand Down
2 changes: 0 additions & 2 deletions sewer/dns_providers/hurricane.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ def extract_zone(domain_name):
:param str domain_name: the value sewer client passed in, like *.menduo.example.com
:return tuple: root, zone, acme_txt
"""
# if we have been given a wildcard name, strip wildcard
domain_name = domain_name.lstrip("*.")
if domain_name.count(".") > 1:
zone, middle, last = str(domain_name).rsplit(".", 2)
root = ".".join([middle, last])
Expand Down
2 changes: 0 additions & 2 deletions sewer/dns_providers/rackspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,6 @@ def poll_callback_url(self, callback_url):

def create_dns_record(self, domain_name, domain_dns_value):
self.logger.info("create_dns_record")
# strip wildcard if present
domain_name = domain_name.lstrip("*.")
self.RACKSPACE_DNS_ZONE_ID = self.find_dns_zone_id(domain_name)
record_name = "_acme-challenge." + domain_name
url = urllib.parse.urljoin(
Expand Down
13 changes: 0 additions & 13 deletions sewer/dns_providers/tests/test_aliyundns.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,13 @@ def test_extract_zone_sub_domain(self):
self.assertEqual(zone, _zone)
self.assertEqual(acme_txt, "_acme-challenge.%s" % zone)

domain = "*.%s.%s" % (_zone, self.domain_name)
root, zone, acme_txt = self.dns_class.extract_zone(domain)

self.assertEqual(root, self.domain_name)
self.assertEqual(zone, _zone)
self.assertEqual(acme_txt, "_acme-challenge.%s" % zone)

def test_extract_zone_root(self):
domain = self.domain_name
root, zone, acme_txt = self.dns_class.extract_zone(domain)
self.assertEqual(root, self.domain_name)
self.assertEqual(zone, "")
self.assertEqual(acme_txt, "_acme-challenge")

domain = "*." + self.domain_name
root, zone, acme_txt = self.dns_class.extract_zone(domain)
self.assertEqual(root, self.domain_name)
self.assertEqual(zone, "")
self.assertEqual(acme_txt, "_acme-challenge")

def test_aliyun_is_called_by_create_dns_record(self):
with mock.patch("requests.post") as mock_requests_post, mock.patch(
"sewer.AliyunDns.delete_dns_record"
Expand Down
13 changes: 0 additions & 13 deletions sewer/dns_providers/tests/test_hedns.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,13 @@ def test_extract_zone_sub_domain(self):
self.assertEqual(zone, _zone)
self.assertEqual(acme_txt, "_acme-challenge.%s" % zone)

domain = "*.%s.%s" % (_zone, self.domain_name)
root, zone, acme_txt = self.dns_class.extract_zone(domain)

self.assertEqual(root, self.domain_name)
self.assertEqual(zone, _zone)
self.assertEqual(acme_txt, "_acme-challenge.%s" % zone)

def test_extract_zone_root(self):
domain = self.domain_name
root, zone, acme_txt = self.dns_class.extract_zone(domain)
self.assertEqual(root, self.domain_name)
self.assertEqual(zone, "")
self.assertEqual(acme_txt, "_acme-challenge")

domain = "*." + self.domain_name
root, zone, acme_txt = self.dns_class.extract_zone(domain)
self.assertEqual(root, self.domain_name)
self.assertEqual(zone, "")
self.assertEqual(acme_txt, "_acme-challenge")

def test_hedns_is_called_by_create_dns_record(self):
with mock.patch("requests.post") as mock_requests_post, mock.patch(
"sewer.HurricaneDns.delete_dns_record"
Expand Down

0 comments on commit f3eee58

Please sign in to comment.