コード例 #1
0
        public void GivenUserHasNoRoles_WhenGrantAccess_ThenThrowException()
        {
            ManageServiceRequestPermission target = new ManageServiceRequestPermission(new ServiceRequest());
            EducationSecurityPrincipal     user   = CreateUserWithNoRoles();

            target.ExpectException <EntityAccessUnauthorizedException>(() => target.GrantAccess(user));
        }
コード例 #2
0
        public void GivenUserIsNotDataAdmin_AndDidntCreateRequest_AndServiceTypeIsntPrivate_AndUserAssociatedWithApprovedProviders_AndProvidersNotAssociatedWithStudentAssignedOfferings_WhenGrantAccess_ThenThrowException()
        {
            ManageServiceRequestPermission target = new ManageServiceRequestPermission(new ServiceRequest
            {
                CreatingUserId = 2,
                ServiceType    = new ServiceType
                {
                    IsPrivate = false
                },
                Student = new Student
                {
                    School = new School {
                        UserRoles = new List <UserRole>()
                    },
                    ApprovedProviders = new List <Provider> {
                        Data.Providers[0]
                    },
                    StudentAssignedOfferings = new List <StudentAssignedOffering>
                    {
                        new StudentAssignedOffering()
                        {
                            ServiceOffering = new ServiceOffering {
                                Provider = new Provider()
                            }
                        }
                    }
                }
            });
            EducationSecurityPrincipal user = CreateProviderUser(new List <Provider> {
                Data.Providers[0]
            });

            target.ExpectException <EntityAccessUnauthorizedException>(() => target.GrantAccess(user));
        }
        public void GivenUserHasNoRoles_WhenGrantAccess_ThenThrowException()
        {
            ManageServiceRequestPermission target = new ManageServiceRequestPermission(new ServiceRequest());
            EducationSecurityPrincipal user = CreateUserWithNoRoles();

            target.ExpectException<EntityAccessUnauthorizedException>(() => target.GrantAccess(user));
        }
コード例 #4
0
        public void GivenUserIsNotDataAdmin_AndDidntCreateRequest_AndServiceTypeIsPrivate_ThenThrowException()
        {
            ManageServiceRequestPermission target = new ManageServiceRequestPermission(new ServiceRequest
            {
                CreatingUserId = 1,
                ServiceType    = new ServiceType {
                    IsPrivate = true
                },
                Student = new Student()
            });
            EducationSecurityPrincipal user = CreateSiteCoordinatorUser(new List <School>());

            user.Identity.User.Id = 2;

            target.ExpectException <EntityAccessUnauthorizedException>(() => target.GrantAccess(user));
        }
コード例 #5
0
        public void GivenUserRoleIsUnknown_WhenGrantAccess_ThenThrowException()
        {
            ManageServiceRequestPermission target = new ManageServiceRequestPermission(new ServiceRequest
            {
                CreatingUserId = 2,
                ServiceType    = new ServiceType
                {
                    IsPrivate = false
                },
                Student = new Student
                {
                    School = new School {
                        UserRoles = new List <UserRole>()
                    },
                    ApprovedProviders = new List <Provider>()
                }
            });
            EducationSecurityPrincipal user = CreateUserWithUnknownRole();

            target.ExpectException <EntityAccessUnauthorizedException>(() => target.GrantAccess(user));
        }
        public void GivenUserIsNotDataAdmin_AndDidntCreateRequest_AndServiceTypeIsntPrivate_AndUserAssociatedWithApprovedProviders_AndProvidersAssociatedWithStudentAssignedOfferingsThatArentActive_WhenGrantAccess_ThenThrowException()
        {
            ManageServiceRequestPermission target = new ManageServiceRequestPermission(new ServiceRequest
            {
                CreatingUserId = 2,
                ServiceType = new ServiceType
                {
                    IsPrivate = false
                },
                Student = new Student
                {
                    School = new School { UserRoles = new List<UserRole>() },
                    ApprovedProviders = new List<Provider> { Data.Providers[0] },
                    StudentAssignedOfferings = new List<StudentAssignedOffering>
                    {
                        new StudentAssignedOffering()
                        {
                            IsActive = false,
                            ServiceOffering = new ServiceOffering{ Provider = Data.Providers[0] }
                        }
                    }
                }
            });
            EducationSecurityPrincipal user = CreateProviderUser(new List<Provider> { Data.Providers[0] });

            target.ExpectException<EntityAccessUnauthorizedException>(() => target.GrantAccess(user));
        }
        public void GivenUserRoleIsUnknown_WhenGrantAccess_ThenThrowException()
        {
            ManageServiceRequestPermission target = new ManageServiceRequestPermission(new ServiceRequest
            {
                CreatingUserId = 2,
                ServiceType = new ServiceType
                {
                    IsPrivate = false
                },
                Student = new Student
                {
                    School = new School { UserRoles = new List<UserRole>() },
                    ApprovedProviders = new List<Provider>()
                }
            });
            EducationSecurityPrincipal user = CreateUserWithUnknownRole();

            target.ExpectException<EntityAccessUnauthorizedException>(() => target.GrantAccess(user));
        }
        public void GivenUserIsNotDataAdmin_AndDidntCreateRequest_AndServiceTypeIsPrivate_ThenThrowException()
        {
            ManageServiceRequestPermission target = new ManageServiceRequestPermission(new ServiceRequest
            {
                CreatingUserId = 1,
                ServiceType = new ServiceType { IsPrivate = true },
                Student = new Student()
            });
            EducationSecurityPrincipal user = CreateSiteCoordinatorUser(new List<School>());
            user.Identity.User.Id = 2;

            target.ExpectException<EntityAccessUnauthorizedException>(() => target.GrantAccess(user));
        }
        public void GivenUserIsNotDataAdmin_AndDidntCreateRequest_AndServiceTypeIsntPrivate_AndUserNotAssociatedToSchools_AndUserNotAssociatedToProviders_ThenThrowException()
        {
            ManageServiceRequestPermission target = new ManageServiceRequestPermission(new ServiceRequest
            {
                CreatingUserId = 2,
                ServiceType = new ServiceType
                {
                    IsPrivate = false
                },
                Student = new Student
                {
                    School = new School { UserRoles = new List<UserRole>() },
                    ApprovedProviders = new List<Provider>()
                }
            });
            EducationSecurityPrincipal user = CreateProviderUser(new List<Provider>());

            target.ExpectException<EntityAccessUnauthorizedException>(() => target.GrantAccess(user));
        }