mirror of
https://github.com/certbot/certbot.git
synced 2026-07-28 08:45:19 +02:00
Be consistent with checking capitalization in rfc2136 plugin (#10188)
Fixes https://github.com/certbot/certbot/issues/10177. We were using `.upper()` when validating the config but not when actually creating the object. Now we call it in both places. I updated a test to work as a regression test here.
This commit is contained in:
@@ -91,12 +91,13 @@ class Authenticator(dns_common.DNSAuthenticator):
|
||||
if not self.credentials: # pragma: no cover
|
||||
raise errors.Error("Plugin has not been prepared.")
|
||||
|
||||
algorithm: str = (self.credentials.conf('algorithm') or '').upper()
|
||||
|
||||
return _RFC2136Client(cast(str, self.credentials.conf('server')),
|
||||
int(cast(str, self.credentials.conf('port')) or self.PORT),
|
||||
cast(str, self.credentials.conf('name')),
|
||||
cast(str, self.credentials.conf('secret')),
|
||||
self.ALGORITHMS.get(self.credentials.conf('algorithm') or '',
|
||||
dns.tsig.HMAC_MD5),
|
||||
self.ALGORITHMS.get(algorithm, dns.tsig.HMAC_MD5),
|
||||
(self.credentials.conf('sign_query') or '').upper() == "TRUE")
|
||||
|
||||
|
||||
|
||||
@@ -79,12 +79,17 @@ class AuthenticatorTest(test_util.TempDirTestCase, dns_test_common.BaseAuthentic
|
||||
self.auth.perform([self.achall])
|
||||
|
||||
@test_util.patch_display_util()
|
||||
def test_valid_algorithm_passes(self, unused_mock_get_utility):
|
||||
@mock.patch('certbot_dns_rfc2136._internal.dns_rfc2136._RFC2136Client')
|
||||
def test_valid_algorithm_passes(self, client, unused_mock_get_utility):
|
||||
from certbot_dns_rfc2136._internal.dns_rfc2136 import Authenticator
|
||||
|
||||
config = VALID_CONFIG.copy()
|
||||
config["rfc2136_algorithm"] = "HMAC-sha512"
|
||||
dns_test_common.write(config, self.config.rfc2136_credentials)
|
||||
self.auth = Authenticator(self.config, "rfc2136")
|
||||
|
||||
self.auth.perform([self.achall])
|
||||
assert dns.tsig.HMAC_SHA512 in client.call_args.args
|
||||
|
||||
def test_invalid_server_raises(self):
|
||||
config = VALID_CONFIG.copy()
|
||||
|
||||
Reference in New Issue
Block a user