private void EditPanel_LoadedPage(EditPanel sender, LoadedPageEventArgs e) { var currentUser = HttpContext.Current.User; if (currentUser == null) return; PageData typedPage = PageTypeBuilder.PageTypeResolver.Instance.ConvertToTyped(e.Page); Type typedPageType = PageTypeBuilder.PageTypeResolver.Instance.GetPageTypeType(e.Page.PageTypeID); if (typedPageType == null) return; var locator = new AuthorizedPropertyDefinitionLocator(typedPage, typedPageType, new TabDefinitionRepository()); List<AuthorizedPropertyDefinition> definitions = locator.GetAuthorizedPropertyDefinitions(); foreach (var definition in definitions) { if (e.Page.Property[definition.PropertyName] == null) continue; e.Page.Property[definition.PropertyName].DisplayEditUI = currentUser.IsInAnyRoleOrUserList(definition.AuthorizedPrincipals); } foreach (var property in e.Page.Property) { if (property.DisplayEditUI) Debug.WriteLine(property.Name); } }
public void Located_PropertyAttribute_Should_Override_Class_Attribute() { _locator = new AuthorizedPropertyDefinitionLocator(_inheritedLevel, _inheritedLevel.GetType(), new FakeTabDefinitionRepository()); var actualDefinitionList = _locator.GetAuthorizedPropertyDefinitions(); var propertyThreeDefinition = actualDefinitionList.Single(d => d.PropertyName == "Property3"); Assert.IsTrue(propertyThreeDefinition.AuthorizedPrincipals.Contains("Role2")); }
public void Locator_Should_Discover_Two_Definitions_From_TabAuthorizedTypedPageData() { var typedPageData = new TabAuthorizedTypedPageData(); TabDefinitionCollection tabDefinitions = new FakeTabDefinitionRepository().List(); typedPageData.Property.Add(new PropertyString { Name = "PageName", OwnerTab = tabDefinitions.First(t => t.Name == "MetaData").ID }); SetupTabBasedPropertiesAndPropertyGroupPageDataProperties(typedPageData); _locator = new AuthorizedPropertyDefinitionLocator(typedPageData, typedPageData.GetType(), new FakeTabDefinitionRepository()); var actualDefinitionList = _locator.GetAuthorizedPropertyDefinitions(); Assert.IsTrue(actualDefinitionList.Count == 2); //This is testing differnet functionality - should be a different test //var propertyOneDefinition = actualDefinitionList.Single(d => d.PropertyName == "Property1"); //Assert.IsTrue(propertyOneDefinition.AuthorizedPrincipals.Contains("Role1")); //This is testing differnet functionality - should be a different test //var pageCategoryDefinition = actualDefinitionList.Single(d => d.PropertyName == "PageName"); //Assert.IsTrue(pageCategoryDefinition.AuthorizedPrincipals.Contains("Role2")); }
public void Locater_Should_Discover_DefaultProperties_If_From_DefaultAuthorizedPageData() { _locator = new AuthorizedPropertyDefinitionLocator(_defaultLevel, _defaultLevel.GetType(), new FakeTabDefinitionRepository()); var actualDefinitionList = _locator.GetAuthorizedPropertyDefinitions(); Assert.IsTrue(actualDefinitionList.Count == 1); }
public void Locator_Should_Discover_Six_Definitions_From_InheritedAuthorizedTypedPageData() { _locator = new AuthorizedPropertyDefinitionLocator(_inheritedLevel, _inheritedLevel.GetType(), new FakeTabDefinitionRepository()); var actualDefinitionList = _locator.GetAuthorizedPropertyDefinitions(); Assert.IsTrue(actualDefinitionList.Count == 6); }
public void Locator_Should_Discover_Two_Definitions_From_ClassAuthorizedFakeTypedPageData() { _locator = new AuthorizedPropertyDefinitionLocator(_classLevel, _classLevel.GetType(), new FakeTabDefinitionRepository()); var actualDefinitionList = _locator.GetAuthorizedPropertyDefinitions(); Assert.IsTrue(actualDefinitionList.Count == 2); }
public void Locator_Should_Not_Discover_Definitions_From_NonAuthorizedTypedPageData() { _locator = new AuthorizedPropertyDefinitionLocator(_noLevel, _noLevel.GetType(), new FakeTabDefinitionRepository()); var actualDefinitionList = _locator.GetAuthorizedPropertyDefinitions(); Assert.IsTrue(!actualDefinitionList.Any()); }
public void Locator_Should_Discover_One_Definition_From_PropertyGroupWithTabAuthorizationAuthorizedTypedPageData() { PropertyGroupWithTabAuthorizationAuthorizedTypedPageData typedPageData = new PropertyGroupWithTabAuthorizationAuthorizedTypedPageData(); SetupTabBasedPropertiesAndPropertyGroupPageDataProperties(typedPageData); _locator = new AuthorizedPropertyDefinitionLocator(typedPageData, typedPageData.GetType(), new FakeTabDefinitionRepository()); var actualDefinitionList = _locator.GetAuthorizedPropertyDefinitions(); Assert.IsTrue(actualDefinitionList.Count == 1); var propertyOneDefinition = actualDefinitionList.Single(d => d.PropertyName == "PropertyGroup1-Property1"); Assert.IsTrue(propertyOneDefinition.AuthorizedPrincipals.Contains("Role1")); }
public void Should_Find_Definition_From_Tab_For_ClassPropertyAndTabDefinitionTypedPageData() { var typedPageData = new ClassPropertyAndTabDefinitionTypedPageData(); SetupTabBasedPropertiesAndPropertyGroupPageDataProperties(typedPageData); _locator = new AuthorizedPropertyDefinitionLocator(typedPageData, typedPageData.GetType(), new FakeTabDefinitionRepository()); var actualDefinitionList = _locator.GetAuthorizedPropertyDefinitions(); Assert.IsTrue(actualDefinitionList.First().AuthorizedPrincipals.Contains("Role5")); }
public void Locator_Should_Discover_One_Definition_From_ClassPropertyGroupAndTabDefinitionTypedPageData() { var typedPageData = new ClassPropertyGroupAndTabDefinitionTypedPageData(); SetupTabBasedPropertiesAndPropertyGroupPageDataProperties(typedPageData); _locator = new AuthorizedPropertyDefinitionLocator(typedPageData, typedPageData.GetType(), new FakeTabDefinitionRepository()); var actualDefinitionList = _locator.GetAuthorizedPropertyDefinitions(); Assert.IsTrue(actualDefinitionList.Count == 1); }