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
20 changes: 12 additions & 8 deletions test/integration/controller/rbacpolicy_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
package controller_test

import (
"bytes"
"context"
"fmt"
"io"
"net/http"
"os"
"path/filepath"
Expand All @@ -37,13 +38,16 @@ import (
"github.com/ontai-dev/guardian/internal/controller"
)

// failFastHTTPClient returns an error immediately for all requests.
// Injected into IdentityProviderReconciler so the OIDC reachability check
// (which has a 10s timeout) does not race against the test poll timeout.
type failFastHTTPClient struct{}
// alwaysReachableHTTPDoer is a test-double HTTPDoer that immediately returns
// HTTP 200 OK for any request. Injected into IdentityProviderReconciler in the
// envtest manager to prevent real network calls during integration tests.
type alwaysReachableHTTPDoer struct{}

func (f *failFastHTTPClient) Do(_ *http.Request) (*http.Response, error) {
return nil, fmt.Errorf("unreachable: no OIDC server in test environment")
func (alwaysReachableHTTPDoer) Do(*http.Request) (*http.Response, error) {
return &http.Response{
StatusCode: http.StatusOK,
Body: io.NopCloser(bytes.NewReader([]byte(`{}`))),
}, nil
}

var (
Expand Down Expand Up @@ -112,7 +116,7 @@ func TestMain(m *testing.M) {
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
Recorder: mgr.GetEventRecorder("identityprovider-controller"),
HTTPClient: &failFastHTTPClient{},
HTTPClient: alwaysReachableHTTPDoer{},
}).SetupWithManager(mgr); err != nil {
panic("failed to register IdentityProviderReconciler: " + err.Error())
}
Expand Down
2 changes: 1 addition & 1 deletion test/integration/lineage/lineage_immutability_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func waitForLineageWebhookActive() {
},
Spec: securityv1alpha1.PermissionSetSpec{
Permissions: []securityv1alpha1.PermissionRule{
{Resources: []string{"pods"}, Verbs: []securityv1alpha1.Verb{"get"}},
{APIGroups: []string{""}, Resources: []string{"pods"}, Verbs: []securityv1alpha1.Verb{"get"}},
},
Lineage: &seamcorev1alpha1lineage.SealedCausalChain{
RootKind: "TestRoot",
Expand Down
Loading