Example #1
0
    def testCreateWithServiceDirectoryAndPrivateVisibility(self):
        sd_url = ('https://servicedirectory.googleapis.com/v1/projects'
                  'my-project/locations/us-central1/namespaces/my-namespace')
        service_directory_config = util_beta.ServiceDirectoryConfig(sd_url)
        visibility_settings = util.GetDnsVisibilityDict(
            self.api_version,
            visibility='private',
            network_urls=['1.0.2.1', '1.2.2.1'],
            messages=self.messages)

        test_zone = util_beta.GetManagedZoneBeforeCreation(
            self.messages,
            visibility_dict=visibility_settings,
            service_directory_config=service_directory_config)

        zone_create_request = self.messages.DnsManagedZonesCreateRequest(
            managedZone=test_zone, project=self.Project())
        self.client.managedZones.Create.Expect(zone_create_request, test_zone)

        self.Run(
            'dns managed-zones create {0} --dns-name {1} --description {2} '
            '--format=disable --visibility private --networks {3} '
            '--service-directory-namespace {4}'.format(
                test_zone.name, test_zone.dnsName, test_zone.description,
                ','.join(['1.0.2.1', '1.2.2.1']), sd_url))
Example #2
0
    def testCreateWithOnlyPrivateForwardingTargetsAndPrivateVisibility(self):
        private_forwarding_targets = ['1.1.1.1', '8.8.8.8']
        forwarding_config = util_beta.ParseManagedZoneForwardingConfig(
            private_target_servers=private_forwarding_targets)

        visibility_settings = util_beta.GetDnsVisibilityDict(
            self.api_version,
            visibility='private',
            network_urls=['1.0.2.1', '1.2.2.1'])
        test_zone = util_beta.GetManagedZoneBeforeCreation(
            self.messages,
            dns_sec_config=False,
            visibility_dict=visibility_settings,
            forwarding_config=forwarding_config)

        zone_create_request = self.messages.DnsManagedZonesCreateRequest(
            managedZone=test_zone, project=self.Project())
        self.client.managedZones.Create.Expect(zone_create_request, test_zone)
        result = self.Run(
            'dns managed-zones create {0} --dns-name {1} --description {2} '
            '--format=disable --visibility private '
            '--private-forwarding-targets {3} --networks {4}'.format(
                test_zone.name, test_zone.dnsName, test_zone.description,
                ','.join(private_forwarding_targets),
                ','.join(['1.0.2.1', '1.2.2.1'])))

        self.assertEqual([test_zone], list(result))
        self.AssertOutputEquals('')
        self.AssertErrContains("""\
Created [{0}projects/{1}/managedZones/mz].
""".format(self.client.BASE_URL, self.Project()))
Example #3
0
 def testCreateWithDnsPeeringIncompleteTargetNetworkSimpler(self):
     test_zone = util_beta.GetManagedZoneBeforeCreation(
         self.messages, dns_sec_config=False, visibility_dict=None)
     # set target-network, no target-project.
     with self.assertRaisesRegex(
             cli_test_base.MockArgumentError,
             'argument --target-project: Must be specified.'):
         self.Run(
             'dns managed-zones create {0} --dns-name {1} --description {2} '
             '--target-network tn'.format(test_zone.name, test_zone.dnsName,
                                          test_zone.description))
Example #4
0
    def testCreateWithReverseLookup(self):
        reverse_lookup_config = self.messages.ManagedZoneReverseLookupConfig()
        test_zone = util_beta.GetManagedZoneBeforeCreation(
            self.messages, reverse_lookup_config=reverse_lookup_config)
        zone_create_request = self.messages.DnsManagedZonesCreateRequest(
            managedZone=test_zone, project=self.Project())
        self.client.managedZones.Create.Expect(zone_create_request, test_zone)

        self.Run(
            'dns managed-zones create {0} --dns-name {1} --description {2} '
            '--managed-reverse-lookup'.format(test_zone.name,
                                              test_zone.dnsName,
                                              test_zone.description))
Example #5
0
    def testCreateWithDnsPeering(self):
        peering_config = util_beta.PeeringConfig('tp', 'tn')
        test_zone = util_beta.GetManagedZoneBeforeCreation(
            self.messages, peering_config=peering_config)

        zone_create_request = self.messages.DnsManagedZonesCreateRequest(
            managedZone=test_zone, project=self.Project())
        self.client.managedZones.Create.Expect(zone_create_request, test_zone)

        self.Run(
            'dns managed-zones create {0} --dns-name {1} --description {2} '
            '--target-network tn --target-project tp'.format(
                test_zone.name, test_zone.dnsName, test_zone.description))
Example #6
0
 def testCreateWithForwardingTargetsandPublicVisibility(self):
     visibility_settings = util_beta.GetDnsVisibilityDict(
         self.api_version, visibility='private', network_urls=[])
     test_zone = util_beta.GetManagedZoneBeforeCreation(
         self.messages,
         dns_sec_config=False,
         visibility_dict=visibility_settings)
     with self.assertRaises(exceptions.InvalidArgumentException):
         self.Run(
             'dns managed-zones create {0} --dns-name {1} --description {2} '
             '--format=disable --visibility public '
             '--forwarding-targets 1.0.0.1 --networks 1.0.0.1'.format(
                 test_zone.name, test_zone.dnsName, test_zone.description))