Gitea host renamed (infra ADR-0004); the mcp-chassis dep already migrated
(3329ff3), so the sequencing gate is clear. `go mod edit -module` + bulk import
rewrite across all .go files. gitea-mcp is a server binary (not an imported
library), so no downstream consumers break. build + task check green.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
29 lines
700 B
Go
29 lines
700 B
Go
package auth_test
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"testing"
|
|
|
|
"git.d-ma.be/mathias/gitea-mcp/internal/auth"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestCallerFromContext(t *testing.T) {
|
|
called := false
|
|
h := auth.CallerMiddleware(http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) {
|
|
called = true
|
|
assert.Equal(t, "mathiasbq", auth.Caller(r.Context()))
|
|
}))
|
|
req := httptest.NewRequest(http.MethodPost, "/", nil)
|
|
req.Header.Set("X-Auth-Request-User", "mathiasbq")
|
|
rr := httptest.NewRecorder()
|
|
h.ServeHTTP(rr, req)
|
|
assert.True(t, called)
|
|
}
|
|
|
|
func TestCallerEmptyWhenHeaderMissing(t *testing.T) {
|
|
assert.Equal(t, "", auth.Caller(context.Background()))
|
|
}
|