# -*- coding: utf-8 -*-
"""Define the cert_manager.domain.Domain unit tests."""
# Don't warn about things that happen as that is part of unit testing
# pylint: disable=protected-access
# pylint: disable=no-member

import json

from requests.exceptions import HTTPError
from testtools import TestCase

import responses

from cert_manager.domain import Domain, DomainCreationResponseError

from .lib.testbase import ClientFixture


class TestDomain(TestCase):  # pylint: disable=too-few-public-methods
    """Serve as a Base class for all tests of the Domain class."""

    def setUp(self):  # pylint: disable=invalid-name
        """Initialize the class."""
        # Call the inherited setUp method
        super().setUp()

        # Make sure the Client fixture is created and setup
        self.cfixt = self.useFixture(ClientFixture())
        self.client = self.cfixt.client

        self.api_url = f"{self.cfixt.base_url}/domain/v1"

        # Setup a test response one would expect normally
        self.valid_response = [
            {"id": 1234, "name": "example.com"},
            {"id": 4321, "name": "*.example.com"},
            {"id": 4322, "name": "subdomain.example.com"},
        ]

        # Setup a test response for getting a specific Domain
        self.valid_individual_response = self.valid_response[0]
        self.valid_individual_response["status"] = "Active"

        # Setup JSON to return in an error
        self.error_response = {"description": "domain error"}


class TestInit(TestDomain):
    """Test the class initializer."""

    @responses.activate
    def test_param(self):
        """The URL should change if api_version is passed as a parameter."""
        # Set a new version
        version = "v3"
        api_url = f"{self.cfixt.base_url}/domain/{version}"

        # Setup the mocked response
        responses.add(responses.GET, api_url, json=self.valid_response, status=200)

        domain = Domain(client=self.client, api_version=version)
        data = domain.all()

        # Verify all the query information
        self.assertEqual(len(responses.calls), 1)
        self.assertEqual(responses.calls[0].request.url, api_url)

        self.assertEqual(data, self.valid_response)

    def test_need_client(self):
        """The class should raise an exception without a client parameter."""
        self.assertRaises(TypeError, Domain)


class TestAll(TestDomain):
    """Test the .all method."""

    @responses.activate
    def test_cached(self):
        """The function should return all the data, but should not query the API twice."""
        # Setup the mocked response
        responses.add(responses.GET, self.api_url, json=self.valid_response, status=200)

        domain = Domain(client=self.client)
        data = domain.all()
        data = domain.all()

        # Verify all the query information
        # There should only be one call the first time "all" is called.
        # Due to pagination, this is only guaranteed as long as the number of
        # entries returned is less than the page size
        self.assertEqual(len(responses.calls), 1)
        self.assertEqual(responses.calls[0].request.url, self.api_url)
        self.assertEqual(data, self.valid_response)

    @responses.activate
    def test_forced(self):
        """The function should return all the data, but should query the API twice."""
        # Setup the mocked response
        responses.add(responses.GET, self.api_url, json=self.valid_response, status=200)

        domain = Domain(client=self.client)
        data = domain.all()
        data = domain.all(force=True)

        # Verify all the query information
        # There should only be one call the first time "all" is called.
        # Due to pagination, this is only guaranteed as long as the number of
        # entries returned is less than the page size
        self.assertEqual(len(responses.calls), 2)
        self.assertEqual(responses.calls[0].request.url, self.api_url)
        self.assertEqual(responses.calls[1].request.url, self.api_url)
        self.assertEqual(data, self.valid_response)

    @responses.activate
    def test_bad_http(self):
        """The function should raise an HTTPError exception if domains cannot be retrieved from the API."""
        # Setup the mocked response
        responses.add(responses.GET, self.api_url, json=self.error_response, status=400)

        domain = Domain(client=self.client)
        self.assertRaises(HTTPError, domain.all)

        # Verify all the query information
        self.assertEqual(len(responses.calls), 1)
        self.assertEqual(responses.calls[0].request.url, self.api_url)


