コード例 #1
0
        public void Should_be_successful_when_the_user_is_anonymous()
        {
            // Arrange
            var policy = new DenyAuthenticatedAccessPolicy();
            const bool authenticated = false;
            var context = TestDataFactory.CreateSecurityContext(authenticated);

            // Act
            var result = policy.Enforce(context);

            // Assert
            Assert.That(result.ViolationOccured, Is.False);
        }
コード例 #2
0
        public void Should_not_be_successful_when_the_user_is_authenticated()
        {
            // Arrange
            var policy = new DenyAuthenticatedAccessPolicy();
            const bool authenticated = true;
            var context = TestDataFactory.CreateSecurityContext(authenticated);

            // Act
            var result = policy.Enforce(context);

            // Assert
            Assert.That(result.ViolationOccured, Is.True);
            Assert.That(result.Message, Is.EqualTo("Authenticated access denied"));
        }
コード例 #3
0
        public override void SetUp()
        {
            base.SetUp();

            // Arrange
            _denyAuthenticatedAccessPolicy = new DenyAuthenticatedAccessPolicy();
            _denyAnonymousAccessPolicy = new DenyAnonymousAccessPolicy();
            _policies = new List<ISecurityPolicy>
                {
                    _denyAnonymousAccessPolicy
                };
        }
コード例 #4
0
 protected override void Context()
 {
     // Arrange
     _denyAuthenticatedAccessPolicy = new DenyAuthenticatedAccessPolicy();
     _denyAnonymousAccessPolicy = new DenyAnonymousAccessPolicy();
     Policies = new List<ISecurityPolicy>
     {
         _denyAnonymousAccessPolicy
     };
 }