示例#1
0
        public async Task HandleAsync_WithNonInternalAccess_ThrowsSecurityException(AuthorizationBuilder.UserType userType)
        {
            var authorization = AuthorizationBuilder.CreateFromUserType(userType);
            var userManager   = A.Fake <UserManager <ApplicationUser> >();

            var handler = new DeleteAatfHandler(authorization,
                                                aatfDataAccess,
                                                organisationDataAccess,
                                                weeeContext,
                                                getAatfDeletionStatus);

            Func <Task> action = async() => await handler.HandleAsync(A.Dummy <DeleteAnAatf>());

            await Assert.ThrowsAsync <SecurityException>(action);
        }
示例#2
0
        public async Task HandleAsync_WithNonInternalAdminRole_ThrowsSecurityException()
        {
            var authorization = new AuthorizationBuilder()
                                .AllowInternalAreaAccess()
                                .DenyRole(Roles.InternalAdmin)
                                .Build();

            var userManager = A.Fake <UserManager <ApplicationUser> >();
            var handler     = new DeleteAatfHandler(authorization,
                                                    aatfDataAccess,
                                                    organisationDataAccess,
                                                    weeeContext,
                                                    getAatfDeletionStatus);

            Func <Task> action = async() => await handler.HandleAsync(A.Dummy <DeleteAnAatf>());

            await Assert.ThrowsAsync <SecurityException>(action);
        }