Пример #1
0
        protected override void EstablishContext()
        {
            providedStaffImage = staffAreaLinksFake.Image(providedSchoolId, providedStaffUSI1, providedStaffGender);
            providedThumbnail = staffAreaLinksFake.ProfileThumbnail(providedSchoolId, providedStaffUSI1, providedStaffGender);

            staffCohortRepository = mocks.StrictMock<IRepository<StaffCohort>>();
            Expect.Call(staffCohortRepository.GetAll()).Repeat.Any().Return(GetStaffCohort());

            staffCustomStudentListRepository = mocks.StrictMock<IRepository<StaffCustomStudentList>>();
            Expect.Call(staffCustomStudentListRepository.GetAll()).Return(GetStaffCustomStudentList());

            staffInfoRepository = mocks.StrictMock<IRepository<StaffInformation>>();
            Expect.Call(staffInfoRepository.GetAll()).Return(GetStaffInformation());

            teacherSectionRepository = mocks.StrictMock<IRepository<TeacherSection>>();
            Expect.Call(teacherSectionRepository.GetAll()).Repeat.Any().Return(GetTeacherSection());
            
            schoolInformationRepository = mocks.StrictMock<IRepository<SchoolInformation>>();
            Expect.Call(schoolInformationRepository.GetAll()).Repeat.Any().Return(GetSchoolInformation());

            WatchListRepository = mocks.StrictMock<IRepository<MetricBasedWatchList>>();
            Expect.Call(WatchListRepository.GetAll()).Repeat.Any().Return(GetWatchListInformation());

            WatchListOptionRepository = mocks.StrictMock<IRepository<MetricBasedWatchListOption>>();
            Expect.Call(WatchListOptionRepository.GetAll()).Repeat.Any().Return(GetWatchListOptionInformation());

            currentUserClaimInterrogator = mocks.StrictMock<ICurrentUserClaimInterrogator>();
            Expect.Call(currentUserClaimInterrogator.HasClaimWithinEducationOrganizationHierarchy(String.Empty, 0)).
                IgnoreArguments().Repeat.Any().Return(true);

            watchListLinkProvider = mocks.StrictMock<IWatchListLinkProvider>();
            Expect.Call(watchListLinkProvider.GenerateLink(null)).
                IgnoreArguments().Repeat.Any().Return("http://testlink");

            LoginUser(providedUserInformation);

            base.EstablishContext();
        }
Пример #2
0
        protected override void EstablishContext()
        {
            providedStaffUSI = providedStaffUSI1;
            providedUserName = "******";
            providedUserInformation = new UserInformation
            {
                StaffUSI = providedStaffUSI,
                FullName = providedFullName,
                AssociatedOrganizations = new List<UserInformation.EducationOrganization>
                                                                            {
                                                                                new UserInformation.School(providedLocalEducationAgencyId, providedSchoolId)
                                                                                { 
                                                                                    Name = providedSchoolName, 
                                                                                },
                                                                                new UserInformation.School(providedLocalEducationAgencyId, providedSchoolId + 1)
                                                                                { 
                                                                                    Name = providedSchoolName1,
                                                                                },
                                                                                new UserInformation.School(providedLocalEducationAgencyId, providedSchoolId + 2)
                                                                                { 
                                                                                    Name = providedSchoolName2,
                                                                                },
                                                                                new UserInformation.School(providedLocalEducationAgencyId, providedSchoolId + 3)
                                                                                { 
                                                                                    Name = providedSchoolName3,
                                                                                },
                                                                            }
            };

            suppliedViewType = StaffModel.ViewType.SubjectSpecificOverview.ToString();

            staffCohortRepository = mocks.StrictMock<IRepository<StaffCohort>>();
            Expect.Call(staffCohortRepository.GetAll()).Return(GetStaffCohort());
            
            staffInfoRepository = mocks.StrictMock<IRepository<StaffInformation>>();
            Expect.Call(staffInfoRepository.GetAll()).Return(GetStaffInformation());

            teacherSectionRepository = mocks.StrictMock<IRepository<TeacherSection>>();
            Expect.Call(teacherSectionRepository.GetAll()).Repeat.Any().Return(GetTeacherSection());

            schoolInformationRepository = mocks.StrictMock<IRepository<SchoolInformation>>();
            Expect.Call(schoolInformationRepository.GetAll()).Repeat.Any().Return(GetSchoolInformation());

            WatchListRepository = mocks.StrictMock<IRepository<MetricBasedWatchList>>();
            Expect.Call(WatchListRepository.GetAll()).Repeat.Any().Return(GetWatchListInformation());

            WatchListOptionRepository = mocks.StrictMock<IRepository<MetricBasedWatchListOption>>();
            Expect.Call(WatchListOptionRepository.GetAll()).Repeat.Any().Return(GetWatchListOptionInformation());

            currentUserClaimInterrogator = mocks.StrictMock<ICurrentUserClaimInterrogator>();
            Expect.Call(currentUserClaimInterrogator.HasClaimWithinEducationOrganizationHierarchy(String.Empty, 0)).
                IgnoreArguments().Repeat.Any().Return(true);

            LoginUser(providedUserInformation);

            base.EstablishContext();
        }
