예제 #1
0
        public void Test_AccessGranted()
        {
            _testHelper.ReplayAll();

            bool hasAccess = _securityClient.HasPropertyReadAccess(_testHelper.SecurableObject, "IsVisible");

            _testHelper.VerifyAll();
            Assert.That(hasAccess, Is.True);
        }
        public void Test_AccessGranted()
        {
            _testHelper.ExpectPermissionReflectorGetRequiredMethodPermissions(_methodInformation, TestAccessTypes.First);
            _testHelper.ExpectObjectSecurityStrategyHasAccess(TestAccessTypes.First, true);
            _testHelper.ReplayAll();

            bool hasAccess = _securityClient.HasPropertyReadAccess(_testHelper.SecurableObject, _methodInformation);

            _testHelper.VerifyAll();
            Assert.That(hasAccess, Is.True);
        }
        public bool CanRead(IBusinessObject businessObject, PropertyBase bindableProperty)
        {
            // businessObject can be null
            ArgumentUtility.DebugCheckNotNull("bindableProperty", bindableProperty);

            var securableObject = businessObject as ISecurableObject;

            if (securableObject == null)
            {
                return(true);
            }

            var getter = bindableProperty.PropertyInfo.GetGetMethod(true) ?? s_nullMethodInformation;

            return(_securityClient.HasPropertyReadAccess(securableObject, getter));
        }
        public void HasAccess_Property()
        {
            var securityContextStub        = MockRepository.GenerateStub <ISecurityContext>();
            var securityContextFactoryStub = MockRepository.GenerateStub <ISecurityContextFactory>();

            securityContextFactoryStub.Stub(mock => mock.CreateSecurityContext()).Return(securityContextStub);
            _securityProviderStub
            .Stub(mock => mock.GetAccess(securityContextStub, _securityPrincipalStub))
            .Return(new[] { AccessType.Get(GeneralAccessTypes.Read) });

            ISecurableObject securableObject = new SecurableObject(
                ObjectSecurityStrategy.Create(securityContextFactoryStub, InvalidationToken.Create()));

            var hasMethodAccess = _securityClient.HasPropertyReadAccess(securableObject, "IsVisible");

            Assert.That(hasMethodAccess, Is.True);
        }