mirror of
https://github.com/certbot/certbot.git
synced 2026-06-07 15:52:08 -04:00
* Refactor tests out of module for certbot-dns-cloudflare * Refactor tests out of module for certbot-dns-cloudxns * Refactor tests out of module for certbot-dns-digitalocean * Refactor tests out of module for certbot-dns-dnsimple * Refactor tests out of module for certbot-dns-dnsmadeeasy * Refactor tests out of module for certbot-dns-gehirn * Refactor tests out of module for certbot-dns-google * Refactor tests out of module for certbot-dns-linode * Refactor tests out of module for certbot-dns-luadns * Refactor tests out of module for certbot-dns-nsone * Refactor tests out of module for certbot-dns-ovh * Refactor tests out of module for certbot-dns-rfc2136 * Refactor tests out of module for certbot-dns-sakuracloud * Refactor tests out of module for certbot-dns-route53 * Move certbot-dns-google testdata/ under tests/ * Use pytest for dns plugins * Exclude pycache and .py[cod]
52 lines
1.6 KiB
Python
52 lines
1.6 KiB
Python
"""Tests for certbot_dns_luadns._internal.dns_luadns."""
|
|
|
|
import unittest
|
|
|
|
import mock
|
|
from requests.exceptions import HTTPError
|
|
|
|
from certbot.compat import os
|
|
from certbot.plugins import dns_test_common
|
|
from certbot.plugins import dns_test_common_lexicon
|
|
from certbot.tests import util as test_util
|
|
|
|
EMAIL = 'fake@example.com'
|
|
TOKEN = 'foo'
|
|
|
|
|
|
class AuthenticatorTest(test_util.TempDirTestCase,
|
|
dns_test_common_lexicon.BaseLexiconAuthenticatorTest):
|
|
|
|
def setUp(self):
|
|
super(AuthenticatorTest, self).setUp()
|
|
|
|
from certbot_dns_luadns._internal.dns_luadns import Authenticator
|
|
|
|
path = os.path.join(self.tempdir, 'file.ini')
|
|
dns_test_common.write({"luadns_email": EMAIL, "luadns_token": TOKEN}, path)
|
|
|
|
self.config = mock.MagicMock(luadns_credentials=path,
|
|
luadns_propagation_seconds=0) # don't wait during tests
|
|
|
|
self.auth = Authenticator(self.config, "luadns")
|
|
|
|
self.mock_client = mock.MagicMock()
|
|
# _get_luadns_client | pylint: disable=protected-access
|
|
self.auth._get_luadns_client = mock.MagicMock(return_value=self.mock_client)
|
|
|
|
|
|
class LuaDNSLexiconClientTest(unittest.TestCase, dns_test_common_lexicon.BaseLexiconClientTest):
|
|
|
|
LOGIN_ERROR = HTTPError("401 Client Error: Unauthorized for url: ...")
|
|
|
|
def setUp(self):
|
|
from certbot_dns_luadns._internal.dns_luadns import _LuaDNSLexiconClient
|
|
|
|
self.client = _LuaDNSLexiconClient(EMAIL, TOKEN, 0)
|
|
|
|
self.provider_mock = mock.MagicMock()
|
|
self.client.provider = self.provider_mock
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main() # pragma: no cover
|