Files
zeekayandHanzo Dev b1cc108c9f gofmt
Co-authored-by: Hanzo Dev <[email protected]>
2026-09-08 01:51:51 -07:00

46 lines
1.1 KiB
Go

// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package server
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/stretchr/testify/require"
"github.com/luxfi/ids"
"github.com/luxfi/log"
"github.com/luxfi/runtime"
)
func TestRejectMiddleware(t *testing.T) {
require := require.New(t)
// Create test handler
testHandler := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusTeapot)
})
// Create a Runtime
rt := &runtime.Runtime{
NetworkID: 1,
ChainID: ids.Empty,
NodeID: ids.EmptyNodeID,
Log: log.NoLog{},
}
// rejectMiddleware passes the handler through, so the wrapped handler's own
// status is what reaches the recorder.
middleware := rejectMiddleware(testHandler, rt)
w := httptest.NewRecorder()
middleware.ServeHTTP(w, httptest.NewRequest(http.MethodGet, "/", nil))
require.Equal(http.StatusTeapot, w.Code)
}
func TestHTTPHeaderRouteIsCanonical(t *testing.T) {
wantHeaderKey := http.CanonicalHeaderKey(HTTPHeaderRoute)
require.Equal(t, wantHeaderKey, HTTPHeaderRoute)
}