示例#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 AddAatfRequestHandler(authorization, dataAccess, addressMapper, contactMapper, commonDataAccess);

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

            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 AddAatfRequestHandler(authorization, this.dataAccess, addressMapper, contactMapper, commonDataAccess);

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

            await Assert.ThrowsAsync <SecurityException>(action);
        }
示例#3
0
        public async Task HandleAsync_WithNoLocalArea_LocalAreaIsNull(Core.AatfReturn.FacilityType facilityType)
        {
            var aatf = new AatfData(Guid.NewGuid(), "name", "approval number", 2019, A.Dummy <Core.Shared.UKCompetentAuthorityData>(),
                                    Core.AatfReturn.AatfStatus.Approved, A.Dummy <AatfAddressData>(), Core.AatfReturn.AatfSize.Large, DateTime.Now,
                                    A.Dummy <Core.Shared.PanAreaData>(), null)
            {
                FacilityType = facilityType
            };

            var aatfId = Guid.NewGuid();

            var request = new AddAatf()
            {
                Aatf           = aatf,
                AatfContact    = A.Dummy <AatfContactData>(),
                OrganisationId = Guid.NewGuid()
            };

            var result = await handler.HandleAsync(request);

            A.CallTo(() => commonDataAccess.FetchLookup <LocalArea>(A <Guid> ._)).MustNotHaveHappened();
        }