Codebase list python-certbot-dns-rfc2136 / d2761d7
Updated version 0.23.0 from 'upstream/0.23.0' with Debian dir a7056f73f4167244db56eca0f8d148f06d198ba0 Andrew Starr-Bochicchio 6 years ago
6 changed file(s) with 31 addition(s) and 33 deletion(s). Raw diff Collapse all Expand all
0 Metadata-Version: 1.2
0 Metadata-Version: 2.1
11 Name: certbot-dns-rfc2136
2 Version: 0.22.0
2 Version: 0.23.0
33 Summary: RFC 2136 DNS Authenticator plugin for Certbot
44 Home-page: https://github.com/certbot/certbot
55 Author: Certbot Project
66 Author-email: client-dev@letsencrypt.org
77 License: Apache License 2.0
8 Description-Content-Type: UNKNOWN
98 Description: UNKNOWN
109 Platform: UNKNOWN
1110 Classifier: Development Status :: 3 - Alpha
2726 Classifier: Topic :: System :: Systems Administration
2827 Classifier: Topic :: Utilities
2928 Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*
29 Provides-Extra: docs
6969 self._validate_algorithm
7070 )
7171
72 def _perform(self, domain, validation_name, validation):
73 self._get_rfc2136_client().add_txt_record(domain, validation_name, validation, self.ttl)
74
75 def _cleanup(self, domain, validation_name, validation):
76 self._get_rfc2136_client().del_txt_record(domain, validation_name, validation)
72 def _perform(self, _domain, validation_name, validation):
73 self._get_rfc2136_client().add_txt_record(validation_name, validation, self.ttl)
74
75 def _cleanup(self, _domain, validation_name, validation):
76 self._get_rfc2136_client().del_txt_record(validation_name, validation)
7777
7878 def _get_rfc2136_client(self):
7979 return _RFC2136Client(self.credentials.conf('server'),
9494 })
9595 self.algorithm = key_algorithm
9696
97 def add_txt_record(self, domain_name, record_name, record_content, record_ttl):
97 def add_txt_record(self, record_name, record_content, record_ttl):
9898 """
9999 Add a TXT record using the supplied information.
100100
101 :param str domain: The domain to use to find the closest SOA.
102101 :param str record_name: The record name (typically beginning with '_acme-challenge.').
103102 :param str record_content: The record content (typically the challenge validation).
104103 :param int record_ttl: The record TTL (number of seconds that the record may be cached).
105104 :raises certbot.errors.PluginError: if an error occurs communicating with the DNS server
106105 """
107106
108 domain = self._find_domain(domain_name)
107 domain = self._find_domain(record_name)
109108
110109 n = dns.name.from_text(record_name)
111110 o = dns.name.from_text(domain)
130129 raise errors.PluginError('Received response from server: {0}'
131130 .format(dns.rcode.to_text(rcode)))
132131
133 def del_txt_record(self, domain_name, record_name, record_content):
132 def del_txt_record(self, record_name, record_content):
134133 """
135134 Delete a TXT record using the supplied information.
136135
137 :param str domain: The domain to use to find the closest SOA.
138136 :param str record_name: The record name (typically beginning with '_acme-challenge.').
139137 :param str record_content: The record content (typically the challenge validation).
140138 :param int record_ttl: The record TTL (number of seconds that the record may be cached).
141139 :raises certbot.errors.PluginError: if an error occurs communicating with the DNS server
142140 """
143141
144 domain = self._find_domain(domain_name)
142 domain = self._find_domain(record_name)
145143
146144 n = dns.name.from_text(record_name)
147145 o = dns.name.from_text(domain)
166164 raise errors.PluginError('Received response from server: {0}'
167165 .format(dns.rcode.to_text(rcode)))
168166
169 def _find_domain(self, domain_name):
167 def _find_domain(self, record_name):
170168 """
171169 Find the closest domain with an SOA record for a given domain name.
172170
173 :param str domain_name: The domain name for which to find the closest SOA record.
171 :param str record_name: The record name for which to find the closest SOA record.
174172 :returns: The domain, if found.
175173 :rtype: str
176174 :raises certbot.errors.PluginError: if no SOA record can be found.
177175 """
178176
179 domain_name_guesses = dns_common.base_domain_name_guesses(domain_name)
177 domain_name_guesses = dns_common.base_domain_name_guesses(record_name)
180178
181179 # Loop through until we find an authoritative SOA record
182180 for guess in domain_name_guesses:
184182 return guess
185183
186184 raise errors.PluginError('Unable to determine base domain for {0} using names: {1}.'
187 .format(domain_name, domain_name_guesses))
185 .format(record_name, domain_name_guesses))
188186
189187 def _query_soa(self, domain_name):
190188 """
4040 def test_perform(self):
4141 self.auth.perform([self.achall])
4242
43 expected = [mock.call.add_txt_record(DOMAIN, '_acme-challenge.'+DOMAIN, mock.ANY, mock.ANY)]
43 expected = [mock.call.add_txt_record('_acme-challenge.'+DOMAIN, mock.ANY, mock.ANY)]
4444 self.assertEqual(expected, self.mock_client.mock_calls)
4545
4646 def test_cleanup(self):
4848 self.auth._attempt_cleanup = True
4949 self.auth.cleanup([self.achall])
5050
51 expected = [mock.call.del_txt_record(DOMAIN, '_acme-challenge.'+DOMAIN, mock.ANY)]
51 expected = [mock.call.del_txt_record('_acme-challenge.'+DOMAIN, mock.ANY)]
5252 self.assertEqual(expected, self.mock_client.mock_calls)
5353
5454 def test_invalid_algorithm_raises(self):
8181 # _find_domain | pylint: disable=protected-access
8282 self.rfc2136_client._find_domain = mock.MagicMock(return_value="example.com")
8383
84 self.rfc2136_client.add_txt_record(DOMAIN, "bar", "baz", 42)
84 self.rfc2136_client.add_txt_record("bar", "baz", 42)
8585
8686 query_mock.assert_called_with(mock.ANY, SERVER)
8787 self.assertTrue("bar. 42 IN TXT \"baz\"" in str(query_mock.call_args[0][0]))
9595 self.assertRaises(
9696 errors.PluginError,
9797 self.rfc2136_client.add_txt_record,
98 DOMAIN, "bar", "baz", 42)
98 "bar", "baz", 42)
9999
100100 @mock.patch("dns.query.tcp")
101101 def test_add_txt_record_server_error(self, query_mock):
106106 self.assertRaises(
107107 errors.PluginError,
108108 self.rfc2136_client.add_txt_record,
109 DOMAIN, "bar", "baz", 42)
109 "bar", "baz", 42)
110110
111111 @mock.patch("dns.query.tcp")
112112 def test_del_txt_record(self, query_mock):
114114 # _find_domain | pylint: disable=protected-access
115115 self.rfc2136_client._find_domain = mock.MagicMock(return_value="example.com")
116116
117 self.rfc2136_client.del_txt_record(DOMAIN, "bar", "baz")
117 self.rfc2136_client.del_txt_record("bar", "baz")
118118
119119 query_mock.assert_called_with(mock.ANY, SERVER)
120120 self.assertTrue("bar. 0 NONE TXT \"baz\"" in str(query_mock.call_args[0][0]))
128128 self.assertRaises(
129129 errors.PluginError,
130130 self.rfc2136_client.del_txt_record,
131 DOMAIN, "bar", "baz")
131 "bar", "baz")
132132
133133 @mock.patch("dns.query.tcp")
134134 def test_del_txt_record_server_error(self, query_mock):
139139 self.assertRaises(
140140 errors.PluginError,
141141 self.rfc2136_client.del_txt_record,
142 DOMAIN, "bar", "baz")
142 "bar", "baz")
143143
144144 def test_find_domain(self):
145145 # _query_soa | pylint: disable=protected-access
0 Metadata-Version: 1.2
0 Metadata-Version: 2.1
11 Name: certbot-dns-rfc2136
2 Version: 0.22.0
2 Version: 0.23.0
33 Summary: RFC 2136 DNS Authenticator plugin for Certbot
44 Home-page: https://github.com/certbot/certbot
55 Author: Certbot Project
66 Author-email: client-dev@letsencrypt.org
77 License: Apache License 2.0
8 Description-Content-Type: UNKNOWN
98 Description: UNKNOWN
109 Platform: UNKNOWN
1110 Classifier: Development Status :: 3 - Alpha
2726 Classifier: Topic :: System :: Systems Administration
2827 Classifier: Topic :: Utilities
2928 Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*
29 Provides-Extra: docs
99 :maxdepth: 2
1010 :caption: Contents:
1111
12 .. automodule:: certbot_dns_rfc2136
13 :members:
14
1215 .. toctree::
1316 :maxdepth: 1
1417
1518 api
16
17 .. automodule:: certbot_dns_rfc2136
18 :members:
1919
2020
2121
33 from setuptools import find_packages
44
55
6 version = '0.22.0'
6 version = '0.23.0'
77
88 # Remember to update local-oldest-requirements.txt when changing the minimum
99 # acme/certbot version.