Skip to content

Commit 8647e52

Browse files
committed
test/e2e-oidc: validate oauth resources missing when OIDC gets rolled out
1 parent a5a7d4c commit 8647e52

File tree

5 files changed

+210
-85
lines changed

5 files changed

+210
-85
lines changed

pkg/operator/extractors.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package operator
2+
3+
import (
4+
"fmt"
5+
6+
operatorv1 "github.com/openshift/api/operator/v1"
7+
applyoperatorv1 "github.com/openshift/client-go/operator/applyconfigurations/operator/v1"
8+
9+
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
10+
"k8s.io/apimachinery/pkg/runtime"
11+
)
12+
13+
func ExtractOperatorSpec(obj *unstructured.Unstructured, fieldManager string) (*applyoperatorv1.OperatorSpecApplyConfiguration, error) {
14+
castObj := &operatorv1.Authentication{}
15+
if err := runtime.DefaultUnstructuredConverter.FromUnstructured(obj.Object, castObj); err != nil {
16+
return nil, fmt.Errorf("unable to convert to Authentication: %w", err)
17+
}
18+
ret, err := applyoperatorv1.ExtractAuthentication(castObj, fieldManager)
19+
if err != nil {
20+
return nil, fmt.Errorf("unable to extract fields for %q: %w", fieldManager, err)
21+
}
22+
if ret.Spec == nil {
23+
return nil, nil
24+
}
25+
return &ret.Spec.OperatorSpecApplyConfiguration, nil
26+
}
27+
28+
func ExtractOperatorStatus(obj *unstructured.Unstructured, fieldManager string) (*applyoperatorv1.OperatorStatusApplyConfiguration, error) {
29+
castObj := &operatorv1.Authentication{}
30+
if err := runtime.DefaultUnstructuredConverter.FromUnstructured(obj.Object, castObj); err != nil {
31+
return nil, fmt.Errorf("unable to convert to Authentication: %w", err)
32+
}
33+
ret, err := applyoperatorv1.ExtractAuthenticationStatus(castObj, fieldManager)
34+
if err != nil {
35+
return nil, fmt.Errorf("unable to extract fields for %q: %w", fieldManager, err)
36+
}
37+
38+
if ret.Status == nil {
39+
return nil, nil
40+
}
41+
return &ret.Status.OperatorStatusApplyConfiguration, nil
42+
}

pkg/operator/replacement_starter.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ func CreateOperatorInputFromMOM(ctx context.Context, momInput libraryapplyconfig
104104
momInput.MutationTrackingClient.GetHTTPClient(),
105105
operatorv1.GroupVersion.WithResource("authentications"),
106106
operatorv1.GroupVersion.WithKind("Authentication"),
107-
extractOperatorSpec,
108-
extractOperatorStatus,
107+
ExtractOperatorSpec,
108+
ExtractOperatorStatus,
109109
)
110110
if err != nil {
111111
return nil, err
@@ -189,8 +189,8 @@ func CreateControllerInputFromControllerContext(ctx context.Context, controllerC
189189
controllerContext.KubeConfig,
190190
operatorv1.GroupVersion.WithResource("authentications"),
191191
operatorv1.GroupVersion.WithKind("Authentication"),
192-
extractOperatorSpec,
193-
extractOperatorStatus,
192+
ExtractOperatorSpec,
193+
ExtractOperatorStatus,
194194
)
195195
if err != nil {
196196
return nil, err

pkg/operator/starter.go

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
"github.com/openshift/api/features"
1515
operatorv1 "github.com/openshift/api/operator/v1"
1616
routev1 "github.com/openshift/api/route/v1"
17-
applyoperatorv1 "github.com/openshift/client-go/operator/applyconfigurations/operator/v1"
1817
"github.com/openshift/cluster-authentication-operator/bindata"
1918
"github.com/openshift/cluster-authentication-operator/pkg/controllers/common"
2019
"github.com/openshift/cluster-authentication-operator/pkg/controllers/configobservation/configobservercontroller"
@@ -60,10 +59,8 @@ import (
6059
certapiv1 "k8s.io/api/certificates/v1"
6160
"k8s.io/apimachinery/pkg/api/errors"
6261
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
63-
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
6462
"k8s.io/apimachinery/pkg/fields"
6563
"k8s.io/apimachinery/pkg/labels"
66-
"k8s.io/apimachinery/pkg/runtime"
6764
"k8s.io/apimachinery/pkg/runtime/schema"
6865
"k8s.io/apimachinery/pkg/selection"
6966
"k8s.io/apimachinery/pkg/util/sets"
@@ -827,37 +824,6 @@ func loadSystemCACertBundle() ([]byte, error) {
827824
return systemCABundle, nil
828825
}
829826

830-
func extractOperatorSpec(obj *unstructured.Unstructured, fieldManager string) (*applyoperatorv1.OperatorSpecApplyConfiguration, error) {
831-
castObj := &operatorv1.Authentication{}
832-
if err := runtime.DefaultUnstructuredConverter.FromUnstructured(obj.Object, castObj); err != nil {
833-
return nil, fmt.Errorf("unable to convert to Authentication: %w", err)
834-
}
835-
ret, err := applyoperatorv1.ExtractAuthentication(castObj, fieldManager)
836-
if err != nil {
837-
return nil, fmt.Errorf("unable to extract fields for %q: %w", fieldManager, err)
838-
}
839-
if ret.Spec == nil {
840-
return nil, nil
841-
}
842-
return &ret.Spec.OperatorSpecApplyConfiguration, nil
843-
}
844-
845-
func extractOperatorStatus(obj *unstructured.Unstructured, fieldManager string) (*applyoperatorv1.OperatorStatusApplyConfiguration, error) {
846-
castObj := &operatorv1.Authentication{}
847-
if err := runtime.DefaultUnstructuredConverter.FromUnstructured(obj.Object, castObj); err != nil {
848-
return nil, fmt.Errorf("unable to convert to Authentication: %w", err)
849-
}
850-
ret, err := applyoperatorv1.ExtractAuthenticationStatus(castObj, fieldManager)
851-
if err != nil {
852-
return nil, fmt.Errorf("unable to extract fields for %q: %w", fieldManager, err)
853-
}
854-
855-
if ret.Status == nil {
856-
return nil, nil
857-
}
858-
return &ret.Status.OperatorStatusApplyConfiguration, nil
859-
}
860-
861827
func oidcAvailable(authConfigChecker common.AuthConfigChecker) bool {
862828
oidcAvailable, err := authConfigChecker.OIDCAvailable()
863829
if err != nil {

0 commit comments

Comments
 (0)