Пример #3
0
        protected override void EstablishContext()
        {
            metricActionUrlAuthService = mocks.StrictMock<IMetricActionUrlAuthorizationProvider>();
            configSectionProvider = mocks.StrictMock<IConfigSectionProvider>();
            currentUserClaimInterrogator = mocks.StrictMock<ICurrentUserClaimInterrogator>();
            windsorContainer = new WindsorContainer();
            RegisterServices(windsorContainer);
            LoginHelper.LoginSuperintendent();
            int lea =
                LoginHelper.userInfoSuperintendent.AssociatedLocalEducationAgencies.Single().EducationOrganizationId;
            CreateEdFiDashboardContext(lea,null);

            foreach (var associatedOrganizations in LoginHelper.userInfoSuperintendent.AssociatedOrganizations)
            {
                foreach (var claimType in associatedOrganizations.ClaimTypes)
                {
                    Expect.Call(currentUserClaimInterrogator.HasClaimWithinEducationOrganizationHierarchy(claimType,associatedOrganizations.EducationOrganizationId)).Repeat.Any().Return(true);
                    Expect.Call(currentUserClaimInterrogator.HasClaimForLocalEducationAgencyWithinEducationOrganizationHierarchy(claimType, associatedOrganizations.EducationOrganizationId)).Repeat.Any().Return(true);
                    if (claimType == EdFiClaimTypes.ViewAllMetrics)
                    {
                        Expect.Call(currentUserClaimInterrogator.HasClaimForMetricWithinEducationOrganizationHierarchy(0, 0)).Repeat.Any().Constraints(Rhino.Mocks.Constraints.Is.TypeOf<int>(), Rhino.Mocks.Constraints.Is.Equal(associatedOrganizations.EducationOrganizationId)).Return(true);
                    }
                }
            }

            

            //Test is focusing on this!!! The logic to add or filter/remove actions
            Expect.Call(metricActionUrlAuthService.CurrentUserHasAccessToPath("~/aaa.aspx",lea)).Return(true);
            Expect.Call(metricActionUrlAuthService.CurrentUserHasAccessToPath("~/bbb.aspx",lea)).Return(false);
        }
Пример #4
0
        protected override void EstablishContext()
        {
            canAccessSchool = true;
            metricActionUrlAuthService = mocks.StrictMock<IMetricActionUrlAuthorizationProvider>();
            Expect.Call(metricActionUrlAuthService.CurrentUserHasAccessToPath(String.Empty,0)).Repeat.Any().IgnoreArguments().Return(true);

            currentUserClaimInterrogator = mocks.StrictMock<ICurrentUserClaimInterrogator>();

            var userAssociatedOrgs = UserInformation.Current.AssociatedSchools;
            foreach (var associatedOrg in userAssociatedOrgs)
            {
                foreach (var claimType in associatedOrg.ClaimTypes)
                {
                    Expect.Call(currentUserClaimInterrogator.HasClaimWithinEducationOrganizationHierarchy(claimType, associatedOrg.EducationOrganizationId
                                                                                                          )).Repeat.Any().Return(true);
                    Expect.Call(currentUserClaimInterrogator.HasClaimForLocalEducationAgencyWithinEducationOrganizationHierarchy(claimType, associatedOrg.EducationOrganizationId)).Repeat.Any().Return(false);
                    
                    if (claimType == EdFiClaimTypes.ViewAllMetrics)
                    {
                        Expect.Call(currentUserClaimInterrogator.HasClaimForMetricWithinEducationOrganizationHierarchy(0, 0)).Repeat.Any().Constraints(Rhino.Mocks.Constraints.Is.TypeOf<int>(), Rhino.Mocks.Constraints.Is.Equal(associatedOrg.EducationOrganizationId)).Return(true);
                    }
                    else if (claimType == EdFiClaimTypes.ViewMyMetrics)
                    {
                        Expect.Call(currentUserClaimInterrogator.HasClaimForMetricWithinEducationOrganizationHierarchy(0, 0)).Repeat.Any().Constraints(Rhino.Mocks.Constraints.Is.TypeOf<int>() && !Rhino.Mocks.Constraints.Is.Equal((int)SchoolMetricEnum.OperationsDashboard), Rhino.Mocks.Constraints.Is.Equal(associatedOrg.EducationOrganizationId)).Return(true);
                    }
                }
            }
            var userAssociatedLeaOrgs = UserInformation.Current.AssociatedLocalEducationAgencies;
            foreach (var associatedOrg in userAssociatedLeaOrgs)
            {
                foreach (var claimType in associatedOrg.ClaimTypes)
                {
                    Expect.Call(currentUserClaimInterrogator.HasClaimWithinEducationOrganizationHierarchy(claimType, associatedOrg.EducationOrganizationId
                                                                                                          )).Repeat.Any().Return(true);
                    Expect.Call(currentUserClaimInterrogator.HasClaimForLocalEducationAgencyWithinEducationOrganizationHierarchy(claimType, associatedOrg.EducationOrganizationId)).Repeat.Any().Return(true);

                    if (claimType == EdFiClaimTypes.ViewAllMetrics)
                    {
                        Expect.Call(currentUserClaimInterrogator.HasClaimForMetricWithinEducationOrganizationHierarchy(0, 0)).Repeat.Any().Constraints(Rhino.Mocks.Constraints.Is.TypeOf<int>(), Rhino.Mocks.Constraints.Is.TypeOf<int>()).Return(true); 
                    }
                    else if (claimType == EdFiClaimTypes.ViewMyMetrics)
                    {
                        Expect.Call(currentUserClaimInterrogator.HasClaimForMetricWithinEducationOrganizationHierarchy(0, 0)).Repeat.Any().Constraints(Rhino.Mocks.Constraints.Is.TypeOf<int>() && !Rhino.Mocks.Constraints.Is.Equal((int)LocalEducationAgencyMetricEnum.OperationsDashboard), Rhino.Mocks.Constraints.Is.Equal(associatedOrg.EducationOrganizationId)).Return(true); 
                    }
                }
            }

            if (!userAssociatedLeaOrgs.Any(o => o.ClaimTypes.Any(t => t == EdFiClaimTypes.ViewAllMetrics)))
            {
                Expect.Call(currentUserClaimInterrogator.HasClaimForLocalEducationAgencyWithinEducationOrganizationHierarchy(EdFiClaimTypes.ViewAllMetrics, 0)).Repeat.Any().Return(false).IgnoreArguments();
                Expect.Call(currentUserClaimInterrogator.HasClaimForMetricWithinEducationOrganizationHierarchy(0, 0)).Repeat.Any().Constraints(Rhino.Mocks.Constraints.Is.TypeOf<int>(), Rhino.Mocks.Constraints.Is.TypeOf<int>()).Return(false);
            }
            Expect.Call(currentUserClaimInterrogator.HasClaimForStateAgency(string.Empty)).Repeat.Any().Return(false).IgnoreArguments();
            
            windsorContainer = new WindsorContainer();
            RegisterServices(windsorContainer);

            CreateEdFiDashboardContext(LoginHelper.localEducationAgencyOneId, LoginHelper.schoolOneId);

            base.EstablishContext();
        }