class TestFind(TestDomain):
    """Test the .find method."""

    @responses.activate
    def test_no_params(self):
        """Without parameters, the method will return all domains"""
        # Setup the mocked response
        responses.add(responses.GET, self.api_url, json=self.valid_response, status=200)

        domain = Domain(client=self.client)
        data = domain.find()

        self.assertEqual(data, self.valid_response)

    @responses.activate
    def test_params(self):
        """Parameters will be passed to API"""
        # Setup the mocked response
        responses.add(responses.GET, self.api_url, json=self.valid_response[0], status=200)

        api_url = f"{self.api_url}?name=example.com"
        domain = Domain(client=self.client)
        data = domain.find(name="example.com")

        # Verify all the query information

        self.assertEqual(responses.calls[0].request.url, api_url)
        self.assertEqual(data, self.valid_response[0])

    @responses.activate
    def test_bad_http(self):
        """The function should raise an HTTPError exception if domains cannot be retrieved from the API."""
        # Setup the mocked response
        responses.add(responses.GET, self.api_url, json=self.error_response, status=400)

        domain = Domain(client=self.client)
        self.assertRaises(HTTPError, domain.find)

        # Verify all the query information
        self.assertEqual(len(responses.calls), 1)
        self.assertEqual(responses.calls[0].request.url, self.api_url)


class TestCount(TestDomain):
    """Test the .count method."""

    @responses.activate
    def test_no_params(self):
        """Without parameters, the method will count all domains"""
        # Setup the mocked response
        count = {"count": len(self.valid_response)}
        api_url = f"{self.api_url}/count"
        responses.add(responses.GET, api_url, json=count, status=200)

        domain = Domain(client=self.client)
        data = domain.count()

        self.assertEqual(data, count)
        self.assertEqual(responses.calls[0].request.url, api_url)

    @responses.activate
    def test_params(self):
        """Parameters will be passed to API"""
        # Setup the mocked response
        count = {"count": len(self.valid_response[0])}
        api_url = f"{self.api_url}/count"
        responses.add(responses.GET, api_url, json=count, status=200)

        domain = Domain(client=self.client)
        data = domain.count(name="example.com")

        # Verify all the query information
        self.assertEqual(responses.calls[0].request.url, f"{api_url}?name=example.com")
        self.assertEqual(data, count)

    @responses.activate
    def test_bad_http(self):
        """The function should raise an HTTPError exception if counts cannot be retrieved from the API."""
        # Setup the mocked response
        api_url = f"{self.api_url}/count"
        responses.add(responses.GET, api_url, json=self.error_response, status=400)

        domain = Domain(client=self.client)
        self.assertRaises(HTTPError, domain.count)

        # Verify all the query information
        self.assertEqual(len(responses.calls), 1)
        self.assertEqual(responses.calls[0].request.url, api_url)


class TestGet(TestDomain):
    """Test the .get method."""

    @responses.activate
    def test_need_domain_id(self):
        """The function should raise an exception without an domain_id parameter."""

        domain = Domain(client=self.client)
        self.assertRaises(TypeError, domain.get)

    @responses.activate
    def test_domain_id(self):
        """The function should return data about the specified Domain ID."""

        domain_id = 1234
        api_url = f"{self.api_url}/{str(domain_id)}"

        # Setup the mocked response
        responses.add(responses.GET, api_url, json=self.valid_individual_response, status=200)

        domain = Domain(client=self.client)
        data = domain.get(domain_id)

        self.assertEqual(len(responses.calls), 1)
        self.assertEqual(responses.calls[0].request.url, api_url)
        self.assertEqual(data, self.valid_individual_response)

    @responses.activate
    def test_ne_domain_id(self):
        """The function should raise an HTTPError exception if the specified Domain ID does not exist."""

        domain_id = 2345
        api_url = f"{self.api_url}/{str(domain_id)}"

        # Setup the mocked response
        responses.add(responses.GET, api_url, status=404)

        domain = Domain(client=self.client)
        self.assertRaises(HTTPError, domain.get, domain_id)


