Updated version 0.23.0 from 'upstream/0.23.0'
with Debian dir a7056f73f4167244db56eca0f8d148f06d198ba0
Andrew Starr-Bochicchio
5 years ago
0 | Metadata-Version: 1.2 | |
0 | Metadata-Version: 2.1 | |
1 | 1 | Name: certbot-dns-rfc2136 |
2 | Version: 0.22.0 | |
2 | Version: 0.23.0 | |
3 | 3 | Summary: RFC 2136 DNS Authenticator plugin for Certbot |
4 | 4 | Home-page: https://github.com/certbot/certbot |
5 | 5 | Author: Certbot Project |
6 | 6 | Author-email: client-dev@letsencrypt.org |
7 | 7 | License: Apache License 2.0 |
8 | Description-Content-Type: UNKNOWN | |
9 | 8 | Description: UNKNOWN |
10 | 9 | Platform: UNKNOWN |
11 | 10 | Classifier: Development Status :: 3 - Alpha |
27 | 26 | Classifier: Topic :: System :: Systems Administration |
28 | 27 | Classifier: Topic :: Utilities |
29 | 28 | Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.* |
29 | Provides-Extra: docs |
69 | 69 | self._validate_algorithm |
70 | 70 | ) |
71 | 71 | |
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) | |
77 | 77 | |
78 | 78 | def _get_rfc2136_client(self): |
79 | 79 | return _RFC2136Client(self.credentials.conf('server'), |
94 | 94 | }) |
95 | 95 | self.algorithm = key_algorithm |
96 | 96 | |
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): | |
98 | 98 | """ |
99 | 99 | Add a TXT record using the supplied information. |
100 | 100 | |
101 | :param str domain: The domain to use to find the closest SOA. | |
102 | 101 | :param str record_name: The record name (typically beginning with '_acme-challenge.'). |
103 | 102 | :param str record_content: The record content (typically the challenge validation). |
104 | 103 | :param int record_ttl: The record TTL (number of seconds that the record may be cached). |
105 | 104 | :raises certbot.errors.PluginError: if an error occurs communicating with the DNS server |
106 | 105 | """ |
107 | 106 | |
108 | domain = self._find_domain(domain_name) | |
107 | domain = self._find_domain(record_name) | |
109 | 108 | |
110 | 109 | n = dns.name.from_text(record_name) |
111 | 110 | o = dns.name.from_text(domain) |
130 | 129 | raise errors.PluginError('Received response from server: {0}' |
131 | 130 | .format(dns.rcode.to_text(rcode))) |
132 | 131 | |
133 | def del_txt_record(self, domain_name, record_name, record_content): | |
132 | def del_txt_record(self, record_name, record_content): | |
134 | 133 | """ |
135 | 134 | Delete a TXT record using the supplied information. |
136 | 135 | |
137 | :param str domain: The domain to use to find the closest SOA. | |
138 | 136 | :param str record_name: The record name (typically beginning with '_acme-challenge.'). |
139 | 137 | :param str record_content: The record content (typically the challenge validation). |
140 | 138 | :param int record_ttl: The record TTL (number of seconds that the record may be cached). |
141 | 139 | :raises certbot.errors.PluginError: if an error occurs communicating with the DNS server |
142 | 140 | """ |
143 | 141 | |
144 | domain = self._find_domain(domain_name) | |
142 | domain = self._find_domain(record_name) | |
145 | 143 | |
146 | 144 | n = dns.name.from_text(record_name) |
147 | 145 | o = dns.name.from_text(domain) |
166 | 164 | raise errors.PluginError('Received response from server: {0}' |
167 | 165 | .format(dns.rcode.to_text(rcode))) |
168 | 166 | |
169 | def _find_domain(self, domain_name): | |
167 | def _find_domain(self, record_name): | |
170 | 168 | """ |
171 | 169 | Find the closest domain with an SOA record for a given domain name. |
172 | 170 | |
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. | |
174 | 172 | :returns: The domain, if found. |
175 | 173 | :rtype: str |
176 | 174 | :raises certbot.errors.PluginError: if no SOA record can be found. |
177 | 175 | """ |
178 | 176 | |
179 | domain_name_guesses = dns_common.base_domain_name_guesses(domain_name) | |
177 | domain_name_guesses = dns_common.base_domain_name_guesses(record_name) | |
180 | 178 | |
181 | 179 | # Loop through until we find an authoritative SOA record |
182 | 180 | for guess in domain_name_guesses: |
184 | 182 | return guess |
185 | 183 | |
186 | 184 | 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)) | |
188 | 186 | |
189 | 187 | def _query_soa(self, domain_name): |
190 | 188 | """ |
40 | 40 | def test_perform(self): |
41 | 41 | self.auth.perform([self.achall]) |
42 | 42 | |
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)] | |
44 | 44 | self.assertEqual(expected, self.mock_client.mock_calls) |
45 | 45 | |
46 | 46 | def test_cleanup(self): |
48 | 48 | self.auth._attempt_cleanup = True |
49 | 49 | self.auth.cleanup([self.achall]) |
50 | 50 | |
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)] | |
52 | 52 | self.assertEqual(expected, self.mock_client.mock_calls) |
53 | 53 | |
54 | 54 | def test_invalid_algorithm_raises(self): |
81 | 81 | # _find_domain | pylint: disable=protected-access |
82 | 82 | self.rfc2136_client._find_domain = mock.MagicMock(return_value="example.com") |
83 | 83 | |
84 | self.rfc2136_client.add_txt_record(DOMAIN, "bar", "baz", 42) | |
84 | self.rfc2136_client.add_txt_record("bar", "baz", 42) | |
85 | 85 | |
86 | 86 | query_mock.assert_called_with(mock.ANY, SERVER) |
87 | 87 | self.assertTrue("bar. 42 IN TXT \"baz\"" in str(query_mock.call_args[0][0])) |
95 | 95 | self.assertRaises( |
96 | 96 | errors.PluginError, |
97 | 97 | self.rfc2136_client.add_txt_record, |
98 | DOMAIN, "bar", "baz", 42) | |
98 | "bar", "baz", 42) | |
99 | 99 | |
100 | 100 | @mock.patch("dns.query.tcp") |
101 | 101 | def test_add_txt_record_server_error(self, query_mock): |
106 | 106 | self.assertRaises( |
107 | 107 | errors.PluginError, |
108 | 108 | self.rfc2136_client.add_txt_record, |
109 | DOMAIN, "bar", "baz", 42) | |
109 | "bar", "baz", 42) | |
110 | 110 | |
111 | 111 | @mock.patch("dns.query.tcp") |
112 | 112 | def test_del_txt_record(self, query_mock): |
114 | 114 | # _find_domain | pylint: disable=protected-access |
115 | 115 | self.rfc2136_client._find_domain = mock.MagicMock(return_value="example.com") |
116 | 116 | |
117 | self.rfc2136_client.del_txt_record(DOMAIN, "bar", "baz") | |
117 | self.rfc2136_client.del_txt_record("bar", "baz") | |
118 | 118 | |
119 | 119 | query_mock.assert_called_with(mock.ANY, SERVER) |
120 | 120 | self.assertTrue("bar. 0 NONE TXT \"baz\"" in str(query_mock.call_args[0][0])) |
128 | 128 | self.assertRaises( |
129 | 129 | errors.PluginError, |
130 | 130 | self.rfc2136_client.del_txt_record, |
131 | DOMAIN, "bar", "baz") | |
131 | "bar", "baz") | |
132 | 132 | |
133 | 133 | @mock.patch("dns.query.tcp") |
134 | 134 | def test_del_txt_record_server_error(self, query_mock): |
139 | 139 | self.assertRaises( |
140 | 140 | errors.PluginError, |
141 | 141 | self.rfc2136_client.del_txt_record, |
142 | DOMAIN, "bar", "baz") | |
142 | "bar", "baz") | |
143 | 143 | |
144 | 144 | def test_find_domain(self): |
145 | 145 | # _query_soa | pylint: disable=protected-access |
0 | Metadata-Version: 1.2 | |
0 | Metadata-Version: 2.1 | |
1 | 1 | Name: certbot-dns-rfc2136 |
2 | Version: 0.22.0 | |
2 | Version: 0.23.0 | |
3 | 3 | Summary: RFC 2136 DNS Authenticator plugin for Certbot |
4 | 4 | Home-page: https://github.com/certbot/certbot |
5 | 5 | Author: Certbot Project |
6 | 6 | Author-email: client-dev@letsencrypt.org |
7 | 7 | License: Apache License 2.0 |
8 | Description-Content-Type: UNKNOWN | |
9 | 8 | Description: UNKNOWN |
10 | 9 | Platform: UNKNOWN |
11 | 10 | Classifier: Development Status :: 3 - Alpha |
27 | 26 | Classifier: Topic :: System :: Systems Administration |
28 | 27 | Classifier: Topic :: Utilities |
29 | 28 | Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.* |
29 | Provides-Extra: docs |