Interface IClaimsIdentityBuilder
Used for building mocked System.Security.Claims.ClaimsIdentity.
Namespace:MyTested.AspNetCore.Mvc.Builders.Contracts.Authentication
Assembly:MyTested.AspNetCore.Mvc.Authentication.dll
Syntax
public interface IClaimsIdentityBuilder
Methods
| Improve this Doc View SourceInRole(String)
Adds role to the built System.Security.Claims.ClaimsIdentity.
Declaration
IAndClaimsIdentityBuilder 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.IAndClaimsIdentityBuilder | The same MyTested.AspNetCore.Mvc.Builders.Contracts.Authentication.IAndClaimsIdentityBuilder. |
InRoles(IEnumerable<String>)
Adds roles to the built System.Security.Claims.ClaimsIdentity.
Declaration
IAndClaimsIdentityBuilder 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.IAndClaimsIdentityBuilder | The same MyTested.AspNetCore.Mvc.Builders.Contracts.Authentication.IAndClaimsIdentityBuilder. |
InRoles(String[])
Adds roles to the built System.Security.Claims.ClaimsIdentity.
Declaration
IAndClaimsIdentityBuilder 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.IAndClaimsIdentityBuilder | The same MyTested.AspNetCore.Mvc.Builders.Contracts.Authentication.IAndClaimsIdentityBuilder. |
WithAuthenticationType(String)
Adds authentication type to the built System.Security.Claims.ClaimsIdentity. If such is not provided, "Passport" is used by default.
Declaration
IAndClaimsIdentityBuilder WithAuthenticationType(string authenticationType)
Parameters
Type | Name | Description |
---|---|---|
System.String | authenticationType | Authentication type to add. |
Returns
Type | Description |
---|---|
MyTested.AspNetCore.Mvc.Builders.Contracts.Authentication.IAndClaimsIdentityBuilder | The same MyTested.AspNetCore.Mvc.Builders.Contracts.Authentication.IAndClaimsIdentityBuilder. |
WithClaim(Claim)
Adds claim to the built System.Security.Claims.ClaimsIdentity.
Declaration
IAndClaimsIdentityBuilder 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.IAndClaimsIdentityBuilder | The same MyTested.AspNetCore.Mvc.Builders.Contracts.Authentication.IAndClaimsIdentityBuilder. |
WithClaim(String, String)
Adds claim to the built System.Security.Claims.ClaimsIdentity.
Declaration
IAndClaimsIdentityBuilder 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.IAndClaimsIdentityBuilder | The same MyTested.AspNetCore.Mvc.Builders.Contracts.Authentication.IAndClaimsIdentityBuilder. |
WithClaims(IEnumerable<Claim>)
Adds claims to the built System.Security.Claims.ClaimsIdentity.
Declaration
IAndClaimsIdentityBuilder 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.IAndClaimsIdentityBuilder | The same MyTested.AspNetCore.Mvc.Builders.Contracts.Authentication.IAndClaimsIdentityBuilder. |
WithClaims(Claim[])
Adds claims to the built System.Security.Claims.ClaimsIdentity.
Declaration
IAndClaimsIdentityBuilder 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.IAndClaimsIdentityBuilder | The same MyTested.AspNetCore.Mvc.Builders.Contracts.Authentication.IAndClaimsIdentityBuilder. |
WithIdentifier(String)
Sets identifier claim to the built System.Security.Claims.ClaimsIdentity. If such is not provided, "TestId" is used by default.
Declaration
IAndClaimsIdentityBuilder 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.IAndClaimsIdentityBuilder | The same MyTested.AspNetCore.Mvc.Builders.Contracts.Authentication.IAndClaimsIdentityBuilder. |
WithNameType(String)
Sets type of the username claim. Default is System.Security.Claims.ClaimTypes.Name.
Declaration
IAndClaimsIdentityBuilder 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.IAndClaimsIdentityBuilder | The same MyTested.AspNetCore.Mvc.Builders.Contracts.Authentication.IAndClaimsIdentityBuilder. |
WithRoleType(String)
Sets type of the role claim. Default is System.Security.Claims.ClaimTypes.Role.
Declaration
IAndClaimsIdentityBuilder 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.IAndClaimsIdentityBuilder | The same MyTested.AspNetCore.Mvc.Builders.Contracts.Authentication.IAndClaimsIdentityBuilder. |
WithUsername(String)
Sets username claims to the built System.Security.Claims.ClaimsIdentity. If such is not provided, "TestUser" is used by default.
Declaration
IAndClaimsIdentityBuilder 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.IAndClaimsIdentityBuilder | The same MyTested.AspNetCore.Mvc.Builders.Contracts.Authentication.IAndClaimsIdentityBuilder. |