def test_client_without_credentials(self, get_project_id_mock,
                                     credential_mock,
                                     unused_discovery_mock):
     from certbot_dns_google.dns_google import _GoogleClient
     _GoogleClient(None)
     self.assertFalse(credential_mock.called)
     self.assertTrue(get_project_id_mock.called)
    def _setUp_client_with_mock(self, zone_request_side_effect):
        from certbot_dns_google.dns_google import _GoogleClient

        pwd = os.path.dirname(__file__)
        rel_path = 'testdata/discovery.json'
        discovery_file = os.path.join(pwd, rel_path)
        http_mock = HttpMock(discovery_file, {'status': '200'})
        dns_api = discovery.build('dns', 'v1', http=http_mock)

        client = _GoogleClient(ACCOUNT_JSON_PATH, dns_api)

        # Setup
        mock_mz = mock.MagicMock()
        mock_mz.list.return_value.execute.side_effect = zone_request_side_effect

        mock_rrs = mock.MagicMock()
        rrsets = {
            "rrsets": [{
                "name": "_acme-challenge.example.org.",
                "type": "TXT",
                "rrdatas": ["\"example-txt-contents\""]
            }]
        }
        mock_rrs.list.return_value.execute.return_value = rrsets
        mock_changes = mock.MagicMock()

        client.dns.managedZones = mock.MagicMock(return_value=mock_mz)
        client.dns.changes = mock.MagicMock(return_value=mock_changes)
        client.dns.resourceRecordSets = mock.MagicMock(return_value=mock_rrs)

        return client, mock_changes
    def _setUp_client_with_mock(self, zone_request_side_effect):
        from certbot_dns_google.dns_google import _GoogleClient

        pwd = os.path.dirname(__file__)
        rel_path = 'testdata/discovery.json'
        discovery_file = os.path.join(pwd, rel_path)
        http_mock = HttpMock(discovery_file, {'status': '200'})
        dns_api = discovery.build('dns', 'v1', http=http_mock)

        client = _GoogleClient(ACCOUNT_JSON_PATH, dns_api)

        # Setup
        mock_mz = mock.MagicMock()
        mock_mz.list.return_value.execute.side_effect = zone_request_side_effect

        mock_rrs = mock.MagicMock()
        rrsets = {"rrsets": [{"name": "_acme-challenge.example.org.", "type": "TXT",
                              "rrdatas": ["\"example-txt-contents\""]}]}
        mock_rrs.list.return_value.execute.return_value = rrsets
        mock_changes = mock.MagicMock()

        client.dns.managedZones = mock.MagicMock(return_value=mock_mz)
        client.dns.changes = mock.MagicMock(return_value=mock_changes)
        client.dns.resourceRecordSets = mock.MagicMock(return_value=mock_rrs)

        return client, mock_changes
Example #4
0
    def _setUp_client_with_mock(self, zone_request_side_effect):
        from certbot_dns_google.dns_google import _GoogleClient

        client = _GoogleClient(ACCOUNT_JSON_PATH)

        # Setup
        mock_mz = mock.MagicMock()
        mock_mz.list.return_value.execute.side_effect = zone_request_side_effect

        mock_rrs = mock.MagicMock()
        rrsets = {
            "rrsets": [{
                "name": "_acme-challenge.example.org.",
                "type": "TXT",
                "rrdatas": ["\"example-txt-contents\""]
            }]
        }
        mock_rrs.list.return_value.execute.return_value = rrsets
        mock_changes = mock.MagicMock()

        client.dns.managedZones = mock.MagicMock(return_value=mock_mz)
        client.dns.changes = mock.MagicMock(return_value=mock_changes)
        client.dns.resourceRecordSets = mock.MagicMock(return_value=mock_rrs)

        return client, mock_changes
Example #5
0
    def _setUp_client_with_mock(self, zone_request_side_effect):
        from certbot_dns_google.dns_google import _GoogleClient

        client = _GoogleClient(ACCOUNT_JSON_PATH)

        # Setup
        mock_mz = mock.MagicMock()
        mock_mz.list.return_value.execute.side_effect = zone_request_side_effect

        mock_changes = mock.MagicMock()

        client.dns.managedZones = mock.MagicMock(return_value=mock_mz)
        client.dns.changes = mock.MagicMock(return_value=mock_changes)

        return client, mock_changes
 def test_client_without_credentials(self, get_project_id_mock, credential_mock,
                                     unused_discovery_mock):
     from certbot_dns_google.dns_google import _GoogleClient
     _GoogleClient(None)
     self.assertFalse(credential_mock.called)
     self.assertTrue(get_project_id_mock.called)