This repository has been archived by the owner on Jul 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Honour EnableDeviceAuthorizationEndpoint in IsEndpointEnabled (#3645)
- Loading branch information
1 parent
40eec71
commit 684b441
Showing
2 changed files
with
138 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
135 changes: 135 additions & 0 deletions
135
...dentityServer4/test/IdentityServer.UnitTests/Extensions/EndpointOptionsExtensionsTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
using IdentityServer4.Configuration; | ||
using IdentityServer4.Extensions; | ||
using IdentityServer4.Hosting; | ||
using Xunit; | ||
using static IdentityServer4.Constants; | ||
|
||
namespace IdentityServer.UnitTests.Extensions | ||
{ | ||
public class EndpointOptionsExtensionsTests | ||
{ | ||
private readonly EndpointsOptions _options = new EndpointsOptions(); | ||
|
||
[Theory] | ||
[InlineData(true)] | ||
[InlineData(false)] | ||
public void IsEndpointEnabledShouldReturnExpectedForAuthorizeEndpoint(bool expectedIsEndpointEnabled) | ||
{ | ||
_options.EnableAuthorizeEndpoint = expectedIsEndpointEnabled; | ||
|
||
Assert.Equal( | ||
expectedIsEndpointEnabled, | ||
_options.IsEndpointEnabled( | ||
CreateTestEndpoint(EndpointNames.Authorize))); | ||
} | ||
|
||
[Theory] | ||
[InlineData(true)] | ||
[InlineData(false)] | ||
public void IsEndpointEnabledShouldReturnExpectedForCheckSessionEndpoint(bool expectedIsEndpointEnabled) | ||
{ | ||
_options.EnableCheckSessionEndpoint = expectedIsEndpointEnabled; | ||
|
||
Assert.Equal( | ||
expectedIsEndpointEnabled, | ||
_options.IsEndpointEnabled( | ||
CreateTestEndpoint(EndpointNames.CheckSession))); | ||
} | ||
|
||
[Theory] | ||
[InlineData(true)] | ||
[InlineData(false)] | ||
public void IsEndpointEnabledShouldReturnExpectedForDeviceAuthorizationEndpoint(bool expectedIsEndpointEnabled) | ||
{ | ||
_options.EnableDeviceAuthorizationEndpoint = expectedIsEndpointEnabled; | ||
|
||
Assert.Equal( | ||
expectedIsEndpointEnabled, | ||
_options.IsEndpointEnabled( | ||
CreateTestEndpoint(EndpointNames.DeviceAuthorization))); | ||
} | ||
|
||
[Theory] | ||
[InlineData(true)] | ||
[InlineData(false)] | ||
public void IsEndpointEnabledShouldReturnExpectedForDiscoveryEndpoint(bool expectedIsEndpointEnabled) | ||
{ | ||
_options.EnableDiscoveryEndpoint = expectedIsEndpointEnabled; | ||
|
||
Assert.Equal( | ||
expectedIsEndpointEnabled, | ||
_options.IsEndpointEnabled( | ||
CreateTestEndpoint(EndpointNames.Discovery))); | ||
} | ||
|
||
[Theory] | ||
[InlineData(true)] | ||
[InlineData(false)] | ||
public void IsEndpointEnabledShouldReturnExpectedForEndSessionEndpoint(bool expectedIsEndpointEnabled) | ||
{ | ||
_options.EnableEndSessionEndpoint = expectedIsEndpointEnabled; | ||
|
||
Assert.Equal( | ||
expectedIsEndpointEnabled, | ||
_options.IsEndpointEnabled( | ||
CreateTestEndpoint(EndpointNames.EndSession))); | ||
} | ||
|
||
[Theory] | ||
[InlineData(true)] | ||
[InlineData(false)] | ||
public void IsEndpointEnabledShouldReturnExpectedForIntrospectionEndpoint(bool expectedIsEndpointEnabled) | ||
{ | ||
_options.EnableIntrospectionEndpoint = expectedIsEndpointEnabled; | ||
|
||
Assert.Equal( | ||
expectedIsEndpointEnabled, | ||
_options.IsEndpointEnabled( | ||
CreateTestEndpoint(EndpointNames.Introspection))); | ||
} | ||
|
||
[Theory] | ||
[InlineData(true)] | ||
[InlineData(false)] | ||
public void IsEndpointEnabledShouldReturnExpectedForTokenEndpoint(bool expectedIsEndpointEnabled) | ||
{ | ||
_options.EnableTokenEndpoint = expectedIsEndpointEnabled; | ||
|
||
Assert.Equal( | ||
expectedIsEndpointEnabled, | ||
_options.IsEndpointEnabled( | ||
CreateTestEndpoint(EndpointNames.Token))); | ||
} | ||
|
||
[Theory] | ||
[InlineData(true)] | ||
[InlineData(false)] | ||
public void IsEndpointEnabledShouldReturnExpectedForRevocationEndpoint(bool expectedIsEndpointEnabled) | ||
{ | ||
_options.EnableTokenRevocationEndpoint = expectedIsEndpointEnabled; | ||
|
||
Assert.Equal( | ||
expectedIsEndpointEnabled, | ||
_options.IsEndpointEnabled( | ||
CreateTestEndpoint(EndpointNames.Revocation))); | ||
} | ||
|
||
[Theory] | ||
[InlineData(true)] | ||
[InlineData(false)] | ||
public void IsEndpointEnabledShouldReturnExpectedForUserInfoEndpoint(bool expectedIsEndpointEnabled) | ||
{ | ||
_options.EnableUserInfoEndpoint = expectedIsEndpointEnabled; | ||
|
||
Assert.Equal( | ||
expectedIsEndpointEnabled, | ||
_options.IsEndpointEnabled( | ||
CreateTestEndpoint(EndpointNames.UserInfo))); | ||
} | ||
|
||
private Endpoint CreateTestEndpoint(string name) | ||
{ | ||
return new Endpoint(name, "", null); | ||
} | ||
} | ||
} |