✅ Refactored metadata HTTP delivery test
This commit is contained in:
parent
d789bfd1c7
commit
48c5423ae1
|
@ -1,25 +1,23 @@
|
|||
package http_test
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"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 TestMetadata(t *testing.T) {
|
||||
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)
|
||||
|
||||
delivery.NewHandler(metadata).ServeHTTP(w, req)
|
||||
|
||||
resp := w.Result()
|
||||
|
||||
|
@ -27,8 +25,5 @@ func TestMetadata(t *testing.T) {
|
|||
t.Errorf("%s %s = %d, want %d", req.Method, req.RequestURI, resp.StatusCode, http.StatusOK)
|
||||
}
|
||||
|
||||
out := new(delivery.MetadataResponse)
|
||||
if err := json.NewDecoder(resp.Body).Decode(out); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
testutil.GoldenEqual(t, resp.Body)
|
||||
}
|
||||
|
|
1
internal/metadata/delivery/http/testdata/TestHandler_ServeHTTP.golden
vendored
Executable file
1
internal/metadata/delivery/http/testdata/TestHandler_ServeHTTP.golden
vendored
Executable file
|
@ -0,0 +1 @@
|
|||
{"service_documentation":"https://indieauth.net/draft/","authorization_endpoint":"https://indieauth.example.com/auth","token_endpoint":"https://indieauth.example.com/token","introspection_endpoint":"https://indieauth.example.com/introspect","userinfo_endpoint":"https://indieauth.example.com/userinfo","revocation_endpoint":"https://indieauth.example.com/revocation","issuer":"https://example.com/.well-known/oauth-authorization-server","revocation_endpoint_auth_methods_supported":["none"],"response_types_supported":["code","id"],"grant_types_supported":["authorization_code","ticket"],"scopes_supported":["block","channels","create","delete","draft","email","follow","media","mute","profile","read","update"],"code_challenge_methods_supported":["MD5","PLAIN","S1","S256","S512"],"introspection_endpoint_auth_methods_supported":["Bearer"],"authorization_response_iss_parameter_supported":true}
|
Loading…
Reference in New Issue
Block a user