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); }
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")); }
public override void SetUp() { base.SetUp(); // Arrange _denyAuthenticatedAccessPolicy = new DenyAuthenticatedAccessPolicy(); _denyAnonymousAccessPolicy = new DenyAnonymousAccessPolicy(); _policies = new List<ISecurityPolicy> { _denyAnonymousAccessPolicy }; }
protected override void Context() { // Arrange _denyAuthenticatedAccessPolicy = new DenyAuthenticatedAccessPolicy(); _denyAnonymousAccessPolicy = new DenyAnonymousAccessPolicy(); Policies = new List<ISecurityPolicy> { _denyAnonymousAccessPolicy }; }