public async Task HandleAsync_WithNonInternalAccess_ThrowsSecurityException(AuthorizationBuilder.UserType userType) { IWeeeAuthorization authorization = AuthorizationBuilder.CreateFromUserType(userType); UserManager <ApplicationUser> userManager = A.Fake <UserManager <ApplicationUser> >(); CheckApprovalNumberIsUniqueHandler handler = new CheckApprovalNumberIsUniqueHandler(authorization, dataAccess); Func <Task> action = async() => await handler.HandleAsync(A.Dummy <CheckApprovalNumberIsUnique>()); await Assert.ThrowsAsync <SecurityException>(action); }
public async Task HandleAsync_WithNonInternalAdminRole_ThrowsSecurityException() { IWeeeAuthorization authorization = new AuthorizationBuilder() .AllowInternalAreaAccess() .DenyRole(Roles.InternalAdmin) .Build(); UserManager <ApplicationUser> userManager = A.Fake <UserManager <ApplicationUser> >(); CheckApprovalNumberIsUniqueHandler handler = new CheckApprovalNumberIsUniqueHandler(authorization, this.dataAccess); Func <Task> action = async() => await handler.HandleAsync(A.Dummy <CheckApprovalNumberIsUnique>()); await Assert.ThrowsAsync <SecurityException>(action); }
public CheckApprovalNumberIsUniqueHandlerTests() { dataAccess = A.Fake <IFetchAatfDataAccess>(); handler = new CheckApprovalNumberIsUniqueHandler(AuthorizationBuilder.CreateUserWithAllRights(), dataAccess); }