30 lines
741 B
Go
30 lines
741 B
Go
package http_test
|
|
|
|
import (
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"testing"
|
|
|
|
"source.toby3d.me/toby3d/auth/internal/domain"
|
|
delivery "source.toby3d.me/toby3d/auth/internal/metadata/delivery/http"
|
|
testutil "source.toby3d.me/toby3d/auth/internal/util/testing"
|
|
)
|
|
|
|
func TestHandler_ServeHTTP(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
metadata := domain.TestMetadata(t)
|
|
req := httptest.NewRequest(http.MethodGet, "https://example.com/.well-known/oauth-authorization-server", nil)
|
|
w := httptest.NewRecorder()
|
|
|
|
delivery.NewHandler(metadata).ServeHTTP(w, req)
|
|
|
|
resp := w.Result()
|
|
|
|
if resp.StatusCode != http.StatusOK {
|
|
t.Errorf("%s %s = %d, want %d", req.Method, req.RequestURI, resp.StatusCode, http.StatusOK)
|
|
}
|
|
|
|
testutil.GoldenEqual(t, resp.Body)
|
|
}
|