Class BunitAuthorizationContext
- Namespace
- Bunit.TestDoubles
- Assembly
- bunit.dll
Root authorization service that manages different authentication/authorization state in the system.
public class BunitAuthorizationContext
- Inheritance
-
BunitAuthorizationContext
- Inherited Members
- Extension Methods
Properties
Claims
Gets the set of principal claims for the current user.
public IEnumerable<Claim> Claims { get; }
Property Value
IsAuthenticated
Gets a value indicating whether user is authenticated.
public bool IsAuthenticated { get; }
Property Value
Policies
Gets the set of authentication policies for the current user.
public IEnumerable<string> Policies { get; }
Property Value
PolicySchemeName
Gets or sets the policy schemeName. Defaults to TestScheme and usually doesn't need to be changed by user.
public string PolicySchemeName { get; set; }
Property Value
Roles
Gets the set of roles for the current user.
public IEnumerable<string> Roles { get; }
Property Value
State
Gets the authorization state for the user.
public AuthorizationState State { get; }
Property Value
UserName
Gets the authorization context user name.
public string UserName { get; }
Property Value
Methods
SetAuthenticationType(string)
Sets the Identity.AuthenticationType for the current user/principa;.
public BunitAuthorizationContext SetAuthenticationType(string authenticationType)
Parameters
authenticationTypestringThe authentication type to set.
Returns
SetAuthorized(string, AuthorizationState)
Authenticates the user with specified name and authorization state.
public BunitAuthorizationContext SetAuthorized(string userName, AuthorizationState state = AuthorizationState.Authorized)
Parameters
userNamestringUser name for the principal identity.
stateAuthorizationStateAuthorization state.
Returns
SetAuthorizing()
Puts the authorization services into the authorizing state.
public BunitAuthorizationContext SetAuthorizing()
Returns
SetClaims(params Claim[])
Sets the claims on the current user/principal.
public BunitAuthorizationContext SetClaims(params Claim[] claims)
Parameters
claimsClaim[]Claims to set.
Returns
SetNotAuthorized()
Puts the authorization services into an unauthenticated and unauthorized state.
public BunitAuthorizationContext SetNotAuthorized()
Returns
SetPolicies(params string[])
Sets the authorization policies supported for the current user.
public BunitAuthorizationContext SetPolicies(params string[] policies)
Parameters
policiesstring[]Supported authorization policies.
Returns
SetRoles(params string[])
Sets the user roles in this context..
public BunitAuthorizationContext SetRoles(params string[] roles)
Parameters
rolesstring[]Roles for the claims principal.