def setUp(self): from certbot_dns_cloudflare._internal.dns_cloudflare import Authenticator super(AuthenticatorTest, self).setUp() path = os.path.join(self.tempdir, 'file.ini') dns_test_common.write({"cloudflare_email": EMAIL, "cloudflare_api_key": API_KEY}, path) self.config = mock.MagicMock(cloudflare_credentials=path, cloudflare_propagation_seconds=0) # don't wait during tests self.auth = Authenticator(self.config, "cloudflare") self.mock_client = mock.MagicMock() # _get_cloudflare_client | pylint: disable=protected-access self.auth._get_cloudflare_client = mock.MagicMock(return_value=self.mock_client)
class AuthenticatorTest(test_util.TempDirTestCase, dns_test_common.BaseAuthenticatorTest): def setUp(self): from certbot_dns_cloudflare._internal.dns_cloudflare import Authenticator super(AuthenticatorTest, self).setUp() path = os.path.join(self.tempdir, 'file.ini') dns_test_common.write( { "cloudflare_email": EMAIL, "cloudflare_api_key": API_KEY }, path) self.config = mock.MagicMock( cloudflare_credentials=path, cloudflare_propagation_seconds=0) # don't wait during tests self.auth = Authenticator(self.config, "cloudflare") self.mock_client = mock.MagicMock() # _get_cloudflare_client | pylint: disable=protected-access self.auth._get_cloudflare_client = mock.MagicMock( return_value=self.mock_client) def test_perform(self): self.auth.perform([self.achall]) expected = [ mock.call.add_txt_record(DOMAIN, '_acme-challenge.' + DOMAIN, mock.ANY, mock.ANY) ] self.assertEqual(expected, self.mock_client.mock_calls) def test_cleanup(self): # _attempt_cleanup | pylint: disable=protected-access self.auth._attempt_cleanup = True self.auth.cleanup([self.achall]) expected = [ mock.call.del_txt_record(DOMAIN, '_acme-challenge.' + DOMAIN, mock.ANY) ] self.assertEqual(expected, self.mock_client.mock_calls)