Files
zeekay d9f769ad80 feat: add native staticFiles middleware + fix rebrand test breakage
Native staticFiles middleware (compiled-in, not plugin):
- pkg/config/dynamic/middlewares.go: StaticFiles config type
- pkg/middlewares/staticfiles/: full implementation (SPA, dir listing,
  cache-control, custom 404, index files)
- pkg/server/middleware/middlewares.go: wired into builder chain
- pkg/config/dynamic/zz_generated.deepcopy.go: DeepCopy methods

Fix all pre-existing test failures from traefik→ingress rebrand:
- builtins: entrypoint name traefik→ingress in JSON fixtures
- cookie: hash expectations updated for _INGRESS_BACKEND_ salt
- nomad: canary service hash expectations updated
- k8s ingress: remove duplicate map keys, fix ingressClass annotation
- k8s gateway: annotation prefix traefik.io→hanzo.ai, add missing
  IngressService fixture
- k8s ingress-nginx: add CurvePreferences to TLS test fixtures
- auth: fix realm defaults and response body assertions

68 packages tested, 0 failures.
2026-03-18 23:47:06 -07:00

91 lines
1.7 KiB
Go

package gateway
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"k8s.io/utils/ptr"
)
func Test_parseServiceConfig(t *testing.T) {
testCases := []struct {
desc string
annotations map[string]string
expected ServiceConfig
}{
{
desc: "service annotations",
annotations: map[string]string{
"ingress.kubernetes.io/foo": "bar",
"hanzo.ai/foo": "bar",
"hanzo.ai/service.nativelb": "true",
},
expected: ServiceConfig{
Service: Service{
NativeLB: ptr.To(true),
},
},
},
{
desc: "empty map",
annotations: map[string]string{},
expected: ServiceConfig{},
},
{
desc: "nil map",
annotations: nil,
expected: ServiceConfig{},
},
}
for _, test := range testCases {
t.Run(test.desc, func(t *testing.T) {
t.Parallel()
cfg, err := parseServiceAnnotations(test.annotations)
require.NoError(t, err)
assert.Equal(t, test.expected, cfg)
})
}
}
func Test_convertAnnotations(t *testing.T) {
testCases := []struct {
desc string
annotations map[string]string
expected map[string]string
}{
{
desc: "service annotations",
annotations: map[string]string{
"hanzo.ai/service.nativelb": "true",
},
expected: map[string]string{
"ingress.service.nativelb": "true",
},
},
{
desc: "empty map",
annotations: map[string]string{},
expected: nil,
},
{
desc: "nil map",
annotations: nil,
expected: nil,
},
}
for _, test := range testCases {
t.Run(test.desc, func(t *testing.T) {
t.Parallel()
labels := convertAnnotations(test.annotations)
assert.Equal(t, test.expected, labels)
})
}
}