Interface IClaimsPrincipalBuilder
Used for building mocked System.Security.Claims.ClaimsPrincipal.
Namespace:MyTested.AspNetCore.Mvc.Builders.Contracts.Authentication
Assembly:MyTested.AspNetCore.Mvc.Authentication.dll
Syntax
public interface IClaimsPrincipalBuilder
Methods
| Improve this Doc View SourceInRole(String)
Adds role to the built System.Security.Claims.ClaimsPrincipal.
Declaration
IAndClaimsPrincipalBuilder InRole(string role)
Parameters
Type | Name | Description |
---|---|---|
System.String | role | Value of the role claim. Default claim type is System.Security.Claims.ClaimTypes.Role. |
Returns
Type | Description |
---|---|
MyTested.AspNetCore.Mvc.Builders.Contracts.Authentication.IAndClaimsPrincipalBuilder | The same MyTested.AspNetCore.Mvc.Builders.Contracts.Authentication.IAndClaimsPrincipalBuilder. |
InRoles(IEnumerable<String>)
Adds roles to the built System.Security.Claims.ClaimsPrincipal.
Declaration
IAndClaimsPrincipalBuilder InRoles(IEnumerable<string> roles)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.String> | roles | Collection of role names to add. |
Returns
Type | Description |
---|---|
MyTested.AspNetCore.Mvc.Builders.Contracts.Authentication.IAndClaimsPrincipalBuilder | The same MyTested.AspNetCore.Mvc.Builders.Contracts.Authentication.IAndClaimsPrincipalBuilder. |
InRoles(String[])
Adds roles to the built System.Security.Claims.ClaimsPrincipal.
Declaration
IAndClaimsPrincipalBuilder InRoles(params string[] roles)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | roles | Role name parameters to add. |
Returns
Type | Description |
---|---|
MyTested.AspNetCore.Mvc.Builders.Contracts.Authentication.IAndClaimsPrincipalBuilder | The same MyTested.AspNetCore.Mvc.Builders.Contracts.Authentication.IAndClaimsPrincipalBuilder. |
WithAuthenticationType(String)
Adds authentication type to the built System.Security.Claims.ClaimsPrincipal. If such is not provided, "Passport" is used by default.
Declaration
IAndClaimsPrincipalBuilder WithAuthenticationType(string authenticationType)
Parameters
Type | Name | Description |
---|---|---|
System.String | authenticationType | Authentication type to add. |
Returns
Type | Description |
---|---|
MyTested.AspNetCore.Mvc.Builders.Contracts.Authentication.IAndClaimsPrincipalBuilder | The same MyTested.AspNetCore.Mvc.Builders.Contracts.Authentication.IAndClaimsPrincipalBuilder. |
WithClaim(Claim)
Adds claim to the built System.Security.Claims.ClaimsPrincipal.
Declaration
IAndClaimsPrincipalBuilder WithClaim(Claim claim)
Parameters
Type | Name | Description |
---|---|---|
System.Security.Claims.Claim | claim | The Claim to add. |
Returns
Type | Description |
---|---|
MyTested.AspNetCore.Mvc.Builders.Contracts.Authentication.IAndClaimsPrincipalBuilder | The same MyTested.AspNetCore.Mvc.Builders.Contracts.Authentication.IAndClaimsPrincipalBuilder. |
WithClaim(String, String)
Adds claim to the built System.Security.Claims.ClaimsPrincipal.
Declaration
IAndClaimsPrincipalBuilder WithClaim(string type, string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | type | Type of the Claim to add. |
System.String | value | Value of the Claim to add. |
Returns
Type | Description |
---|---|
MyTested.AspNetCore.Mvc.Builders.Contracts.Authentication.IAndClaimsPrincipalBuilder | The same MyTested.AspNetCore.Mvc.Builders.Contracts.Authentication.IAndClaimsPrincipalBuilder. |
WithClaims(IEnumerable<Claim>)
Adds claims to the built System.Security.Claims.ClaimsPrincipal.
Declaration
IAndClaimsPrincipalBuilder WithClaims(IEnumerable<Claim> claims)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.Security.Claims.Claim> | claims | Collection of Claim to add. |
Returns
Type | Description |
---|---|
MyTested.AspNetCore.Mvc.Builders.Contracts.Authentication.IAndClaimsPrincipalBuilder | The same MyTested.AspNetCore.Mvc.Builders.Contracts.Authentication.IAndClaimsPrincipalBuilder. |
WithClaims(Claim[])
Adds claims to the built System.Security.Claims.ClaimsPrincipal.
Declaration
IAndClaimsPrincipalBuilder WithClaims(params Claim[] claims)
Parameters
Type | Name | Description |
---|---|---|
System.Security.Claims.Claim[] | claims | Claim parameters to add. |
Returns
Type | Description |
---|---|
MyTested.AspNetCore.Mvc.Builders.Contracts.Authentication.IAndClaimsPrincipalBuilder | The same MyTested.AspNetCore.Mvc.Builders.Contracts.Authentication.IAndClaimsPrincipalBuilder. |
WithIdentifier(String)
Sets identifier claim to the built System.Security.Claims.ClaimsPrincipal. If such is not provided, "TestId" is used by default.
Declaration
IAndClaimsPrincipalBuilder WithIdentifier(string identifier)
Parameters
Type | Name | Description |
---|---|---|
System.String | identifier | Value of the identifier claim - System.Security.Claims.ClaimTypes.NameIdentifier. |
Returns
Type | Description |
---|---|
MyTested.AspNetCore.Mvc.Builders.Contracts.Authentication.IAndClaimsPrincipalBuilder | The same MyTested.AspNetCore.Mvc.Builders.Contracts.Authentication.IAndClaimsPrincipalBuilder. |
WithIdentity(Action<IClaimsIdentityBuilder>)
Adds IIdentity to the built System.Security.Claims.ClaimsPrincipal.
Declaration
IAndClaimsPrincipalBuilder WithIdentity(Action<IClaimsIdentityBuilder> claimsIdentityBuilder)
Parameters
Type | Name | Description |
---|---|---|
System.Action<IClaimsIdentityBuilder> | claimsIdentityBuilder | Builder for creating mocked IIdentity. |
Returns
Type | Description |
---|---|
MyTested.AspNetCore.Mvc.Builders.Contracts.Authentication.IAndClaimsPrincipalBuilder | The same MyTested.AspNetCore.Mvc.Builders.Contracts.Authentication.IAndClaimsPrincipalBuilder. |
WithIdentity(IIdentity)
Adds IIdentity to the built System.Security.Claims.ClaimsPrincipal.
Declaration
IAndClaimsPrincipalBuilder WithIdentity(IIdentity identity)
Parameters
Type | Name | Description |
---|---|---|
System.Security.Principal.IIdentity | identity | IIdentity to add. |
Returns
Type | Description |
---|---|
MyTested.AspNetCore.Mvc.Builders.Contracts.Authentication.IAndClaimsPrincipalBuilder | The same MyTested.AspNetCore.Mvc.Builders.Contracts.Authentication.IAndClaimsPrincipalBuilder. |
WithNameType(String)
Sets type of the username claim. Default is System.Security.Claims.ClaimTypes.Name.
Declaration
IAndClaimsPrincipalBuilder WithNameType(string nameType)
Parameters
Type | Name | Description |
---|---|---|
System.String | nameType | Type to set on the username claim. |
Returns
Type | Description |
---|---|
MyTested.AspNetCore.Mvc.Builders.Contracts.Authentication.IAndClaimsPrincipalBuilder | The same MyTested.AspNetCore.Mvc.Builders.Contracts.Authentication.IAndClaimsPrincipalBuilder. |
WithRoleType(String)
Sets type of the role claim. Default is System.Security.Claims.ClaimTypes.Role.
Declaration
IAndClaimsPrincipalBuilder WithRoleType(string roleType)
Parameters
Type | Name | Description |
---|---|---|
System.String | roleType | Type to set on the role claim. |
Returns
Type | Description |
---|---|
MyTested.AspNetCore.Mvc.Builders.Contracts.Authentication.IAndClaimsPrincipalBuilder | The same MyTested.AspNetCore.Mvc.Builders.Contracts.Authentication.IAndClaimsPrincipalBuilder. |
WithUsername(String)
Sets username claims to the built System.Security.Claims.ClaimsPrincipal. If such is not provided, "TestUser" is used by default.
Declaration
IAndClaimsPrincipalBuilder WithUsername(string username)
Parameters
Type | Name | Description |
---|---|---|
System.String | username | Value of the username claim. Default claim type is System.Security.Claims.ClaimTypes.Name. |
Returns
Type | Description |
---|---|
MyTested.AspNetCore.Mvc.Builders.Contracts.Authentication.IAndClaimsPrincipalBuilder | The same MyTested.AspNetCore.Mvc.Builders.Contracts.Authentication.IAndClaimsPrincipalBuilder. |