class TestCreate(TestDomain):
    """Test the .create method."""

    @responses.activate
    def test_need_params(self):
        """
        The function should raise an exception when called without required
        parameters.
        """

        domain = Domain(client=self.client)
        # Not going to check every permutation of missing parameters,
        # but verify that something is required
        self.assertRaises(TypeError, domain.create)

    @responses.activate
    def test_create_success(self):
        """
        The function should return the created domain ID,
        as well as add all parameters to the request body
        """

        # Setup the mocked response
        domain_id = 1234
        org_id = 4321
        types = ["SSL"]
        location = f"{self.api_url}/{str(domain_id)}"
        responses.add(responses.POST, self.api_url, headers={"Location": location}, status=201)

        domain = Domain(client=self.client)
        post_data = {
            "name": "sub2.example.com",
            "delegations": [{"orgId": org_id, "certTypes": types}]
        }
        response = domain.create("sub2.example.com", org_id, types)

        self.assertEqual(response, {"id": domain_id})
        self.assertEqual(responses.calls[0].request.body, json.dumps(post_data).encode("utf8"))

    @responses.activate
    def test_create_success_optional_params(self):
        """
        The function should return the created domain ID when additional params are specified,
        as well add the non-required parameters to the request body
        """

        # Setup the mocked response
        domain_id = 1234
        location = f"{self.api_url}/{str(domain_id)}"
        responses.add(responses.POST, self.api_url, headers={"Location": location}, status=201)

        domain = Domain(client=self.client)
        post_data = {
            "name": "sub2.example.com",
            "delegations": [{"orgId": 4321, "certTypes": ["SSL"]}],
            "description": "Example sub domain"
        }
        response = domain.create("sub2.example.com", 4321, ["SSL"], description="Example sub domain")

        self.assertEqual(response, {"id": domain_id})
        self.assertEqual(responses.calls[0].request.body, json.dumps(post_data).encode("utf8"))

    @responses.activate
    def test_create_failure_http_error(self):
        """
        The function should return an error code and description if the Domain
        creation failed.
        """

        # Setup the mocked response
        responses.add(responses.POST, self.api_url, json=self.error_response,
                      status=400)

        domain = Domain(client=self.client)

        create_args = {
            "name": "sub2.example.com",
            "org_id": 4321,
            "cert_types": ["other"]
        }
        self.assertRaises(ValueError, domain.create, **create_args)

    @responses.activate
    def test_create_failure_http_status_unexpected(self):
        """
        The function should return an error code and description if the Domain
        creation failed with DomainCreationResponseError
        (unexpected HTTP status code).
        """

        # Setup the mocked response
        responses.add(responses.POST, self.api_url, json=self.error_response,
                      status=200)

        domain = Domain(client=self.client)

        create_args = {
            "name": "sub2.example.com",
            "org_id": 4321,
            "cert_types": ["SSL"]
        }
        self.assertRaises(DomainCreationResponseError, domain.create, **create_args)

    @responses.activate
    def test_create_failure_missing_location_header(self):
        """
        The function should return an error code and description if the Domain
        creation failed with DomainCreationResponseError
        (no Location header in response).
        """

        # Setup the mocked response
        responses.add(responses.POST, self.api_url, status=201)

        domain = Domain(client=self.client)

        create_args = {
            "name": "sub2.example.com",
            "org_id": 4321,
            "cert_types": ["SSL"]
        }
        self.assertRaises(DomainCreationResponseError, domain.create, **create_args)

    @responses.activate
    def test_create_failure_domain_id_not_found(self):
        """
        The function should return an error code and description if the Domain
        creation failed with DomainCreationResponseError
        (Domain ID not found in response).
        """

        # Setup the mocked response
        responses.add(responses.POST, self.api_url, headers={"Location": "not a url"}, status=201)

        domain = Domain(client=self.client)

        create_args = {
            "name": "sub2.example.com",
            "org_id": 4321,
            "cert_types": ["SSL"]
        }
        self.assertRaises(DomainCreationResponseError, domain.create, **create_args)


