Skip to content
Merged
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: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/openshift/api v0.0.0-20230424202542-f7a9b7696bc2
github.com/openshift/build-machinery-go v0.0.0-20230228230858-4cd708338479
github.com/openshift/client-go v0.0.0-20230120202327-72f107311084
github.com/openshift/library-go v0.0.0-20230425132011-00923e044766
github.com/openshift/library-go v0.0.0-20230425205800-ab66adbd0bb5
github.com/pkg/profile v1.5.0 // indirect
github.com/prometheus-operator/prometheus-operator/pkg/client v0.45.0
github.com/prometheus/client_golang v1.14.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,8 @@ github.com/openshift/build-machinery-go v0.0.0-20230228230858-4cd708338479 h1:IU
github.com/openshift/build-machinery-go v0.0.0-20230228230858-4cd708338479/go.mod h1:b1BuldmJlbA/xYtdZvKi+7j5YGB44qJUJDZ9zwiNCfE=
github.com/openshift/client-go v0.0.0-20230120202327-72f107311084 h1:66uaqNwA+qYyQDwsMWUfjjau8ezmg1dzCqub13KZOcE=
github.com/openshift/client-go v0.0.0-20230120202327-72f107311084/go.mod h1:M3h9m001PWac3eAudGG3isUud6yBjr5XpzLYLLTlHKo=
github.com/openshift/library-go v0.0.0-20230425132011-00923e044766 h1:pENkmo53xgk2+QsTdoClC50Vnb92wJ4rq+LWiNgujX4=
github.com/openshift/library-go v0.0.0-20230425132011-00923e044766/go.mod h1:tUWJLc0m8/1GyMKXFKZMWWfaGtFhX1T6kdcGtiGtZIE=
github.com/openshift/library-go v0.0.0-20230425205800-ab66adbd0bb5 h1:U+Cdda576x6c0s9PlTFf+JXSHUkPjg1u3Smb/piRTyc=
github.com/openshift/library-go v0.0.0-20230425205800-ab66adbd0bb5/go.mod h1:tUWJLc0m8/1GyMKXFKZMWWfaGtFhX1T6kdcGtiGtZIE=
github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU=
Expand Down
49 changes: 25 additions & 24 deletions pkg/operator/configobservation/auth/podsecurityadmission_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package auth

import (
"encoding/json"
"github.com/openshift/library-go/pkg/operator/configobserver/featuregates"
"errors"
"strings"
"testing"

Expand All @@ -12,6 +12,7 @@ import (
"github.com/stretchr/testify/require"

configv1 "github.com/openshift/api/config/v1"
"github.com/openshift/library-go/pkg/operator/configobserver/featuregates"
"github.com/openshift/library-go/pkg/operator/events"
)

Expand All @@ -28,15 +29,7 @@ func TestObservePodSecurityAdmissionEnforcement(t *testing.T) {

defaultFeatureSet := featuregates.NewHardcodedFeatureGateAccess([]configv1.FeatureGateName{}, []configv1.FeatureGateName{})

// TODO provide a hardcoded test harness that allows not-ready and error
//corruptFeatureSet := &configv1.FeatureGate{
// Spec: configv1.FeatureGateSpec{
// FeatureGateSelection: configv1.FeatureGateSelection{
// FeatureSet: "Bad",
// CustomNoUpgrade: nil,
// },
// },
//}
const sentinelExistingJSON = `{"admission":{"pluginConfig":{"PodSecurity":{"configuration":{"defaults":{"foo":"bar"}}}}}}`

disabledFeatureSet := featuregates.NewHardcodedFeatureGateAccess([]configv1.FeatureGateName{}, []configv1.FeatureGateName{"OpenShiftPodSecurityAdmission"})

Expand All @@ -54,27 +47,35 @@ func TestObservePodSecurityAdmissionEnforcement(t *testing.T) {
expectedErr: "",
expectedJSON: string(restrictedJSON),
},
//{
// name: "corrupt-1",
// existingJSON: string(privilegedJSON),
// featureGateAccessor: corruptFeatureSet,
// expectedErr: "not found",
// expectedJSON: string(privilegedJSON),
//},
//{
// name: "corrupt-2",
// existingJSON: string(restrictedJSON),
// featureGateAccessor: corruptFeatureSet,
// expectedErr: "not found",
// expectedJSON: string(restrictedJSON),
//},
{
name: "disabled",
existingJSON: string(restrictedJSON),
featureGateAccessor: disabledFeatureSet,
expectedErr: "",
expectedJSON: string(privilegedJSON),
},
{
name: "initial feature gates not observed",
existingJSON: sentinelExistingJSON,
featureGateAccessor: featuregates.NewHardcodedFeatureGateAccessForTesting(nil, nil, make(chan struct{}), nil),
expectedJSON: sentinelExistingJSON,
},
{
name: "error reading current feature gates",
existingJSON: sentinelExistingJSON,
featureGateAccessor: featuregates.NewHardcodedFeatureGateAccessForTesting(
nil,
nil,
func() chan struct{} {
c := make(chan struct{})
close(c)
return c
}(),
errors.New("test error"),
),
expectedJSON: sentinelExistingJSON,
expectedErr: "test error",
},
} {
t.Run(tc.name, func(t *testing.T) {
testRecorder := events.NewInMemoryRecorder("SAIssuerTest")
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ github.com/openshift/client-go/operatorcontrolplane/informers/externalversions/i
github.com/openshift/client-go/operatorcontrolplane/informers/externalversions/operatorcontrolplane
github.com/openshift/client-go/operatorcontrolplane/informers/externalversions/operatorcontrolplane/v1alpha1
github.com/openshift/client-go/operatorcontrolplane/listers/operatorcontrolplane/v1alpha1
# github.com/openshift/library-go v0.0.0-20230425132011-00923e044766
# github.com/openshift/library-go v0.0.0-20230425205800-ab66adbd0bb5
## explicit; go 1.19
github.com/openshift/library-go/pkg/assets
github.com/openshift/library-go/pkg/authorization/hardcodedauthorizer
Expand Down