|
|
|
@ -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] |
|
|
|
|