class TestDelete(TestDomain):
    """Test the .delete method."""

    @responses.activate
    def test_need_params(self):
        """
        The function should raise an exception when called without required
        parameters.
        """

        domain = Domain(client=self.client)
        # missing domain_id
        self.assertRaises(TypeError, domain.delete)

    @responses.activate
    def test_delete_success(self):
        """The function should return True if the deletion succeeded."""

        domain_id = 1234
        api_url = f"{self.api_url}/{str(domain_id)}"

        # Setup the mocked response
        responses.add(responses.DELETE, api_url, status=200)

        domain = Domain(client=self.client)
        response = domain.delete(domain_id)

        self.assertEqual(True, response)

    @responses.activate
    def test_delete_failure_http_error(self):
        """
        The function should raise an HTTPError exception if the deletion
        failed.
        """

        domain_id = 1234
        api_url = f"{self.api_url}/{str(domain_id)}"

        # Setup the mocked response
        responses.add(responses.DELETE, api_url, status=404)

        domain = Domain(client=self.client)

        self.assertRaises(HTTPError, domain.delete, domain_id)


class TestActivate(TestDomain):
    """Test the .activate method."""

    @responses.activate
    def test_need_params(self):
        """
        The function should raise an exception when called without required
        parameters.
        """

        domain = Domain(client=self.client)
        # missing domain_id
        self.assertRaises(TypeError, domain.activate)

    @responses.activate
    def test_activate_success(self):
        """The function should return True if the activation succeeded."""

        domain_id = 1234
        api_url = f"{self.api_url}/{str(domain_id)}/activate"

        # Setup the mocked response
        responses.add(responses.PUT, api_url, status=200)

        domain = Domain(client=self.client)
        response = domain.activate(domain_id)

        self.assertEqual(True, response)

    @responses.activate
    def test_activate_failure_http_error(self):
        """
        The function should raise an HTTPError exception if the deletion
        failed.
        """

        domain_id = 1234
        api_url = f"{self.api_url}/{str(domain_id)}/activate"

        # Setup the mocked response
        responses.add(responses.PUT, api_url, status=404)

        domain = Domain(client=self.client)

        self.assertRaises(HTTPError, domain.activate, domain_id)


class TestSuspend(TestDomain):
    """Test the .suspend method."""

    @responses.activate
    def test_need_params(self):
        """
        The function should raise an exception when called without required
        parameters.
        """

        domain = Domain(client=self.client)
        # missing domain_id
        self.assertRaises(TypeError, domain.suspend)

    @responses.activate
    def test_suspend_success(self):
        """The function should return True if the suspension succeeded."""

        domain_id = 1234
        api_url = f"{self.api_url}/{str(domain_id)}/suspend"

        # Setup the mocked response
        responses.add(responses.PUT, api_url, status=200)

        domain = Domain(client=self.client)
        response = domain.suspend(domain_id)

        self.assertEqual(True, response)

    @responses.activate
    def test_suspend_failure_http_error(self):
        """
        The function should raise an HTTPError exception if the suspension
        failed.
        """

        domain_id = 1234
        api_url = f"{self.api_url}/{str(domain_id)}/suspend"

        # Setup the mocked response
        responses.add(responses.PUT, api_url, status=404)

        domain = Domain(client=self.client)

        self.assertRaises(HTTPError, domain.suspend, domain_id)


class TestDelegate(TestDomain):
    """Test the .delegate method."""

    @responses.activate
    def test_need_params(self):
        """
        The function should raise an exception when called without required
        parameters.
        """

        domain = Domain(client=self.client)
        # missing domain_id
        self.assertRaises(TypeError, domain.delegate)

    @responses.activate
    def test_delegate_success(self):
        """The function should return True if the delegation succeeded."""

        domain_id = 1234
        org_id = 4321
        types = ["SSL"]
        api_url = f"{self.api_url}/{str(domain_id)}/delegation"

        # Setup the mocked response
        responses.add(responses.POST, api_url, status=200)

        domain = Domain(client=self.client)
        response = domain.delegate(domain_id, org_id, types)
        post_data = {
            "orgId": org_id,
            "certTypes": types
        }

        self.assertEqual(True, response)
        self.assertEqual(responses.calls[0].request.body, json.dumps(post_data).encode("utf8"))

    @responses.activate
    def test_delegate_failure_http_error(self):
        """The function should raise an HTTPError exception if the delegation failed."""

        domain_id = 1234
        org_id = 4321
        types = ["SSL"]
        api_url = f"{self.api_url}/{str(domain_id)}/delegation"

        # Setup the mocked response
        responses.add(responses.POST, api_url, status=404)

        domain = Domain(client=self.client)

        self.assertRaises(HTTPError, domain.delegate, domain_id, org_id, types)


