5151 invalidXpnSA = "[email protected] " 5252 validServiceEndpointURL = "https://computeexample.googleapis.com/compute/v1/"
5353 invalidServiceEndpointURL = "http://badstorage.googleapis"
54- permissionsProject = "permissions-project"
5554
5655 // #nosec G101
5756 fakeCreds = `{
@@ -118,8 +117,6 @@ var (
118117 invalidateXpnSA = func (ic * types.InstallConfig ) { ic .ControlPlane .Platform .GCP .ServiceAccount = invalidXpnSA }
119118 invalidateBaseDomain = func (ic * types.InstallConfig ) { ic .BaseDomain = invalidBaseDomain }
120119 enableCustomDNS = func (ic * types.InstallConfig ) { ic .GCP .UserProvisionedDNS = customDNS .UserProvisionedDNSEnabled }
121- resetNetwork = func (ic * types.InstallConfig ) { ic .GCP .Network = "" }
122- validPermissionProject = func (ic * types.InstallConfig ) { ic .GCP .ProjectID = permissionsProject }
123120
124121 invalidKeyRing = gcp.KMSKeyReference {
125122 Name : "invalidKeyName" ,
@@ -462,12 +459,6 @@ func TestGCPInstallConfigValidation(t *testing.T) {
462459 records : []* dns.ResourceRecordSet {},
463460 expectedError : false ,
464461 },
465- {
466- name : "Invalid missing permissions and network" ,
467- edits : editFunctions {resetNetwork , validPermissionProject },
468- records : []* dns.ResourceRecordSet {},
469- expectedError : true , // platform.gcp.network: Required value: firewall rule creation permission is missing, an existing network is required
470- },
471462 }
472463 mockCtrl := gomock .NewController (t )
473464 defer mockCtrl .Finish ()
@@ -477,9 +468,8 @@ func TestGCPInstallConfigValidation(t *testing.T) {
477468 errNotFound := & googleapi.Error {Code : http .StatusNotFound }
478469
479470 // Should get the list of projects.
480- gcpClient .EXPECT ().GetProjects (gomock .Any ()).Return (map [string ]string {"valid-project" : "valid-project" , permissionsProject : permissionsProject }, nil ).AnyTimes ()
471+ gcpClient .EXPECT ().GetProjects (gomock .Any ()).Return (map [string ]string {"valid-project" : "valid-project" }, nil ).AnyTimes ()
481472 gcpClient .EXPECT ().GetProjectByID (gomock .Any (), "valid-project" ).Return (& cloudresourcemanager.Project {}, nil ).AnyTimes ()
482- gcpClient .EXPECT ().GetProjectByID (gomock .Any (), permissionsProject ).Return (& cloudresourcemanager.Project {}, nil ).AnyTimes ()
483473 gcpClient .EXPECT ().GetProjectByID (gomock .Any (), "invalid-project" ).Return (nil , errNotFound ).AnyTimes ()
484474 gcpClient .EXPECT ().GetProjectByID (gomock .Any (), gomock .Any ()).Return (nil , fmt .Errorf ("error" )).AnyTimes ()
485475
@@ -490,7 +480,6 @@ func TestGCPInstallConfigValidation(t *testing.T) {
490480 gcpClient .EXPECT ().GetRegions (gomock .Any (), invalidProjectName ).Return (nil , fmt .Errorf ("failed to get regions for project" )).AnyTimes ()
491481 // When passed a project that is valid but the region is not contained, an error should still occur
492482 gcpClient .EXPECT ().GetRegions (gomock .Any (), validProjectName ).Return ([]string {validRegion }, nil ).AnyTimes ()
493- gcpClient .EXPECT ().GetRegions (gomock .Any (), permissionsProject ).Return ([]string {validRegion }, nil ).AnyTimes ()
494483
495484 // Should return the machine type as specified.
496485 for key , value := range machineTypeAPIResult {
@@ -509,7 +498,6 @@ func TestGCPInstallConfigValidation(t *testing.T) {
509498 // When passed a correct network, project, & region, returns valid subnets.
510499 // We will test incorrect subnets, by changing the install config.
511500 gcpClient .EXPECT ().GetSubnetworks (gomock .Any (), validNetworkName , validProjectName , validRegion ).Return (subnetAPIResult , nil ).AnyTimes ()
512- gcpClient .EXPECT ().GetSubnetworks (gomock .Any (), validNetworkName , permissionsProject , validRegion ).Return (subnetAPIResult , nil ).AnyTimes ()
513501
514502 // When passed an incorrect network, project or region, return empty list.
515503 gcpClient .EXPECT ().GetSubnetworks (gomock .Any (), gomock .Not (validNetworkName ), gomock .Any (), gomock .Any ()).Return ([]* compute.Subnetwork {}, nil ).AnyTimes ()
@@ -544,14 +532,9 @@ func TestGCPInstallConfigValidation(t *testing.T) {
544532 gcpClient .EXPECT ().GetKeyRing (gomock .Any (), & invalidKeyRing ).Return (nil , fmt .Errorf ("failed to find key ring invalidKeyRingName: data" )).AnyTimes ()
545533
546534 gcpClient .EXPECT ().GetDNSZone (gomock .Any (), validProjectName , validBaseDomain , true ).Return (& dns.ManagedZone {Name : validZone }, nil ).AnyTimes ()
547- gcpClient .EXPECT ().GetDNSZone (gomock .Any (), permissionsProject , validBaseDomain , true ).Return (& dns.ManagedZone {Name : validZone }, nil ).AnyTimes ()
548535 gcpClient .EXPECT ().GetDNSZone (gomock .Any (), invalidProjectName , validBaseDomain , true ).Return (& dns.ManagedZone {Name : validZone }, nil ).AnyTimes ()
549536 gcpClient .EXPECT ().GetDNSZone (gomock .Any (), validProjectName , invalidBaseDomain , true ).Return (nil , fmt .Errorf ("baseDomain: Not found: \" %s\" " , invalidBaseDomain )).AnyTimes ()
550537
551- gcpClient .EXPECT ().ValidateServiceAccountHasPermissions (gomock .Any (), permissionsProject , []string {CreateGCPFirewallPermission }).Return (false , nil ).AnyTimes ()
552- gcpClient .EXPECT ().ValidateServiceAccountHasPermissions (gomock .Any (), validProjectName , []string {CreateGCPFirewallPermission }).Return (true , nil ).AnyTimes ()
553- gcpClient .EXPECT ().ValidateServiceAccountHasPermissions (gomock .Any (), invalidProjectName , []string {CreateGCPFirewallPermission }).Return (false , fmt .Errorf ("failed to get project permissions" )).AnyTimes ()
554-
555538 httpmock .Activate ()
556539 defer httpmock .DeactivateAndReset ()
557540
0 commit comments