Aligns module path with canonical Gitea source (infra ADR-0004) and repo name. Binary only, no downstream consumers. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Roq1ajWKR5f1hG5Df9wC6A
29 lines
856 B
Go
29 lines
856 B
Go
package auth_test
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"testing"
|
|
|
|
"git.d-ma.be/mathias/hyperguild/internal/auth"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestProtectedResourceHandler(t *testing.T) {
|
|
h := auth.ProtectedResourceHandler("https://brain-mcp.d-ma.be", "https://auth.d-ma.be")
|
|
req := httptest.NewRequest(http.MethodGet, "/.well-known/oauth-protected-resource", nil)
|
|
rr := httptest.NewRecorder()
|
|
h(rr, req)
|
|
|
|
assert.Equal(t, http.StatusOK, rr.Code)
|
|
assert.Equal(t, "application/json", rr.Header().Get("Content-Type"))
|
|
|
|
var body map[string]any
|
|
require.NoError(t, json.Unmarshal(rr.Body.Bytes(), &body))
|
|
assert.Equal(t, "https://brain-mcp.d-ma.be", body["resource"])
|
|
servers := body["authorization_servers"].([]any)
|
|
assert.Equal(t, "https://auth.d-ma.be", servers[0])
|
|
}
|