-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
prevent updating existing platform identities
This adds a check to v20240812preview static validation that raises an error if either the name or resource ID of an existing platform identity
- Loading branch information
Showing
4 changed files
with
168 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package v20240812preview | ||
|
||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the Apache License 2.0. | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
) | ||
|
||
func TestIsWorkloadIdentity(t *testing.T) { | ||
tests := []*struct { | ||
name string | ||
oc OpenShiftCluster | ||
want bool | ||
}{ | ||
{ | ||
name: "Cluster is Workload Identity", | ||
oc: OpenShiftCluster{ | ||
Properties: OpenShiftClusterProperties{ | ||
PlatformWorkloadIdentityProfile: &PlatformWorkloadIdentityProfile{}, | ||
ServicePrincipalProfile: nil, | ||
}, | ||
}, | ||
want: true, | ||
}, | ||
{ | ||
name: "Cluster is Service Principal", | ||
oc: OpenShiftCluster{ | ||
Properties: OpenShiftClusterProperties{ | ||
PlatformWorkloadIdentityProfile: nil, | ||
ServicePrincipalProfile: &ServicePrincipalProfile{}, | ||
}, | ||
}, | ||
want: false, | ||
}, | ||
{ | ||
name: "Cluster is Service Principal", | ||
oc: OpenShiftCluster{ | ||
Properties: OpenShiftClusterProperties{ | ||
PlatformWorkloadIdentityProfile: nil, | ||
ServicePrincipalProfile: nil, | ||
}, | ||
}, | ||
want: false, | ||
}, | ||
{ | ||
name: "Cluster is Service Principal", | ||
oc: OpenShiftCluster{ | ||
Properties: OpenShiftClusterProperties{ | ||
PlatformWorkloadIdentityProfile: &PlatformWorkloadIdentityProfile{}, | ||
ServicePrincipalProfile: &ServicePrincipalProfile{}, | ||
}, | ||
}, | ||
want: false, | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
t.Run(test.name, func(t *testing.T) { | ||
got := test.oc.UsesWorkloadIdentity() | ||
if got != test.want { | ||
t.Error(fmt.Errorf("got != want: %v != %v", got, test.want)) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters