Skip to content

Commit 801fd0b

Browse files
committed
Expand test coverage of disco response
1 parent 1bd7801 commit 801fd0b

File tree

2 files changed

+93
-2
lines changed

2 files changed

+93
-2
lines changed

identity-model/test/IdentityModel.Tests/HttpClientExtensions/DiscoveryExtensionsTests.cs

Lines changed: 89 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,27 +214,114 @@ public async Task Strongly_typed_accessors_should_behave_as_expected()
214214

215215
disco.IsError.ShouldBeFalse();
216216

217+
// Endpoints
218+
disco.Issuer.ShouldBe("https://demo.identityserver.io");
219+
disco.JwksUri.ShouldBe("https://demo.identityserver.io/.well-known/jwks");
217220
disco.TokenEndpoint.ShouldBe("https://demo.identityserver.io/connect/token");
218221
disco.AuthorizeEndpoint.ShouldBe("https://demo.identityserver.io/connect/authorize");
219222
disco.UserInfoEndpoint.ShouldBe("https://demo.identityserver.io/connect/userinfo");
223+
disco.IntrospectionEndpoint.ShouldBe("https://demo.identityserver.io/connect/introspect");
224+
disco.RevocationEndpoint.ShouldBe("https://demo.identityserver.io/connect/revocation");
225+
disco.DeviceAuthorizationEndpoint.ShouldBe("https://demo.identityserver.io/connect/deviceauthorization");
226+
disco.BackchannelAuthenticationEndpoint.ShouldBe("https://demo.identityserver.io/connect/ciba");
220227
disco.PushedAuthorizationRequestEndpoint.ShouldBe("https://demo.identityserver.io/connect/par");
228+
disco.EndSessionEndpoint.ShouldBe("https://demo.identityserver.io/connect/endsession");
229+
disco.RegistrationEndpoint.ShouldBe("https://demo.identityserver.io/connect/dcr");
230+
disco.CheckSessionIframe.ShouldBe("https://demo.identityserver.io/connect/checksession");
221231

222232
disco.FrontChannelLogoutSupported.ShouldBe(true);
223233
disco.FrontChannelLogoutSessionSupported.ShouldBe(true);
234+
disco.RequirePushedAuthorizationRequests.ShouldBe(true);
224235

236+
// Response Modes
225237
var responseModes = disco.ResponseModesSupported.ToList();
226-
238+
responseModes.Count.ShouldBe(3);
227239
responseModes.ShouldContain("form_post");
228240
responseModes.ShouldContain("query");
229241
responseModes.ShouldContain("fragment");
230242

