Files
netbird/proxy/internal/middleware/headerpolicy_test.go
Daneyon Hansen 7a9582db16 [management,proxy] Add agentgateway integration (#7274)
* [management] Add agentgateway provider catalog entry

Allow Agent Network providers to target an operator-supplied agentgateway proxy while stamping trusted NetBird identity headers.

Signed-off-by: Daneyon Hansen <daneyon.hansen@solo.io>

* [proxy] Allow trusted Agent Network identity headers

Permit only the built-in identity injector to replace the two reserved agentgateway attribution headers while keeping them blocked for every other middleware.

Signed-off-by: Daneyon Hansen <daneyon.hansen@solo.io>

* [management,proxy] Add multi-vendor gateway routing

Let one Agent Network route declare multiple parser surfaces while preserving the existing singular vendor wire field.

Signed-off-by: Daneyon Hansen <daneyon.hansen@solo.io>

* [management] Update router test for model policies

Signed-off-by: Daneyon Hansen <daneyon.hansen@solo.io>

* [proxy] Cover reserved header policy

Signed-off-by: Daneyon Hansen <daneyon.hansen@solo.io>

* [management] Add agentgateway model discovery

Use agentgateway's OpenAI-compatible models endpoint and omit wildcard patterns until NetBird can authorize and price them consistently.

Signed-off-by: Daneyon Hansen <daneyon.hansen@solo.io>

---------

Signed-off-by: Daneyon Hansen <daneyon.hansen@solo.io>
2026-09-01 13:03:16 +02:00

27 lines
863 B
Go

package middleware
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestFilterHeaderMutationsDoesNotTrustReservedHeaders(t *testing.T) {
mutations := &Mutations{
HeadersAdd: []KV{
{Key: "x-request-label", Value: "allowed"},
{Key: "x-netbird-user-id", Value: "spoofed-user"},
},
HeadersRemove: []string{"x-request-label", "x-netbird-groups"},
}
filteredAdd, filteredRemove, blocked := FilterHeaderMutations(mutations)
assert.Equal(t, []KV{{Key: "x-request-label", Value: "allowed"}}, filteredAdd,
"the public filter should retain mutable additions")
assert.Equal(t, []string{"x-request-label"}, filteredRemove,
"the public filter should retain mutable removals")
assert.ElementsMatch(t, []string{"x-netbird-user-id", "x-netbird-groups"}, blocked,
"the public filter must not grant the identity middleware exception")
}