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