class TestRemoveDelegation(TestDomain):
    """Test the .remove_delegation method."""

    @responses.activate
    def test_need_params(self):
        """
        The function should raise an exception when called without required
        parameters.
        """

        domain = Domain(client=self.client)
        # missing domain_id
        self.assertRaises(TypeError, domain.remove_delegation)

    @responses.activate
    def test_remove_delegation_success(self):
        """The function should return True if the delegation removal succeeded."""

        domain_id = 1234
        org_id = 4321
        types = ["SSL"]
        api_url = f"{self.api_url}/{str(domain_id)}/delegation"

        # Setup the mocked response
        responses.add(responses.DELETE, api_url, status=200)

        domain = Domain(client=self.client)
        response = domain.remove_delegation(domain_id, org_id, types)
        post_data = {
            "orgId": org_id,
            "certTypes": types
        }

        self.assertEqual(True, response)
        self.assertEqual(responses.calls[0].request.body, json.dumps(post_data).encode("utf8"))

    @responses.activate
    def test_remove_delegation_failure_http_error(self):
        """The function should raise an HTTPError exception if the delegation removal failed."""

        domain_id = 1234
        org_id = 4321
        types = ["SSL"]
        api_url = f"{self.api_url}/{str(domain_id)}/delegation"

        # Setup the mocked response
        responses.add(responses.DELETE, api_url, status=404)

        domain = Domain(client=self.client)

        self.assertRaises(HTTPError, domain.remove_delegation, domain_id, org_id, types)


class TestApproveDelegation(TestDomain):
    """Test the .approve_delegation method."""

    @responses.activate
    def test_need_params(self):
        """
        The function should raise an exception when called without required
        parameters.
        """

        domain = Domain(client=self.client)
        # missing domain_id
        self.assertRaises(TypeError, domain.approve_delegation)

    @responses.activate
    def test_approve_delegation_success(self):
        """The function should return True if the approval succeeded."""

        domain_id = 1234
        org_id = 4321
        api_url = f"{self.api_url}/{str(domain_id)}/delegation/approve"

        # Setup the mocked response
        responses.add(responses.POST, api_url, status=200)

        domain = Domain(client=self.client)
        response = domain.approve_delegation(domain_id, org_id)
        post_data = {
            "orgId": org_id,
        }

        self.assertEqual(True, response)
        self.assertEqual(responses.calls[0].request.body, json.dumps(post_data).encode("utf8"))

    @responses.activate
    def test_approval_failure_http_error(self):
        """The function should raise an HTTPError exception if the approval failed."""

        domain_id = 1234
        org_id = 4321
        api_url = f"{self.api_url}/{str(domain_id)}/delegation/approve"

        # Setup the mocked response
        responses.add(responses.POST, api_url, status=404)

        domain = Domain(client=self.client)

        self.assertRaises(HTTPError, domain.approve_delegation, domain_id, org_id)


class TestRejectDelegation(TestDomain):
    """Test the .reject_delegation method."""

    @responses.activate
    def test_need_params(self):
        """
        The function should raise an exception when called without required
        parameters.
        """

        domain = Domain(client=self.client)
        # missing domain_id
        self.assertRaises(TypeError, domain.reject_delegation)

    @responses.activate
    def test_reject_delegation_success(self):
        """The function should return True if the rejection succeeded."""

        domain_id = 1234
        org_id = 4321
        api_url = f"{self.api_url}/{str(domain_id)}/delegation/reject"

        # Setup the mocked response
        responses.add(responses.POST, api_url, status=200)

        domain = Domain(client=self.client)
        response = domain.reject_delegation(domain_id, org_id)
        post_data = {
            "orgId": org_id,
        }

        self.assertEqual(True, response)
        self.assertEqual(responses.calls[0].request.body, json.dumps(post_data).encode("utf8"))

    @responses.activate
    def test_reject_failure_http_error(self):
        """The function should raise an HTTPError exception if the rejection failed."""

        domain_id = 1234
        org_id = 4321
        api_url = f"{self.api_url}/{str(domain_id)}/delegation/reject"

        # Setup the mocked response
        responses.add(responses.POST, api_url, status=404)

        domain = Domain(client=self.client)

        self.assertRaises(HTTPError, domain.reject_delegation, domain_id, org_id)

