-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* 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 * allow changing operator identity order This allows changing the order of platform identities while still preventing the resource ID and operator name from being changed * additional platform identity update validation This prevents removal of a platform identity or changing the identity's OperatorName and ResourceID at the same time * detect duplicate operator names in platform workload identity profiles * use a map instead of a slice
- Loading branch information
Showing
4 changed files
with
297 additions
and
25 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
Oops, something went wrong.