Пример #5
0
        protected override void EstablishContext()
        {
            windsorContainer = new WindsorContainer();
            authorizationInformationProvider = mocks.StrictMock<IAuthorizationInformationProvider>();
            sessionStateProvider = mocks.StrictMock<ISessionStateProvider>();
            currentUserClaimInterrogator = mocks.StrictMock<ICurrentUserClaimInterrogator>();
            currentUserAccessibleStudentsProvider = mocks.StrictMock<ICurrentUserAccessibleStudentsProvider>();
            RegisterServices(windsorContainer);
            var userAssociatedOrgs = UserInformation.Current.AssociatedSchools;
            foreach(var associatedOrg in userAssociatedOrgs)
            {
                foreach(var claimType in associatedOrg.ClaimTypes)
                {
                    Expect.Call(currentUserClaimInterrogator.HasClaimWithinEducationOrganizationHierarchy(claimType,associatedOrg.EducationOrganizationId
                                                                                                          )).Repeat.Any().Return(true);
                }
            }
            var userAssociatedLeaOrgs = UserInformation.Current.AssociatedLocalEducationAgencies;
            foreach (var associatedOrg in userAssociatedLeaOrgs)
            {
                foreach (var claimType in associatedOrg.ClaimTypes)
                {
                    Expect.Call(currentUserClaimInterrogator.HasClaimWithinEducationOrganizationHierarchy(claimType, associatedOrg.EducationOrganizationId
                                                                                                          )).Repeat.Any().Return(true);
                }
            }
            Expect.Call(currentUserClaimInterrogator.HasClaimForStateAgency(string.Empty)).Repeat.Any().Return(false).IgnoreArguments();
            
            CreateEdFiDashboardContext(LoginHelper.localEducationAgencyOneId);

            if (registerAccessibleStudentsInBase)
                Expect.Call(currentUserAccessibleStudentsProvider.GetAccessibleStudents(1, false)).IgnoreArguments().Repeat.
                    Any().Return(new AccessibleStudents { CanAccessAllStudents = false, StudentUSIs = GetAllStaffStudents() });

            //Expect.Call(authorizationInformationProvider.GetAllStaffStudentUSIs(providedStaffUSI)).Repeat.Any().Return(GetAllStaffStudents());

            //Expect.Call(authorizationInformationProvider.GetPrincipalStudentUSIs(providedStaffUSI)).Repeat.Any().Return(GetPrincipalStudents());
            //Expect.Call(authorizationInformationProvider.GetStaffCohortStudentUSIs(providedStaffUSI)).Repeat.Any().Return(GetCohortStudents());
            //Expect.Call(authorizationInformationProvider.GetTeacherStudentUSIs(providedStaffUSI)).Repeat.Any().Return(GetTeacherStudents());

            base.EstablishContext();
        }