@@ -34,7 +34,7 @@ func TestHandleHealth(t *testing.T) {
3434 }
3535}
3636
37- func TestHandleDiscovery (t * testing.T ) {
37+ func TestHandleDiscoveryOIDC (t * testing.T ) {
3838 httpServer , server := newTestServer (t , nil )
3939 defer httpServer .Close ()
4040
@@ -44,10 +44,10 @@ func TestHandleDiscovery(t *testing.T) {
4444 t .Errorf ("expected 200 got %d" , rr .Code )
4545 }
4646
47- var res discovery
47+ var res discoveryOIDC
4848 err := json .NewDecoder (rr .Result ().Body ).Decode (& res )
4949 require .NoError (t , err )
50- require .Equal (t , discovery {
50+ require .Equal (t , discoveryOIDC {
5151 Issuer : httpServer .URL ,
5252 Auth : fmt .Sprintf ("%s/auth" , httpServer .URL ),
5353 Token : fmt .Sprintf ("%s/token" , httpServer .URL ),
@@ -101,6 +101,51 @@ func TestHandleDiscovery(t *testing.T) {
101101 }, res )
102102}
103103
104+ func TestHandleDiscoveryOAuth2 (t * testing.T ) {
105+ httpServer , server := newTestServer (t , nil )
106+ defer httpServer .Close ()
107+
108+ rr := httptest .NewRecorder ()
109+ server .ServeHTTP (rr , httptest .NewRequest ("GET" , "/.well-known/oauth-authorization-server" , nil ))
110+
111+ if rr .Code != http .StatusOK {
112+ t .Errorf ("expected 200 got %d" , rr .Code )
113+ }
114+
115+ var res discoveryOAuth2
116+ err := json .NewDecoder (rr .Result ().Body ).Decode (& res )
117+ require .NoError (t , err )
118+
119+ require .Equal (t , discoveryOAuth2 {
120+ Issuer : httpServer .URL ,
121+ Auth : fmt .Sprintf ("%s/auth" , httpServer .URL ),
122+ Token : fmt .Sprintf ("%s/token" , httpServer .URL ),
123+ Keys : fmt .Sprintf ("%s/keys" , httpServer .URL ),
124+ DeviceEndpoint : fmt .Sprintf ("%s/device/code" , httpServer .URL ),
125+ Introspect : fmt .Sprintf ("%s/token/introspect" , httpServer .URL ),
126+ GrantTypes : []string {
127+ "authorization_code" ,
128+ "refresh_token" ,
129+ "urn:ietf:params:oauth:grant-type:device_code" ,
130+ "urn:ietf:params:oauth:grant-type:token-exchange" ,
131+ },
132+ ResponseTypes : []string {
133+ "code" ,
134+ },
135+ CodeChallengeAlgs : []string {
136+ "S256" ,
137+ "plain" ,
138+ },
139+ Scopes : []string {
140+ "offline_access" ,
141+ },
142+ AuthMethods : []string {
143+ "client_secret_basic" ,
144+ "client_secret_post" ,
145+ },
146+ }, res )
147+ }
148+
104149func TestHandleHealthFailure (t * testing.T ) {
105150 httpServer , server := newTestServer (t , func (c * Config ) {
106151 c .HealthChecker = gosundheit .New ()
0 commit comments