|
|
@ -1982,21 +1982,6 @@ namespace OpenIddict.Abstractions.Tests.Primitives |
|
|
Assert.StartsWith(SR.GetResourceString(SR.ID0186), exception.Message); |
|
|
Assert.StartsWith(SR.GetResourceString(SR.ID0186), exception.Message); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
[Theory] |
|
|
|
|
|
[InlineData(new string[0], false)] |
|
|
|
|
|
[InlineData(new[] { "fabrikam" }, true)] |
|
|
|
|
|
public void HasAudience_ReturnsExpectedResult(string[] audience, bool result) |
|
|
|
|
|
{ |
|
|
|
|
|
// Arrange
|
|
|
|
|
|
var identity = new ClaimsIdentity(); |
|
|
|
|
|
var principal = new ClaimsPrincipal(identity); |
|
|
|
|
|
|
|
|
|
|
|
principal.SetClaims(Claims.Private.Audience, audience.ToImmutableArray()); |
|
|
|
|
|
|
|
|
|
|
|
// Act and assert
|
|
|
|
|
|
Assert.Equal(result, principal.HasAudience()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
[Theory] |
|
|
[InlineData(new string[0], false)] |
|
|
[InlineData(new string[0], false)] |
|
|
[InlineData(new[] { "contoso" }, false)] |
|
|
[InlineData(new[] { "contoso" }, false)] |
|
|
@ -2007,7 +1992,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives |
|
|
[InlineData(new[] { "CONTOSO", "FABRIKAM" }, false)] |
|
|
[InlineData(new[] { "CONTOSO", "FABRIKAM" }, false)] |
|
|
[InlineData(new[] { "FABRIKAM" }, false)] |
|
|
[InlineData(new[] { "FABRIKAM" }, false)] |
|
|
[InlineData(new[] { "FABRIKAM", "CONTOSO" }, false)] |
|
|
[InlineData(new[] { "FABRIKAM", "CONTOSO" }, false)] |
|
|
public void HasAudience_ReturnsAppropriateResult(string[] audience, bool result) |
|
|
public void HasAudience_ReturnsExpectedResult(string[] audience, bool result) |
|
|
{ |
|
|
{ |
|
|
// Arrange
|
|
|
// Arrange
|
|
|
var identity = new ClaimsIdentity(); |
|
|
var identity = new ClaimsIdentity(); |
|
|
@ -2046,21 +2031,6 @@ namespace OpenIddict.Abstractions.Tests.Primitives |
|
|
Assert.StartsWith(SR.GetResourceString(SR.ID0187), exception.Message); |
|
|
Assert.StartsWith(SR.GetResourceString(SR.ID0187), exception.Message); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
[Theory] |
|
|
|
|
|
[InlineData(new string[0], false)] |
|
|
|
|
|
[InlineData(new[] { "fabrikam" }, true)] |
|
|
|
|
|
public void HasPresenter_ReturnsExpectedResult(string[] presenter, bool result) |
|
|
|
|
|
{ |
|
|
|
|
|
// Arrange
|
|
|
|
|
|
var identity = new ClaimsIdentity(); |
|
|
|
|
|
var principal = new ClaimsPrincipal(identity); |
|
|
|
|
|
|
|
|
|
|
|
principal.SetClaims(Claims.Private.Presenter, presenter.ToImmutableArray()); |
|
|
|
|
|
|
|
|
|
|
|
// Act and assert
|
|
|
|
|
|
Assert.Equal(result, principal.HasPresenter()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
[Theory] |
|
|
[InlineData(new string[0], false)] |
|
|
[InlineData(new string[0], false)] |
|
|
[InlineData(new[] { "contoso" }, false)] |
|
|
[InlineData(new[] { "contoso" }, false)] |
|
|
@ -2071,7 +2041,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives |
|
|
[InlineData(new[] { "CONTOSO", "FABRIKAM" }, false)] |
|
|
[InlineData(new[] { "CONTOSO", "FABRIKAM" }, false)] |
|
|
[InlineData(new[] { "FABRIKAM" }, false)] |
|
|
[InlineData(new[] { "FABRIKAM" }, false)] |
|
|
[InlineData(new[] { "FABRIKAM", "CONTOSO" }, false)] |
|
|
[InlineData(new[] { "FABRIKAM", "CONTOSO" }, false)] |
|
|
public void HasPresenter_ReturnsAppropriateResult(string[] presenter, bool result) |
|
|
public void HasPresenter_ReturnsExpectedResult(string[] presenter, bool result) |
|
|
{ |
|
|
{ |
|
|
// Arrange
|
|
|
// Arrange
|
|
|
var identity = new ClaimsIdentity(); |
|
|
var identity = new ClaimsIdentity(); |
|
|
@ -2110,21 +2080,6 @@ namespace OpenIddict.Abstractions.Tests.Primitives |
|
|
Assert.StartsWith(SR.GetResourceString(SR.ID0062), exception.Message); |
|
|
Assert.StartsWith(SR.GetResourceString(SR.ID0062), exception.Message); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
[Theory] |
|
|
|
|
|
[InlineData(new string[0], false)] |
|
|
|
|
|
[InlineData(new[] { "fabrikam" }, true)] |
|
|
|
|
|
public void HasResource_ReturnsExpectedResult(string[] resource, bool result) |
|
|
|
|
|
{ |
|
|
|
|
|
// Arrange
|
|
|
|
|
|
var identity = new ClaimsIdentity(); |
|
|
|
|
|
var principal = new ClaimsPrincipal(identity); |
|
|
|
|
|
|
|
|
|
|
|
principal.SetClaims(Claims.Private.Resource, resource.ToImmutableArray()); |
|
|
|
|
|
|
|
|
|
|
|
// Act and assert
|
|
|
|
|
|
Assert.Equal(result, principal.HasResource()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
[Theory] |
|
|
[InlineData(new string[0], false)] |
|
|
[InlineData(new string[0], false)] |
|
|
[InlineData(new[] { "contoso" }, false)] |
|
|
[InlineData(new[] { "contoso" }, false)] |
|
|
@ -2135,7 +2090,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives |
|
|
[InlineData(new[] { "CONTOSO", "FABRIKAM" }, false)] |
|
|
[InlineData(new[] { "CONTOSO", "FABRIKAM" }, false)] |
|
|
[InlineData(new[] { "FABRIKAM" }, false)] |
|
|
[InlineData(new[] { "FABRIKAM" }, false)] |
|
|
[InlineData(new[] { "FABRIKAM", "CONTOSO" }, false)] |
|
|
[InlineData(new[] { "FABRIKAM", "CONTOSO" }, false)] |
|
|
public void HasResource_ReturnsAppropriateResult(string[] resource, bool result) |
|
|
public void HasResource_ReturnsExpectedResult(string[] resource, bool result) |
|
|
{ |
|
|
{ |
|
|
// Arrange
|
|
|
// Arrange
|
|
|
var identity = new ClaimsIdentity(); |
|
|
var identity = new ClaimsIdentity(); |
|
|
@ -2148,7 +2103,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
[Fact] |
|
|
[Fact] |
|
|
public void HasScope_ThrowsAnExceptionForNullPrincipal() |
|
|
public void ClaimsPrincipal_HasScope_ThrowsAnExceptionForNullPrincipal() |
|
|
{ |
|
|
{ |
|
|
// Arrange
|
|
|
// Arrange
|
|
|
var principal = (ClaimsPrincipal) null!; |
|
|
var principal = (ClaimsPrincipal) null!; |
|
|
@ -2174,21 +2129,6 @@ namespace OpenIddict.Abstractions.Tests.Primitives |
|
|
Assert.StartsWith(SR.GetResourceString(SR.ID0180), exception.Message); |
|
|
Assert.StartsWith(SR.GetResourceString(SR.ID0180), exception.Message); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
[Theory] |
|
|
|
|
|
[InlineData(new string[0], false)] |
|
|
|
|
|
[InlineData(new[] { "openid" }, true)] |
|
|
|
|
|
public void ClaimsPrincipal_HasScope_ReturnsExpectedResult(string[] scope, bool result) |
|
|
|
|
|
{ |
|
|
|
|
|
// Arrange
|
|
|
|
|
|
var identity = new ClaimsIdentity(); |
|
|
|
|
|
var principal = new ClaimsPrincipal(identity); |
|
|
|
|
|
|
|
|
|
|
|
principal.SetClaims(Claims.Private.Scope, scope.ToImmutableArray()); |
|
|
|
|
|
|
|
|
|
|
|
// Act and assert
|
|
|
|
|
|
Assert.Equal(result, principal.HasScope()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Theory] |
|
|
[Theory] |
|
|
[InlineData(new string[0], false)] |
|
|
[InlineData(new string[0], false)] |
|
|
[InlineData(new[] { "profile" }, false)] |
|
|
[InlineData(new[] { "profile" }, false)] |
|
|
@ -2199,7 +2139,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives |
|
|
[InlineData(new[] { "PROFILE", "OPENID" }, false)] |
|
|
[InlineData(new[] { "PROFILE", "OPENID" }, false)] |
|
|
[InlineData(new[] { "OPENID" }, false)] |
|
|
[InlineData(new[] { "OPENID" }, false)] |
|
|
[InlineData(new[] { "OPENID", "PROFILE" }, false)] |
|
|
[InlineData(new[] { "OPENID", "PROFILE" }, false)] |
|
|
public void HasScope_ReturnsAppropriateResult(string[] scope, bool result) |
|
|
public void ClaimsPrincipal_HasScope_ReturnsExpectedResult(string[] scope, bool result) |
|
|
{ |
|
|
{ |
|
|
// Arrange
|
|
|
// Arrange
|
|
|
var identity = new ClaimsIdentity(); |
|
|
var identity = new ClaimsIdentity(); |
|
|
|