[((59, 8, 59, 83), 'responses.add', 'responses.add', (), '', False, 'import responses\n'), ((61, 17, 61, 64), 'cert_manager.domain.Domain', 'Domain', (), '', False, 'from cert_manager.domain import Domain, DomainCreationResponseError\n'), ((82, 8, 82, 88), 'responses.add', 'responses.add', (), '', False, 'import responses\n'), ((84, 17, 84, 43), 'cert_manager.domain.Domain', 'Domain', (), '', False, 'from cert_manager.domain import Domain, DomainCreationResponseError\n'), ((100, 8, 100, 88), 'responses.add', 'responses.add', (), '', False, 'import responses\n'), ((102, 17, 102, 43), 'cert_manager.domain.Domain', 'Domain', (), '', False, 'from cert_manager.domain import Domain, DomainCreationResponseError\n'), ((119, 8, 119, 88), 'responses.add', 'responses.add', (), '', False, 'import responses\n'), ((121, 17, 121, 43), 'cert_manager.domain.Domain', 'Domain', (), '', False, 'from cert_manager.domain import Domain, DomainCreationResponseError\n'), ((136, 8, 136, 88), 'responses.add', 'responses.add', (), '', False, 'import responses\n'), ((138, 17, 138, 43), 'cert_manager.domain.Domain', 'Domain', (), '', False, 'from cert_manager.domain import Domain, DomainCreationResponseError\n'), ((147, 8, 147, 91), 'responses.add', 'responses.add', (), '', False, 'import responses\n'), ((150, 17, 150, 43), 'cert_manager.domain.Domain', 'Domain', (), '', False, 'from cert_manager.domain import Domain, DomainCreationResponseError\n'), ((162, 8, 162, 88), 'responses.add', 'responses.add', (), '', False, 'import responses\n'), ((164, 17, 164, 43), 'cert_manager.domain.Domain', 'Domain', (), '', False, 'from cert_manager.domain import Domain, DomainCreationResponseError\n'), ((181, 8, 181, 69), 'responses.add', 'responses.add', (), '', False, 'import responses\n'), ((183, 17, 183, 43), 'cert_manager.domain.Domain', 'Domain', (), '', False, 'from cert_manager.domain import Domain, DomainCreationResponseError\n'), ((195, 8, 195, 69), 'responses.add', 'responses.add', (), '', False, 'import responses\n'), ((197, 17, 197, 43), 'cert_manager.domain.Domain', 'Domain', (), '', False, 'from cert_manager.domain import Domain, DomainCreationResponseError\n'), ((209, 8, 209, 83), 'responses.add', 'responses.add', (), '', False, 'import responses\n'), ((211, 17, 211, 43), 'cert_manager.domain.Domain', 'Domain', (), '', False, 'from cert_manager.domain import Domain, DomainCreationResponseError\n'), ((226, 17, 226, 43), 'cert_manager.domain.Domain', 'Domain', (), '', False, 'from cert_manager.domain import Domain, DomainCreationResponseError\n'), ((237, 8, 237, 94), 'responses.add', 'responses.add', (), '', False, 'import responses\n'), ((239, 17, 239, 43), 'cert_manager.domain.Domain', 'Domain', (), '', False, 'from cert_manager.domain import Domain, DomainCreationResponseError\n'), ((254, 8, 254, 57), 'responses.add', 'responses.add', (), '', False, 'import responses\n'), ((256, 17, 256, 43), 'cert_manager.domain.Domain', 'Domain', (), '', False, 'from cert_manager.domain import Domain, DomainCreationResponseError\n'), ((270, 17, 270, 43), 'cert_manager.domain.Domain', 'Domain', (), '', False, 'from cert_manager.domain import Domain, DomainCreationResponseError\n'), ((287, 8, 287, 95), 'responses.add', 'responses.add', (), '', False, 'import responses\n'), ((289, 17, 289, 43), 'cert_manager.domain.Domain', 'Domain', (), '', False, 'from cert_manager.domain import Domain, DomainCreationResponseError\n'), ((309, 8, 309, 95), 'responses.add', 'responses.add', (), '', False, 'import responses\n'), ((311, 17, 311, 43), 'cert_manager.domain.Domain', 'Domain', (), '', False, 'from cert_manager.domain import Domain, DomainCreationResponseError\n'), ((330, 8, 331, 33), 'responses.add', 'responses.add', (), '', False, 'import responses\n'), ((333, 17, 333, 43), 'cert_manager.domain.Domain', 'Domain', (), '', False, 'from cert_manager.domain import Domain, DomainCreationResponseError\n'), ((351, 8, 352, 33), 'responses.add', 'responses.add', (), '', False, 'import responses\n'), ((354, 17, 354, 43), 'cert_manager.domain.Domain', 'Domain', (), '', False, 'from cert_manager.domain import Domain, DomainCreationResponseError\n'), ((372, 8, 372, 63), 'responses.add', 'responses.add', (), '', False, 'import responses\n'), ((374, 17, 374, 43), 'cert_manager.domain.Domain', 'Domain', (), '', False, 'from cert_manager.domain import Domain, DomainCreationResponseError\n'), ((392, 8, 392, 98), 'responses.add', 'responses.add', (), '', False, 'import responses\n'), ((394, 17, 394, 43), 'cert_manager.domain.Domain', 'Domain', (), '', False, 'from cert_manager.domain import Domain, DomainCreationResponseError\n'), ((414, 17, 414, 43), 'cert_manager.domain.Domain', 'Domain', (), '', False, 'from cert_manager.domain import Domain, DomainCreationResponseError\n'), ((426, 8, 426, 60), 'responses.add', 'responses.add', (), '', False, 'import responses\n'), ((428, 17, 428, 43), 'cert_manager.domain.Domain', 'Domain', (), '', False, 'from cert_manager.domain import Domain, DomainCreationResponseError\n'), ((444, 8, 444, 60), 'responses.add', 'responses.add', (), '', False, 'import responses\n'), ((446, 17, 446, 43), 'cert_manager.domain.Domain', 'Domain', (), '', False, 'from cert_manager.domain import Domain, DomainCreationResponseError\n'), ((461, 17, 461, 43), 'cert_manager.domain.Domain', 'Domain', (), '', False, 'from cert_manager.domain import Domain, DomainCreationResponseError\n'), ((473, 8, 473, 57), 'responses.add', 'responses.add', (), '', False, 'import responses\n'), ((475, 17, 475, 43), 'cert_manager.domain.Domain', 'Domain', (), '', False, 'from cert_manager.domain import Domain, DomainCreationResponseError\n'), ((491, 8, 491, 57), 'responses.add', 'responses.add', (), '', False, 'import responses\n'), ((493, 17, 493, 43), 'cert_manager.domain.Domain', 'Domain', (), '', False, 'from cert_manager.domain import Domain, DomainCreationResponseError\n'), ((508, 17, 508, 43), 'cert_manager.domain.Domain', 'Domain', (), '', False, 'from cert_manager.domain import Domain, DomainCreationResponseError\n'), ((520, 8, 520, 57), 'responses.add', 'responses.add', (), '', False, 'import responses\n'), ((522, 17, 522, 43), 'cert_manager.domain.Domain', 'Domain', (), '', False, 'from cert_manager.domain import Domain, DomainCreationResponseError\n'), ((538, 8, 538, 57), 'responses.add', 'responses.add', (), '', False, 'import responses\n'), ((540, 17, 540, 43), 'cert_manager.domain.Domain', 'Domain', (), '', False, 'from cert_manager.domain import Domain, DomainCreationResponseError\n'), ((555, 17, 555, 43), 'cert_manager.domain.Domain', 'Domain', (), '', False, 'from cert_manager.domain import Domain, DomainCreationResponseError\n'), ((569, 8, 569, 58), 'responses.add', 'responses.add', (), '', False, 'import responses\n'), ((571, 17, 571, 43), 'cert_manager.domain.Domain', 'Domain', (), '', False, 'from cert_manager.domain import Domain, DomainCreationResponseError\n'), ((591, 8, 591, 58), 'responses.add', 'responses.add', (), '', False, 'import responses\n'), ((593, 17, 593, 43), 'cert_manager.domain.Domain', 'Domain', (), '', False, 'from cert_manager.domain import Domain, DomainCreationResponseError\n'), ((608, 17, 608, 43), 'cert_manager.domain.Domain', 'Domain', (), '', False, 'from cert_manager.domain import Domain, DomainCreationResponseError\n'), ((622, 8, 622, 60), 'responses.add', 'responses.add', (), '', False, 'import responses\n'), ((624, 17, 624, 43), 'cert_manager.domain.Domain', 'Domain', (), '', False, 'from cert_manager.domain import Domain, DomainCreationResponseError\n'), ((644, 8, 644, 60), 'responses.add', 'responses.add', (), '', False, 'import responses\n'), ((646, 17, 646, 43), 'cert_manager.domain.Domain', 'Domain', (), '', False, 'from cert_manager.domain import Domain, DomainCreationResponseError\n'), ((661, 17, 661, 43), 'cert_manager.domain.Domain', 'Domain', (), '', False, 'from cert_manager.domain import Domain, DomainCreationResponseError\n'), ((674, 8, 674, 58), 'responses.add', 'responses.add', (), '', False, 'import responses\n'), ((676, 17, 676, 43), 'cert_manager.domain.Domain', 'Domain', (), '', False, 'from cert_manager.domain import Domain, DomainCreationResponseError\n'), ((694, 8, 694, 58), 'responses.add', 'responses.add', (), '', False, 'import responses\n'), ((696, 17, 696, 43), 'cert_manager.domain.Domain', 'Domain', (), '', False, 'from cert_manager.domain import Domain, DomainCreationResponseError\n'), ((711, 17, 711, 43), 'cert_manager.domain.Domain', 'Domain', (), '', False, 'from cert_manager.domain import Domain, DomainCreationResponseError\n'), ((724, 8, 724, 58), 'responses.add', 'responses.add', (), '', False, 'import responses\n'), ((726, 17, 726, 43), 'cert_manager.domain.Domain', 'Domain', (), '', False, 'from cert_manager.domain import Domain, DomainCreationResponseError\n'), ((744, 8, 744, 58), 'responses.add', 'responses.add', (), '', False, 'import responses\n'), ((746, 17, 746, 43), 'cert_manager.domain.Domain', 'Domain', (), '', False, 'from cert_manager.domain import Domain, DomainCreationResponseError\n'), ((297, 58, 297, 79), 'json.dumps', 'json.dumps', ({(297, 69, 297, 78): 'post_data'}, {}), '(post_data)', False, 'import json\n'), ((320, 58, 320, 79), 'json.dumps', 'json.dumps', ({(320, 69, 320, 78): 'post_data'}, {}), '(post_data)', False, 'import json\n'), ((579, 58, 579, 79), 'json.dumps', 'json.dumps', ({(579, 69, 579, 78): 'post_data'}, {}), '(post_data)', False, 'import json\n'), ((632, 58, 632, 79), 'json.dumps', 'json.dumps', ({(632, 69, 632, 78): 'post_data'}, {}), '(post_data)', False, 'import json\n'), ((683, 58, 683, 79), 'json.dumps', 'json.dumps', ({(683, 69, 683, 78): 'post_data'}, {}), '(post_data)', False, 'import json\n'), ((733, 58, 733, 79), 'json.dumps', 'json.dumps', ({(733, 69, 733, 78): 'post_data'}, {}), '(post_data)', False, 'import json\n')]