Browse Source

Rename event handlers and event properties that whose endpoint name has changed

pull/2179/head
Kévin Chalet 1 year ago
parent
commit
3662b179dc
  1. 2
      src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.Discovery.cs
  2. 26
      src/OpenIddict.Client/OpenIddictClientHandlers.Discovery.cs
  3. 4
      src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Discovery.cs
  4. 6
      src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Session.cs
  5. 4
      src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Discovery.cs
  6. 6
      src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Session.cs
  7. 8
      src/OpenIddict.Server/OpenIddictServerEvents.Discovery.cs
  8. 8
      src/OpenIddict.Server/OpenIddictServerHandlers.Discovery.cs
  9. 8
      src/OpenIddict.Server/OpenIddictServerHandlers.Session.cs
  10. 2
      src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpHandlers.Discovery.cs
  11. 18
      src/OpenIddict.Validation/OpenIddictValidationHandlers.Discovery.cs
  12. 56
      test/OpenIddict.Server.Tests/OpenIddictServerBuilderTests.cs

2
src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.Discovery.cs

@ -36,7 +36,7 @@ public static partial class OpenIddictClientSystemNetHttpHandlers
DisposeHttpResponse<ExtractConfigurationResponseContext>.Descriptor,
/*
* Cryptography request processing:
* JSON Web Key Set request processing:
*/
CreateHttpClient<PrepareJsonWebKeySetRequestContext>.Descriptor,
PrepareGetHttpRequest<PrepareJsonWebKeySetRequestContext>.Descriptor,

26
src/OpenIddict.Client/OpenIddictClientHandlers.Discovery.cs

