Skip to content

Commit 804338d

Browse files
everettravenopenshift-cherrypick-robot
authored andcommitted
e2e: add validation to tests that operand versions get unset
Signed-off-by: Bryce Palmer <[email protected]>
1 parent 35324eb commit 804338d

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/e2e-oidc/external_oidc_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,7 @@ func (tc *testClient) validateOAuthState(t *testing.T, ctx context.Context, requ
704704
validationErrs = append(validationErrs, validateOAuthResources(ctx, dynamicClient, requireMissing)...)
705705
validationErrs = append(validationErrs, validateOAuthRoutes(ctx, tc.routeClient, tc.configClient, requireMissing)...)
706706
validationErrs = append(validationErrs, validateOAuthControllerConditions(tc.operatorClient, requireMissing)...)
707+
validationErrs = append(validationErrs, validateOperandVersions(ctx, tc.configClient, requireMissing)...)
707708
return len(validationErrs) == 0, nil
708709
})
709710

@@ -849,6 +850,33 @@ func validateOAuthControllerConditions(operatorClient v1helpers.OperatorClient,
849850
return nil
850851
}
851852

853+
func validateOperandVersions(ctx context.Context, cfgClient *configclient.Clientset, requireMissing bool) []error {
854+
operands := sets.New("oauth-apiserver", "oauth-openshift")
855+
856+
authnClusterOperator, err := cfgClient.ConfigV1().ClusterOperators().Get(ctx, "authentication", metav1.GetOptions{})
857+
if err != nil {
858+
return []error{fmt.Errorf("fetching authentication ClusterOperator: %w", err)}
859+
}
860+
861+
foundOperands := []string{}
862+
for _, version := range authnClusterOperator.Status.Versions {
863+
if operands.Has(version.Name) {
864+
foundOperands = append(foundOperands, version.Name)
865+
}
866+
}
867+
868+
if requireMissing && len(foundOperands) > 0 {
869+
return []error{fmt.Errorf("authentication ClusterOperator status has operands %v in versions when they should be unset", foundOperands)}
870+
}
871+
872+
foundSet := sets.New(foundOperands...)
873+
if !requireMissing && !foundSet.Equal(operands) {
874+
return []error{fmt.Errorf("authentication ClusterOperator status expected to have operands %v in versions but got %v", operands.UnsortedList(), foundOperands)}
875+
}
876+
877+
return nil
878+
}
879+
852880
func (tc *testClient) testOIDCAuthentication(t *testing.T, ctx context.Context, kcClient *test.KeycloakClient, usernameClaim, usernamePrefix string, expectAuthSuccess bool) {
853881
// re-authenticate to ensure we always have a fresh token
854882
var err error

0 commit comments

Comments
 (0)