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(); }
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(); }