@ -27,7 +27,7 @@ public static partial class OpenIddictClientHandlers
ExtractJsonWebKeySetEndpoint.Descriptor,
ExtractDeviceAuthorizationEndpoint.Descriptor,
ExtractIntrospectionEndpoint.Descriptor,
ExtractLogoutEndpoint.Descriptor,
ExtractEndSessionEndpoint.Descriptor,
ExtractRevocationEndpoint.Descriptor,
ExtractTokenEndpoint.Descriptor,
ExtractUserInfoEndpoint.Descriptor,
@ -43,10 +43,10 @@ public static partial class OpenIddictClientHandlers
ExtractTokenEndpointClientAuthenticationMethods.Descriptor,
/*
* Cryptography response handling:
* JSON Web Key Set response handling:
*/
ValidateWellKnownCryptographyParameters.Descriptor,
HandleCryptographyErrorResponse.Descriptor,
ValidateWellKnownJsonWebKeySetParameters.Descriptor,
HandleJsonWebKeySetErrorResponse.Descriptor,
ExtractSigningKeys.Descriptor
]);
@ -433,14 +433,14 @@ public static partial class OpenIddictClientHandlers
/// <summary>
/// Contains the logic responsible for extracting the end session endpoint URI from the discovery document.
/// </summary>
public sealed class ExtractLogoutEndpoint : IOpenIddictClientHandler<HandleConfigurationResponseContext>
public sealed class ExtractEndSessionEndpoint : IOpenIddictClientHandler<HandleConfigurationResponseContext>
{
/// <summary>
/// Gets the default descriptor definition assigned to this handler.
/// </summary>
public static OpenIddictClientHandlerDescriptor Descriptor { get; }
= OpenIddictClientHandlerDescriptor.CreateBuilder<HandleConfigurationResponseContext>()
.UseSingletonHandler<ExtractLogoutEndpoint>()
.UseSingletonHandler<ExtractEndSessionEndpoint>()
.SetOrder(ExtractIntrospectionEndpoint.Descriptor.Order + 1_000)
.SetType(OpenIddictClientHandlerType.BuiltIn)
.Build();
@ -484,7 +484,7 @@ public static partial class OpenIddictClientHandlers
public static OpenIddictClientHandlerDescriptor Descriptor { get; }
= OpenIddictClientHandlerDescriptor.CreateBuilder<HandleConfigurationResponseContext>()
.UseSingletonHandler<ExtractRevocationEndpoint>()
.SetOrder(ExtractLogoutEndpoint.Descriptor.Order + 1_000)
.SetOrder(ExtractEndSessionEndpoint.Descriptor.Order + 1_000)
.SetType(OpenIddictClientHandlerType.BuiltIn)
.Build();
@ -1021,14 +1021,14 @@ public static partial class OpenIddictClientHandlers
/// <summary>
/// Contains the logic responsible for validating the well-known parameters contained in the JSON Web Key Set response.
/// </summary>
public sealed class ValidateWellKnownCryptographyParameters : IOpenIddictClientHandler<HandleJsonWebKeySetResponseContext>
public sealed class ValidateWellKnownJsonWebKeySetParameters : IOpenIddictClientHandler<HandleJsonWebKeySetResponseContext>
{
/// <summary>
/// Gets the default descriptor definition assigned to this handler.
/// </summary>
public static OpenIddictClientHandlerDescriptor Descriptor { get; }
= OpenIddictClientHandlerDescriptor.CreateBuilder<HandleJsonWebKeySetResponseContext>()
.UseSingletonHandler<ValidateWellKnownCryptographyParameters>()
.UseSingletonHandler<ValidateWellKnownJsonWebKeySetParameters>()
.SetOrder(int.MinValue + 100_000)
.SetType(OpenIddictClientHandlerType.BuiltIn)
.Build();
@ -1095,15 +1095,15 @@ public static partial class OpenIddictClientHandlers
/// <summary>
/// Contains the logic responsible for surfacing potential errors from the JSON Web Key Set response.
/// </summary>
public sealed class HandleCryptographyErrorResponse : IOpenIddictClientHandler<HandleJsonWebKeySetResponseContext>
public sealed class HandleJsonWebKeySetErrorResponse : IOpenIddictClientHandler<HandleJsonWebKeySetResponseContext>
{
/// <summary>
/// Gets the default descriptor definition assigned to this handler.
/// </summary>
public static OpenIddictClientHandlerDescriptor Descriptor { get; }
= OpenIddictClientHandlerDescriptor.CreateBuilder<HandleJsonWebKeySetResponseContext>()
.UseSingletonHandler<HandleCryptographyErrorResponse>()
.SetOrder(ValidateWellKnownCryptographyParameters.Descriptor.Order + 1_000)
.UseSingletonHandler<HandleJsonWebKeySetErrorResponse>()
.SetOrder(ValidateWellKnownJsonWebKeySetParameters.Descriptor.Order + 1_000)
.SetType(OpenIddictClientHandlerType.BuiltIn)
.Build();
@ -1146,7 +1146,7 @@ public static partial class OpenIddictClientHandlers
public static OpenIddictClientHandlerDescriptor Descriptor { get; }
= OpenIddictClientHandlerDescriptor.CreateBuilder<HandleJsonWebKeySetResponseContext>()
.UseSingletonHandler<ExtractSigningKeys>()
.SetOrder(HandleCryptographyErrorResponse.Descriptor.Order + 1_000)
.SetOrder(HandleJsonWebKeySetErrorResponse.Descriptor.Order + 1_000)
.SetType(OpenIddictClientHandlerType.BuiltIn)
.Build();

4
src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Discovery.cs

@ -26,12 +26,12 @@ public static partial class OpenIddictServerAspNetCoreHandlers
ProcessJsonResponse<ApplyConfigurationResponseContext>.Descriptor,
/*
* Cryptography request extraction:
* JSON Web Key Set request extraction:
*/
ExtractGetRequest<ExtractJsonWebKeySetRequestContext>.Descriptor,
/*
* Cryptography response processing:
* JSON Web Key Set response processing:
*/
AttachHttpResponseCode<ApplyJsonWebKeySetResponseContext>.Descriptor,
AttachWwwAuthenticateHeader<ApplyJsonWebKeySetResponseContext>.Descriptor,

6
src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Session.cs

@ -27,19 +27,19 @@ public static partial class OpenIddictServerAspNetCoreHandlers
{
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
/*
* Logout request extraction:
* End-session request extraction:
*/
ExtractGetOrPostRequest<ExtractEndSessionRequestContext>.Descriptor,
RestoreCachedRequestParameters.Descriptor,
CacheRequestParameters.Descriptor,
/*
* Logout request handling:
* End-session request handling:
*/
EnablePassthroughMode<HandleEndSessionRequestContext, RequireEndSessionEndpointPassthroughEnabled>.Descriptor,
/*
* Logout response processing:
* End-session response processing:
*/
RemoveCachedRequest.Descriptor,
AttachHttpResponseCode<ApplyEndSessionResponseContext>.Descriptor,

4
src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Discovery.cs

@ -28,12 +28,12 @@ public static partial class OpenIddictServerOwinHandlers
ProcessJsonResponse<ApplyConfigurationResponseContext>.Descriptor,
/*
* Cryptography request extraction:
* JSON Web Key Set request extraction:
*/
ExtractGetRequest<ExtractJsonWebKeySetRequestContext>.Descriptor,
/*
* Cryptography response processing:
* JSON Web Key Set response processing:
*/
AttachHttpResponseCode<ApplyJsonWebKeySetResponseContext>.Descriptor,
AttachOwinResponseChallenge<ApplyJsonWebKeySetResponseContext>.Descriptor,

6
src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Session.cs

@ -26,19 +26,19 @@ public static partial class OpenIddictServerOwinHandlers
{
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
/*
* Logout request extraction:
* End-session request extraction:
*/
ExtractGetOrPostRequest<ExtractEndSessionRequestContext>.Descriptor,
RestoreCachedRequestParameters.Descriptor,
CacheRequestParameters.Descriptor,
/*
* Logout request handling:
* End-session request handling:
*/
EnablePassthroughMode<HandleEndSessionRequestContext, RequireEndSessionEndpointPassthroughEnabled>.Descriptor,
/*
* Logout response processing:
* End-session response processing:
*/
RemoveCachedRequest.Descriptor,
AttachHttpResponseCode<ApplyEndSessionResponseContext>.Descriptor,

8
src/OpenIddict.Server/OpenIddictServerEvents.Discovery.cs

@ -107,14 +107,14 @@ public static partial class OpenIddictServerEvents
public Uri? DeviceAuthorizationEndpoint { get; set; }
/// <summary>
/// Gets or sets the introspection endpoint URI.
/// Gets or sets the end session endpoint URI.
/// </summary>
public Uri? IntrospectionEndpoint { get; set; }
public Uri? EndSessionEndpoint { get; set; }
/// <summary>
/// Gets or sets the end session endpoint URI.
/// Gets or sets the introspection endpoint URI.
/// </summary>
public Uri? LogoutEndpoint { get; set; }
public Uri? IntrospectionEndpoint { get; set; }
/// <summary>
/// Gets or sets the revocation endpoint URI.

8
src/OpenIddict.Server/OpenIddictServerHandlers.Discovery.cs

@ -45,7 +45,7 @@ public static partial class OpenIddictServerHandlers
AttachAdditionalMetadata.Descriptor,
/*
* Cryptography request top-level processing:
* JSON Web Key Set request top-level processing:
*/
ExtractJsonWebKeySetRequest.Descriptor,
ValidateJsonWebKeySetRequest.Descriptor,
@ -54,7 +54,7 @@ public static partial class OpenIddictServerHandlers
ApplyJsonWebKeySetResponse<ProcessRequestContext>.Descriptor,
/*
* Cryptography request handling:
* JSON Web Key Set request handling:
*/
AttachSigningKeys.Descriptor
]);
@ -237,7 +237,7 @@ public static partial class OpenIddictServerHandlers
[Metadata.AuthorizationEndpoint] = notification.AuthorizationEndpoint?.AbsoluteUri,
[Metadata.TokenEndpoint] = notification.TokenEndpoint?.AbsoluteUri,
[Metadata.IntrospectionEndpoint] = notification.IntrospectionEndpoint?.AbsoluteUri,
[Metadata.EndSessionEndpoint] = notification.LogoutEndpoint?.AbsoluteUri,
[Metadata.EndSessionEndpoint] = notification.EndSessionEndpoint?.AbsoluteUri,
[Metadata.RevocationEndpoint] = notification.RevocationEndpoint?.AbsoluteUri,
[Metadata.UserInfoEndpoint] = notification.UserInfoEndpoint?.AbsoluteUri,
[Metadata.DeviceAuthorizationEndpoint] = notification.DeviceAuthorizationEndpoint?.AbsoluteUri,
@ -380,7 +380,7 @@ public static partial class OpenIddictServerHandlers
context.IntrospectionEndpoint ??= OpenIddictHelpers.CreateAbsoluteUri(
context.BaseUri, context.Options.IntrospectionEndpointUris.FirstOrDefault());
context.LogoutEndpoint ??= OpenIddictHelpers.CreateAbsoluteUri(
context.EndSessionEndpoint ??= OpenIddictHelpers.CreateAbsoluteUri(
context.BaseUri, context.Options.EndSessionEndpointUris.FirstOrDefault());
context.RevocationEndpoint ??= OpenIddictHelpers.CreateAbsoluteUri(

8
src/OpenIddict.Server/OpenIddictServerHandlers.Session.cs

@ -21,7 +21,7 @@ public static partial class OpenIddictServerHandlers
{
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
/*
* Logout request top-level processing:
* End-session request top-level processing:
*/
ExtractEndSessionRequest.Descriptor,
ValidateEndSessionRequest.Descriptor,
@ -31,7 +31,7 @@ public static partial class OpenIddictServerHandlers
ApplyEndSessionResponse<ProcessSignOutContext>.Descriptor,
/*
* Logout request validation:
* End-session request validation:
*/
ValidatePostLogoutRedirectUriParameter.Descriptor,
ValidateAuthentication.Descriptor,
@ -40,12 +40,12 @@ public static partial class OpenIddictServerHandlers
ValidateAuthorizedParty.Descriptor,
/*
* Logout request handling:
* End-session request handling:
*/
AttachPrincipal.Descriptor,
/*
* Logout response processing:
* End-session response processing:
*/
AttachPostLogoutRedirectUri.Descriptor,
AttachResponseState.Descriptor

2
src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpHandlers.Discovery.cs

@ -36,7 +36,7 @@ public static partial class OpenIddictValidationSystemNetHttpHandlers
DisposeHttpResponse<ExtractConfigurationResponseContext>.Descriptor,
/*
* Cryptography request processing:
* JSON Web Key Set request processing:
*/
CreateHttpClient<PrepareJsonWebKeySetRequestContext>.Descriptor,
PrepareGetHttpRequest<PrepareJsonWebKeySetRequestContext>.Descriptor,

18
src/OpenIddict.Validation/OpenIddictValidationHandlers.Discovery.cs

@ -28,10 +28,10 @@ public static partial class OpenIddictValidationHandlers
ExtractIntrospectionEndpointClientAuthenticationMethods.Descriptor,
/*
* Cryptography response handling:
* JSON Web Key Set response handling:
*/
ValidateWellKnownCryptographyParameters.Descriptor,
HandleCryptographyErrorResponse.Descriptor,
ValidateWellKnownJsonWebKeySetParameters.Descriptor,
HandleJsonWebKeySetErrorResponse.Descriptor,
ExtractSigningKeys.Descriptor
]);
@ -351,14 +351,14 @@ public static partial class OpenIddictValidationHandlers
/// <summary>
/// Contains the logic responsible for validating the well-known parameters contained in the JSON Web Key Set response.
/// </summary>
public sealed class ValidateWellKnownCryptographyParameters : IOpenIddictValidationHandler<HandleJsonWebKeySetResponseContext>
public sealed class ValidateWellKnownJsonWebKeySetParameters : IOpenIddictValidationHandler<HandleJsonWebKeySetResponseContext>
{
/// <summary>
/// Gets the default descriptor definition assigned to this handler.
/// </summary>
public static OpenIddictValidationHandlerDescriptor Descriptor { get; }
= OpenIddictValidationHandlerDescriptor.CreateBuilder<HandleJsonWebKeySetResponseContext>()
.UseSingletonHandler<ValidateWellKnownCryptographyParameters>()
.UseSingletonHandler<ValidateWellKnownJsonWebKeySetParameters>()
.SetOrder(int.MinValue + 100_000)
.SetType(OpenIddictValidationHandlerType.BuiltIn)
.Build();
@ -425,15 +425,15 @@ public static partial class OpenIddictValidationHandlers
/// <summary>
/// Contains the logic responsible for surfacing potential errors from the JSON Web Key Set response.
/// </summary>
public sealed class HandleCryptographyErrorResponse : IOpenIddictValidationHandler<HandleJsonWebKeySetResponseContext>
public sealed class HandleJsonWebKeySetErrorResponse : IOpenIddictValidationHandler<HandleJsonWebKeySetResponseContext>
{
/// <summary>
/// Gets the default descriptor definition assigned to this handler.
/// </summary>
public static OpenIddictValidationHandlerDescriptor Descriptor { get; }
= OpenIddictValidationHandlerDescriptor.CreateBuilder<HandleJsonWebKeySetResponseContext>()
.UseSingletonHandler<HandleCryptographyErrorResponse>()
.SetOrder(ValidateWellKnownCryptographyParameters.Descriptor.Order + 1_000)
.UseSingletonHandler<HandleJsonWebKeySetErrorResponse>()
.SetOrder(ValidateWellKnownJsonWebKeySetParameters.Descriptor.Order + 1_000)
.SetType(OpenIddictValidationHandlerType.BuiltIn)
.Build();
@ -476,7 +476,7 @@ public static partial class OpenIddictValidationHandlers
public static OpenIddictValidationHandlerDescriptor Descriptor { get; }
= OpenIddictValidationHandlerDescriptor.CreateBuilder<HandleJsonWebKeySetResponseContext>()
.UseSingletonHandler<ExtractSigningKeys>()
.SetOrder(HandleCryptographyErrorResponse.Descriptor.Order + 1_000)
.SetOrder(HandleJsonWebKeySetErrorResponse.Descriptor.Order + 1_000)
.SetType(OpenIddictValidationHandlerType.BuiltIn)
.Build();

56
test/OpenIddict.Server.Tests/OpenIddictServerBuilderTests.cs

@ -1101,171 +1101,171 @@ public class OpenIddictServerBuilderTests
}
[Fact]
public void SetIntrospectionEndpointUris_ThrowsExceptionWhenUrisIsNull()
public void SetEndSessionEndpointUris_ThrowsExceptionWhenUrisIsNull()
{
// Arrange
var services = CreateServices();
var builder = CreateBuilder(services);
// Act and assert
var exception = Assert.Throws<ArgumentNullException>(() => builder.SetIntrospectionEndpointUris(uris: (null as Uri[])!));
var exception = Assert.Throws<ArgumentNullException>(() => builder.SetEndSessionEndpointUris(uris: (null as Uri[])!));
Assert.Equal("uris", exception.ParamName);
}
[Fact]
public void SetIntrospectionEndpointUris_Strings_ThrowsExceptionWhenUrisIsNull()
public void SetEndSessionEndpointUris_Strings_ThrowsExceptionWhenUrisIsNull()
{
// Arrange
var services = CreateServices();
var builder = CreateBuilder(services);
// Act and assert
var exception = Assert.Throws<ArgumentNullException>(() => builder.SetIntrospectionEndpointUris(uris: (null as string[])!));
var exception = Assert.Throws<ArgumentNullException>(() => builder.SetEndSessionEndpointUris(uris: (null as string[])!));
Assert.Equal("uris", exception.ParamName);
}
[Theory]
[InlineData(@"C:\")]
public void SetIntrospectionEndpointUris_ThrowsExceptionForMalformedUri(string uri)
public void SetEndSessionEndpointUris_ThrowsExceptionForMalformedUri(string uri)
{
// Arrange
var services = CreateServices();
var builder = CreateBuilder(services);
// Act and assert
var exception = Assert.Throws<ArgumentException>(() => builder.SetIntrospectionEndpointUris(new Uri(uri)));
var exception = Assert.Throws<ArgumentException>(() => builder.SetEndSessionEndpointUris(new Uri(uri)));
Assert.Equal("uris", exception.ParamName);
Assert.Contains(SR.GetResourceString(SR.ID0072), exception.Message);
}
[Theory]
[InlineData("~/path")]
public void SetIntrospectionEndpointUris_ThrowsExceptionForInvalidRelativeUri(string uri)
public void SetEndSessionEndpointUris_ThrowsExceptionForInvalidRelativeUri(string uri)
{
// Arrange
var services = CreateServices();
var builder = CreateBuilder(services);
// Act and assert
var exception = Assert.Throws<ArgumentException>(() => builder.SetIntrospectionEndpointUris(new Uri(uri, UriKind.RelativeOrAbsolute)));
var exception = Assert.Throws<ArgumentException>(() => builder.SetEndSessionEndpointUris(new Uri(uri, UriKind.RelativeOrAbsolute)));
Assert.Equal("uris", exception.ParamName);
Assert.Contains(SR.FormatID0081("~"), exception.Message);
}
[Fact]
public void SetIntrospectionEndpointUris_ClearsUris()
public void SetEndSessionEndpointUris_ClearsUris()
{
// Arrange
var services = CreateServices();
var builder = CreateBuilder(services);
// Act
builder.SetIntrospectionEndpointUris(Array.Empty<Uri>());
builder.SetEndSessionEndpointUris(Array.Empty<Uri>());
var options = GetOptions(services);
// Assert
Assert.Empty(options.IntrospectionEndpointUris);
Assert.Empty(options.EndSessionEndpointUris);
}
[Fact]
public void SetIntrospectionEndpointUris_AddsUri()
public void SetEndSessionEndpointUris_AddsUri()
{
// Arrange
var services = CreateServices();
var builder = CreateBuilder(services);
// Act
builder.SetIntrospectionEndpointUris("http://localhost/endpoint-path");
builder.SetEndSessionEndpointUris("http://localhost/endpoint-path");
var options = GetOptions(services);
// Assert
Assert.Contains(new Uri("http://localhost/endpoint-path"), options.IntrospectionEndpointUris);
Assert.Contains(new Uri("http://localhost/endpoint-path"), options.EndSessionEndpointUris);
}
[Fact]
public void SetLogoutEndpointUris_ThrowsExceptionWhenUrisIsNull()
public void SetIntrospectionEndpointUris_ThrowsExceptionWhenUrisIsNull()
{
// Arrange
var services = CreateServices();
var builder = CreateBuilder(services);
// Act and assert
var exception = Assert.Throws<ArgumentNullException>(() => builder.SetEndSessionEndpointUris(uris: (null as Uri[])!));
var exception = Assert.Throws<ArgumentNullException>(() => builder.SetIntrospectionEndpointUris(uris: (null as Uri[])!));
Assert.Equal("uris", exception.ParamName);
}
[Fact]
public void SetLogoutEndpointUris_Strings_ThrowsExceptionWhenUrisIsNull()
public void SetIntrospectionEndpointUris_Strings_ThrowsExceptionWhenUrisIsNull()
{
// Arrange
var services = CreateServices();
var builder = CreateBuilder(services);
// Act and assert
var exception = Assert.Throws<ArgumentNullException>(() => builder.SetEndSessionEndpointUris(uris: (null as string[])!));
var exception = Assert.Throws<ArgumentNullException>(() => builder.SetIntrospectionEndpointUris(uris: (null as string[])!));
Assert.Equal("uris", exception.ParamName);
}
[Theory]
[InlineData(@"C:\")]
public void SetLogoutEndpointUris_ThrowsExceptionForMalformedUri(string uri)
public void SetIntrospectionEndpointUris_ThrowsExceptionForMalformedUri(string uri)
{
// Arrange
var services = CreateServices();
var builder = CreateBuilder(services);
// Act and assert
var exception = Assert.Throws<ArgumentException>(() => builder.SetEndSessionEndpointUris(new Uri(uri)));
var exception = Assert.Throws<ArgumentException>(() => builder.SetIntrospectionEndpointUris(new Uri(uri)));
Assert.Equal("uris", exception.ParamName);
Assert.Contains(SR.GetResourceString(SR.ID0072), exception.Message);
}
[Theory]
[InlineData("~/path")]
public void SetLogoutEndpointUris_ThrowsExceptionForInvalidRelativeUri(string uri)
public void SetIntrospectionEndpointUris_ThrowsExceptionForInvalidRelativeUri(string uri)
{
// Arrange
var services = CreateServices();
var builder = CreateBuilder(services);
// Act and assert
var exception = Assert.Throws<ArgumentException>(() => builder.SetEndSessionEndpointUris(new Uri(uri, UriKind.RelativeOrAbsolute)));
var exception = Assert.Throws<ArgumentException>(() => builder.SetIntrospectionEndpointUris(new Uri(uri, UriKind.RelativeOrAbsolute)));
Assert.Equal("uris", exception.ParamName);
Assert.Contains(SR.FormatID0081("~"), exception.Message);
}
[Fact]
public void SetLogoutEndpointUris_ClearsUris()
public void SetIntrospectionEndpointUris_ClearsUris()
{
// Arrange
var services = CreateServices();
var builder = CreateBuilder(services);
// Act
builder.SetEndSessionEndpointUris(Array.Empty<Uri>());
builder.SetIntrospectionEndpointUris(Array.Empty<Uri>());
var options = GetOptions(services);
// Assert
Assert.Empty(options.EndSessionEndpointUris);
Assert.Empty(options.IntrospectionEndpointUris);
}
[Fact]
public void SetLogoutEndpointUris_AddsUri()
public void SetIntrospectionEndpointUris_AddsUri()
{
// Arrange
var services = CreateServices();
var builder = CreateBuilder(services);
// Act
builder.SetEndSessionEndpointUris("http://localhost/endpoint-path");
builder.SetIntrospectionEndpointUris("http://localhost/endpoint-path");
var options = GetOptions(services);
// Assert
Assert.Contains(new Uri("http://localhost/endpoint-path"), options.EndSessionEndpointUris);
Assert.Contains(new Uri("http://localhost/endpoint-path"), options.IntrospectionEndpointUris);
}
[Fact]

Loading…
Cancel
Save