243+
// Grant Types
244+
var grantTypes = disco.GrantTypesSupported.ToList();
245+
grantTypes.Count.ShouldBe(5);
246+
grantTypes.ShouldContain("authorization_code");
247+
grantTypes.ShouldContain("client_credentials");
248+
grantTypes.ShouldContain("password");
249+
grantTypes.ShouldContain("refresh_token");
250+
grantTypes.ShouldContain("implicit");
251+
252+
// Response Types
253+
var responseTypes = disco.ResponseTypesSupported.ToList();
254+
responseTypes.Count.ShouldBe(7);
255+
responseTypes.ShouldContain("code");
256+
responseTypes.ShouldContain("token");
257+
responseTypes.ShouldContain("id_token");
258+
responseTypes.ShouldContain("id_token token");
259+
responseTypes.ShouldContain("code id_token");
260+
responseTypes.ShouldContain("code token");
261+
responseTypes.ShouldContain("code id_token token");
262+
263+
// Subject Types
264+
var subjectTypes = disco.SubjectTypesSupported.ToList();
265+
subjectTypes.Count.ShouldBe(1);
266+
subjectTypes.ShouldContain("public");
267+
268+
// PKCE Methods
269+
var codeChallengeMethodsSupported = disco.CodeChallengeMethodsSupported.ToList();
270+
codeChallengeMethodsSupported.Count.ShouldBe(2);
271+
codeChallengeMethodsSupported.ShouldContain("plain");
272+
codeChallengeMethodsSupported.ShouldContain("S256");
273+
274+
// Scopes
275+
var scopes = disco.ScopesSupported.ToList();
276+
scopes.Count.ShouldBe(7);
277+
scopes.ShouldContain("openid");
278+
scopes.ShouldContain("profile");
279+
scopes.ShouldContain("email");
280+
scopes.ShouldContain("address");
281+
scopes.ShouldContain("phone");
282+
scopes.ShouldContain("offline_access");
283+
scopes.ShouldContain("api");
284+
285+
// Claims
286+
var claims = disco.ClaimsSupported.ToList();
287+
claims.Count.ShouldBe(20);
288+
claims.ShouldContain("sub");
289+
claims.ShouldContain("name");
290+
claims.ShouldContain("family_name");
291+
claims.ShouldContain("given_name");
292+
claims.ShouldContain("middle_name");
293+
claims.ShouldContain("nickname");
294+
claims.ShouldContain("preferred_username");
295+
claims.ShouldContain("profile");
296+
claims.ShouldContain("picture");
297+
claims.ShouldContain("website");
298+
claims.ShouldContain("gender");
299+
claims.ShouldContain("birthdate");
300+
claims.ShouldContain("zoneinfo");
301+
claims.ShouldContain("locale");
302+
claims.ShouldContain("updated_at");
303+
claims.ShouldContain("email");
304+
claims.ShouldContain("email_verified");
305+
claims.ShouldContain("address");
306+
claims.ShouldContain("phone_number");
307+
claims.ShouldContain("phone_number_verified");
308+
309+
// JWKS data
231310
disco.KeySet.Keys.Count.ShouldBe(1);
232311
disco.KeySet.Keys.First().Kid.ShouldBe("a3rMUgMFv9tPclLa6yF3zAkfquE");
233312

313+
// mTLS endpoint aliases
234314
disco.MtlsEndpointAliases.ShouldNotBeNull();
235315
disco.MtlsEndpointAliases.TokenEndpoint.ShouldBeNull();
236316

237-
disco.RequirePushedAuthorizationRequests!.Value.ShouldBeTrue();
317+
// These collections aren't in the test discovery.json so they should be empty enumerations
318+
disco.BackchannelTokenDeliveryModesSupported.ShouldBeEmpty();
319+
disco.IntrospectionSigningAlgorithmsSupported.ShouldBeEmpty();
320+
disco.IntrospectionEncryptionAlgorithmsSupported.ShouldBeEmpty();
321+
disco.IntrospectionEncryptionEncValuesSupported.ShouldBeEmpty();
322+
323+
// These flags aren't in the test discovery.json, so they should be null
324+
disco.BackchannelUserCodeParameterSupported.ShouldBeNull();
238325
}
239326

240327
[Fact]

identity-model/test/IdentityModel.Tests/documents/discovery.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@
55
"token_endpoint": "https://demo.identityserver.io/connect/token",
66
"userinfo_endpoint": "https://demo.identityserver.io/connect/userinfo",
77
"end_session_endpoint": "https://demo.identityserver.io/connect/endsession",
8+
"registration_endpoint": "https://demo.identityserver.io/connect/dcr",
89
"check_session_iframe": "https://demo.identityserver.io/connect/checksession",
910
"revocation_endpoint": "https://demo.identityserver.io/connect/revocation",
1011
"introspection_endpoint": "https://demo.identityserver.io/connect/introspect",
12+
"device_authorization_endpoint": "https://demo.identityserver.io/connect/deviceauthorization",
13+
"backchannel_authentication_endpoint": "https://demo.identityserver.io/connect/ciba",
1114
"pushed_authorization_request_endpoint": "https://demo.identityserver.io/connect/par",
15+
"end_session_endpoint": "https://demo.identityserver.io/connect/endsession",
1216
"frontchannel_logout_supported": true,
1317
"frontchannel_logout_session_supported": true,
1418
"scopes_supported": [

0 commit comments

Comments
 (0)