public void Authorize_Disabled() { // Arrange var httpRequest = Mocks.Create<HttpRequestBase>(); var httpContext = Mocks.Create<HttpContextBase>(); httpContext.Setup(c => c.Request).Returns(httpRequest.Object); Configuration.EditHelpConfiguration.Setup(c => c.IsDisabled).Returns(true); var authorizer = new EditAuthorizer(httpContext.Object, Configuration.Object); // Act var result = authorizer.Authorize(); // Assert Assert.That(result, Is.False, "Authorization should fail because editing is disabled."); Mocks.VerifyAll(); }
public void Authorize_Disabled() { // Arrange var httpRequest = Mocks.Create <HttpRequestBase>(); var httpContext = Mocks.Create <HttpContextBase>(); httpContext.Setup(c => c.Request).Returns(httpRequest.Object); Configuration.EditHelpConfiguration.Setup(c => c.IsDisabled).Returns(true); var authorizer = new EditAuthorizer(httpContext.Object, Configuration.Object); // Act var result = authorizer.Authorize(); // Assert Assert.That(result, Is.False, "Authorization should fail because editing is disabled."); Mocks.VerifyAll(); }
public void Authorize_Success() { // Arrange var httpRequest = Mocks.Create <HttpRequestBase>(); var httpContext = Mocks.Create <HttpContextBase>(); httpContext.Setup(c => c.Request).Returns(httpRequest.Object); Configuration.EditHelpConfiguration.Setup(c => c.IsDisabled).Returns(false); Configuration.EditHelpConfiguration.Setup(c => c.RequireAuthentication).Returns(false); Configuration.EditHelpConfiguration.Setup(c => c.RequireLocalConnection).Returns(false); var authorizer = new EditAuthorizer(httpContext.Object, Configuration.Object); // Act var result = authorizer.Authorize(); // Assert Assert.That(result, Is.True, "Authorization should succeed."); Mocks.VerifyAll(); }
public void Authorize_NotLocal() { // Arrange var httpRequest = Mocks.Create<HttpRequestBase>(); httpRequest.Setup(r => r.IsLocal).Returns(false); var httpContext = Mocks.Create<HttpContextBase>(); httpContext.Setup(c => c.Request).Returns(httpRequest.Object); Configuration.EditHelpConfiguration.Setup(c => c.IsDisabled).Returns(false); Configuration.EditHelpConfiguration.Setup(c => c.RequireAuthentication).Returns(false); Configuration.EditHelpConfiguration.Setup(c => c.RequireLocalConnection).Returns(true); var authorizer = new EditAuthorizer(httpContext.Object, Configuration.Object); // Act var result = authorizer.Authorize(); // Assert Assert.That(result, Is.False, "Authorization should fail because request is not local."); Mocks.VerifyAll(); }
public void Authorize_NotLocal() { // Arrange var httpRequest = Mocks.Create <HttpRequestBase>(); httpRequest.Setup(r => r.IsLocal).Returns(false); var httpContext = Mocks.Create <HttpContextBase>(); httpContext.Setup(c => c.Request).Returns(httpRequest.Object); Configuration.EditHelpConfiguration.Setup(c => c.IsDisabled).Returns(false); Configuration.EditHelpConfiguration.Setup(c => c.RequireAuthentication).Returns(false); Configuration.EditHelpConfiguration.Setup(c => c.RequireLocalConnection).Returns(true); var authorizer = new EditAuthorizer(httpContext.Object, Configuration.Object); // Act var result = authorizer.Authorize(); // Assert Assert.That(result, Is.False, "Authorization should fail because request is not local."); Mocks.VerifyAll(); }
public void Authorize_Success() { // Arrange var httpRequest = Mocks.Create<HttpRequestBase>(); var httpContext = Mocks.Create<HttpContextBase>(); httpContext.Setup(c => c.Request).Returns(httpRequest.Object); Configuration.EditHelpConfiguration.Setup(c => c.IsDisabled).Returns(false); Configuration.EditHelpConfiguration.Setup(c => c.RequireAuthentication).Returns(false); Configuration.EditHelpConfiguration.Setup(c => c.RequireLocalConnection).Returns(false); var authorizer = new EditAuthorizer(httpContext.Object, Configuration.Object); // Act var result = authorizer.Authorize(); // Assert Assert.That(result, Is.True, "Authorization should succeed."); Mocks.VerifyAll(); }