Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions manifests/08_clusteroperator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,3 @@ status:
versions:
- name: operator
version: "0.0.1-snapshot"
- name: oauth-openshift
version: "0.0.1-snapshot_openshift"
5 changes: 5 additions & 0 deletions pkg/operator/starter.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,11 @@ func prepareOauthAPIServerOperator(
statusControllerOptions = append(statusControllerOptions, apiservercontrollerset.WithStatusControllerPdbCompatibleHighInertia("(APIServer|OAuthServer)"))
}

// configure version removal so it removes versions it doesn't know about.
statusControllerOptions = append(statusControllerOptions, func(ss *status.StatusSyncer) *status.StatusSyncer {
return ss.WithVersionRemoval()
})

const apiServerConditionsPrefix = "APIServer"

apiServerControllers, err := apiservercontrollerset.NewAPIServerControllerSet(
Expand Down
28 changes: 28 additions & 0 deletions test/e2e-oidc/external_oidc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,7 @@ func (tc *testClient) validateOAuthState(t *testing.T, ctx context.Context, requ
validationErrs = append(validationErrs, validateOAuthResources(ctx, dynamicClient, requireMissing)...)
validationErrs = append(validationErrs, validateOAuthRoutes(ctx, tc.routeClient, tc.configClient, requireMissing)...)
validationErrs = append(validationErrs, validateOAuthControllerConditions(tc.operatorClient, requireMissing)...)
validationErrs = append(validationErrs, validateOperandVersions(ctx, tc.configClient, requireMissing)...)
return len(validationErrs) == 0, nil
})

Expand Down Expand Up @@ -849,6 +850,33 @@ func validateOAuthControllerConditions(operatorClient v1helpers.OperatorClient,
return nil
}

func validateOperandVersions(ctx context.Context, cfgClient *configclient.Clientset, requireMissing bool) []error {
operands := sets.New("oauth-apiserver", "oauth-openshift")

authnClusterOperator, err := cfgClient.ConfigV1().ClusterOperators().Get(ctx, "authentication", metav1.GetOptions{})
if err != nil {
return []error{fmt.Errorf("fetching authentication ClusterOperator: %w", err)}
}

foundOperands := []string{}
for _, version := range authnClusterOperator.Status.Versions {
if operands.Has(version.Name) {
foundOperands = append(foundOperands, version.Name)
}
}

if requireMissing && len(foundOperands) > 0 {
return []error{fmt.Errorf("authentication ClusterOperator status has operands %v in versions when they should be unset", foundOperands)}
}

foundSet := sets.New(foundOperands...)
if !requireMissing && !foundSet.Equal(operands) {
return []error{fmt.Errorf("authentication ClusterOperator status expected to have operands %v in versions but got %v", operands.UnsortedList(), foundOperands)}
}

return nil
}

func (tc *testClient) testOIDCAuthentication(t *testing.T, ctx context.Context, kcClient *test.KeycloakClient, usernameClaim, usernamePrefix string, expectAuthSuccess bool) {
// re-authenticate to ensure we always have a fresh token
var err error
Expand Down