def setUp(self): self.domain_name = "example.com" self.domain_dns_value = "mock-domain_dns_value" self.CLOUDFLARE_EMAIL = "*****@*****.**" self.CLOUDFLARE_API_KEY = "mock-api-key" self.CLOUDFLARE_API_BASE_URL = "https://some-mock-url.com" self.CLOUDFLARE_TOKEN = "mock-token" with mock.patch("requests.post") as mock_requests_post, mock.patch( "requests.get") as mock_requests_get: mock_requests_post.return_value = test_utils.MockResponse() mock_requests_get.return_value = test_utils.MockResponse() self.dns_class_api_key = sewer.CloudFlareDns( CLOUDFLARE_EMAIL=self.CLOUDFLARE_EMAIL, CLOUDFLARE_API_KEY=self.CLOUDFLARE_API_KEY, CLOUDFLARE_API_BASE_URL=self.CLOUDFLARE_API_BASE_URL, ) with mock.patch("requests.post") as mock_requests_post, mock.patch( "requests.get") as mock_requests_get: mock_requests_post.return_value = test_utils.MockResponse() mock_requests_get.return_value = test_utils.MockResponse() self.dns_class_token = sewer.CloudFlareDns( CLOUDFLARE_TOKEN=self.CLOUDFLARE_TOKEN, CLOUDFLARE_API_BASE_URL=self.CLOUDFLARE_API_BASE_URL, )
def setUp(self): self.domain_name = 'example.com' self.domain_dns_value = 'mock-domain_dns_value' self.CLOUDFLARE_EMAIL = '*****@*****.**' self.CLOUDFLARE_API_KEY = 'mock-api-key' self.CLOUDFLARE_API_BASE_URL = 'https://some-mock-url.com' with mock.patch('requests.post') as mock_requests_post, mock.patch( 'requests.get') as mock_requests_get: mock_requests_post.return_value = test_utils.MockResponse() mock_requests_get.return_value = test_utils.MockResponse() self.dns_class = sewer.CloudFlareDns( CLOUDFLARE_EMAIL=self.CLOUDFLARE_EMAIL, CLOUDFLARE_API_KEY=self.CLOUDFLARE_API_KEY, CLOUDFLARE_API_BASE_URL=self.CLOUDFLARE_API_BASE_URL)
def setUp(self): self.domain_name = 'example.com' self.base64_of_acme_keyauthorization = 'mock-base64_of_acme_keyauthorization' self.CLOUDFLARE_DNS_ZONE_ID = 'mock-zone-id' self.CLOUDFLARE_EMAIL = '*****@*****.**' self.CLOUDFLARE_API_KEY = 'mock-api-key' self.CLOUDFLARE_API_BASE_URL = 'https://some-mock-url.com' with mock.patch('requests.post') as mock_requests_post, mock.patch( 'requests.get') as mock_requests_get: mock_requests_post.return_value = test_utils.MockResponse() mock_requests_get.return_value = test_utils.MockResponse() self.dns_class = sewer.CloudFlareDns( CLOUDFLARE_DNS_ZONE_ID=self.CLOUDFLARE_DNS_ZONE_ID, CLOUDFLARE_EMAIL=self.CLOUDFLARE_EMAIL, CLOUDFLARE_API_KEY=self.CLOUDFLARE_API_KEY, CLOUDFLARE_API_BASE_URL=self.CLOUDFLARE_API_BASE_URL)
def test_init_auth_validation(self): # Invalid inputs with self.assertRaises(ValueError): sewer.CloudFlareDns( CLOUDFLARE_TOKEN=self.CLOUDFLARE_TOKEN, CLOUDFLARE_EMAIL=self.CLOUDFLARE_EMAIL, CLOUDFLARE_API_KEY=self.CLOUDFLARE_API_KEY, ) with self.assertRaises(ValueError): sewer.CloudFlareDns(CLOUDFLARE_TOKEN=self.CLOUDFLARE_TOKEN, CLOUDFLARE_API_KEY=self.CLOUDFLARE_API_KEY) with self.assertRaises(ValueError): sewer.CloudFlareDns() with self.assertRaises(ValueError): sewer.CloudFlareDns(CLOUDFLARE_TOKEN=self.CLOUDFLARE_TOKEN, CLOUDFLARE_EMAIL=self.CLOUDFLARE_EMAIL) # Valid inputs sewer.CloudFlareDns(CLOUDFLARE_EMAIL=self.CLOUDFLARE_EMAIL, CLOUDFLARE_API_KEY=self.CLOUDFLARE_API_KEY) sewer.CloudFlareDns(CLOUDFLARE_TOKEN=self.CLOUDFLARE_TOKEN)