public override void SetUp() { base.SetUp(); _testHelper = new TestHelper(); _extension = new SecurityClientTransactionExtension(); _propertyInfo = typeof(SecurableObject).GetProperty("StringProperty"); _getMethodInformation = MethodInfoAdapter.Create(_propertyInfo.GetGetMethod()); _stringPropertyDefinition = PropertyDefinitionObjectMother.CreatePropertyDefinition(_propertyInfo); _testHelper.SetupSecurityIoCConfiguration(); }
public void Test_WithNonSecurableObject_DoesNotPerformSecurityCheck() { var propertyInfo = typeof(NonSecurableObject).GetProperty("StringProperty"); NonSecurableObject nonSecurableObject = _testHelper.CreateNonSecurableObject(); _testHelper.ReplayAll(); _extension.PropertyValueReading( _testHelper.Transaction, nonSecurableObject, PropertyDefinitionObjectMother.CreatePropertyDefinition(propertyInfo, typeof(NonSecurableObject)), ValueAccess.Current); _testHelper.VerifyAll(); }
public void Test_AccessDenied_WithMissingAccessor_ThrowsPermissionDeniedException() { var propertyInfo = typeof(SecurableObject).GetProperty("PropertyWithMissingGetAccessor"); SecurableObject securableObject = _testHelper.CreateSecurableObject(); _testHelper.ExpectPermissionReflectorGetRequiredMethodPermissions(new NullMethodInformation()); _testHelper.ExpectObjectSecurityStrategyHasAccess(securableObject, GeneralAccessTypes.Read, false); _testHelper.ReplayAll(); _extension.PropertyValueReading( _testHelper.Transaction, securableObject, PropertyDefinitionObjectMother.CreatePropertyDefinition(propertyInfo), ValueAccess.Current); }
public void Test_AccessDenied_WithNonPublicAccessor_ThrowsPermissionDeniedException() { var propertyInfo = typeof(SecurableObject).GetProperty("NonPublicPropertyWithCustomPermission", BindingFlags.NonPublic | BindingFlags.Instance); var getMethodInformation = MethodInfoAdapter.Create(propertyInfo.GetGetMethod(true)); SecurableObject securableObject = _testHelper.CreateSecurableObject(); _testHelper.ExpectPermissionReflectorGetRequiredMethodPermissions(getMethodInformation, TestAccessTypes.First); _testHelper.ExpectObjectSecurityStrategyHasAccess(securableObject, TestAccessTypes.First, false); _testHelper.ReplayAll(); _extension.PropertyValueReading( _testHelper.Transaction, securableObject, PropertyDefinitionObjectMother.CreatePropertyDefinition(propertyInfo), ValueAccess.Current); }
public void Test_AccessGranted_WithMissingAccessor_DowsNotThrow() { var propertyInfo = typeof(SecurableObject).GetProperty("PropertyWithMissingSetAccessor"); SecurableObject securableObject = _testHelper.CreateSecurableObject(); _testHelper.ExpectPermissionReflectorGetRequiredMethodPermissions(new NullMethodInformation()); _testHelper.ExpectObjectSecurityStrategyHasAccess(securableObject, GeneralAccessTypes.Edit, true); _testHelper.ReplayAll(); _extension.PropertyValueChanging( _testHelper.Transaction, securableObject, PropertyDefinitionObjectMother.CreatePropertyDefinition(propertyInfo), "old", "new"); _testHelper.VerifyAll(); }
public void Test_AccessGranted_WithNonPublicAccessor_DowsNotThrow() { var propertyInfo = typeof(SecurableObject).GetProperty("NonPublicPropertyWithCustomPermission", BindingFlags.NonPublic | BindingFlags.Instance); var setMethodInformation = MethodInfoAdapter.Create(propertyInfo.GetSetMethod(true)); SecurableObject securableObject = _testHelper.CreateSecurableObject(); _testHelper.ExpectPermissionReflectorGetRequiredMethodPermissions(setMethodInformation, TestAccessTypes.First); _testHelper.ExpectObjectSecurityStrategyHasAccess(securableObject, TestAccessTypes.First, true); _testHelper.ReplayAll(); _extension.PropertyValueChanging( _testHelper.Transaction, securableObject, PropertyDefinitionObjectMother.CreatePropertyDefinition(propertyInfo), "old", "new"); _testHelper.VerifyAll(); }