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 internal/proxy/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ func TestCopyResponseHeaders(t *testing.T) {
t.Run("copies pagination and request ID headers", func(t *testing.T) {
w := httptest.NewRecorder()
resp := &http.Response{Header: http.Header{
"Link": []string{`<https://api.github.com/repos/o/r/issues?page=2>; rel="next"`},
"Link": []string{`<https://api.github.com/repos/o/r/issues?page=2>; rel="next"`},
"X-Github-Request-Id": []string{"abc-123"},
}}
copyResponseHeaders(w, resp)
Expand Down
15 changes: 9 additions & 6 deletions internal/server/register_guard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,20 +250,23 @@ func TestRegisterGuard_WriteSinkPolicy_MultipleAcceptPatterns(t *testing.T) {

// TestRegisterGuard_InvalidPolicy_ReturnsError verifies that when resolveGuardPolicy
// returns an error (invalid AllowOnly policy), registerGuard propagates the error.
// NOTE: The guard must be non-noop because requireGuardPolicyIfGuardEnabled
// short-circuits for noop guards without validating the policy (by design).
func TestRegisterGuard_InvalidPolicy_ReturnsError(t *testing.T) {
t.Setenv(wasmGuardsDirEnvVar, "")

// Register a non-noop guard type so the policy validation path is reached.
const guardType = "test-non-noop-for-invalid-policy"
guard.RegisterGuardType(guardType, func() (guard.Guard, error) {
return guard.NewWriteSinkGuard([]string{"*"}), nil
})

cfg := &config.Config{
Servers: map[string]*config.ServerConfig{
"github": {Type: "http", Guard: "my-guard"},
},
Guards: map[string]*config.GuardConfig{
"my-guard": {
Type: "noop",
// This is a valid guard config – but we'll use the *global* policy
// override to inject an invalid policy so that requireGuardPolicyIfGuardEnabled
// receives the guard and then resolveGuardPolicy validates and errors.
},
"my-guard": {Type: guardType},
},
// Invalid global policy: min-integrity value is not recognised
GuardPolicy: &config.GuardPolicy{
Expand Down
Loading