2021-12-28 01:28:10 +00:00
|
|
|
package http_test
|
|
|
|
|
|
|
|
import (
|
2023-01-14 21:27:37 +00:00
|
|
|
"net/http"
|
|
|
|
"net/http/httptest"
|
2021-12-28 01:28:10 +00:00
|
|
|
"testing"
|
|
|
|
|
2022-03-13 10:58:34 +00:00
|
|
|
"source.toby3d.me/toby3d/auth/internal/domain"
|
|
|
|
delivery "source.toby3d.me/toby3d/auth/internal/metadata/delivery/http"
|
2024-05-08 11:44:10 +00:00
|
|
|
testutil "source.toby3d.me/toby3d/auth/internal/util/testing"
|
2021-12-28 01:28:10 +00:00
|
|
|
)
|
|
|
|
|
2024-05-08 11:44:10 +00:00
|
|
|
func TestHandler_ServeHTTP(t *testing.T) {
|
2021-12-28 01:28:10 +00:00
|
|
|
t.Parallel()
|
|
|
|
|
2022-02-15 20:07:39 +00:00
|
|
|
metadata := domain.TestMetadata(t)
|
2023-01-14 21:27:37 +00:00
|
|
|
req := httptest.NewRequest(http.MethodGet, "https://example.com/.well-known/oauth-authorization-server", nil)
|
|
|
|
w := httptest.NewRecorder()
|
2024-05-08 11:44:10 +00:00
|
|
|
|
|
|
|
delivery.NewHandler(metadata).ServeHTTP(w, req)
|
2022-02-01 18:26:55 +00:00
|
|
|
|
2023-01-14 21:27:37 +00:00
|
|
|
resp := w.Result()
|
2022-02-01 18:26:55 +00:00
|
|
|
|
2023-01-14 21:27:37 +00:00
|
|
|
if resp.StatusCode != http.StatusOK {
|
|
|
|
t.Errorf("%s %s = %d, want %d", req.Method, req.RequestURI, resp.StatusCode, http.StatusOK)
|
2022-02-01 18:26:55 +00:00
|
|
|
}
|
2021-12-28 01:28:10 +00:00
|
|
|
|
2024-05-08 11:44:10 +00:00
|
|
|
testutil.GoldenEqual(t, resp.Body)
|
2021-12-28 01:28:10 +00:00
|
|
|
}
|