public void should_remove_virtual_directory() { // Arrange const string virtualDirectoryPhysicalPath = @"C:\temp\test"; const string iisPath = "/test"; var serverConfig = new WebServerConfig(new LoggerStub()); // Act serverConfig .AddSite(TestSiteName, 563, 8887) .AddVirtualDirectory(iisPath, virtualDirectoryPhysicalPath) .Commit(); serverConfig .GetSite(TestSiteName) .DeleteVirtualDirectory("/test") .Commit(); // Assert var mgr = new ServerManager(); var site = mgr.Sites[TestSiteName]; Assert.That(site.Applications[0].VirtualDirectories[iisPath], Is.Null); }
static void Main(string[] args) { var logger = new ConsoleLogger(); var serverConfig = new WebServerConfig(logger); if (!serverConfig.IsIis7OrAbove) { logger.LogHeading("IIS7 is not installed on this machine. IIS configuration setup terminated."); return; } var envConfig = new Config(); try { serverConfig .AddAppPool(envConfig.SiteName, "v4.0", ManagedPipelineMode.Integrated, ProcessModelIdentityType.LocalService) .WithProcessModel(envConfig.IdleTimeout, envConfig.PingingEnabled) .Commit(); serverConfig .AddSite(envConfig.SiteName, envConfig.PortNumber, envConfig.PortNumber) .AddApplication("/", envConfig.WebRoot, envConfig.SiteName) .WithLogging(false) .Commit(); } catch (Exception e) { logger.LogError(e); } }
public void should_delete_binding() { // Arrange string hostname = "helloworld.local"; string bindingInfo = "*:4887:helloworld.local"; var serverConfig = new WebServerConfig(new LoggerStub()); serverConfig .AddSite(TestSiteName, 563, 4887) .AddBinding(4887, hostname, false) .Commit(); // Act serverConfig .GetSite(TestSiteName) .DeleteBinding(4887, hostname) .Commit(); // Assert var mgr = new ServerManager(); var site = mgr.Sites[TestSiteName]; Binding binding = site.Bindings.FirstOrDefault(x => x.BindingInformation == bindingInfo); Assert.That(binding, Is.Null); Assert.That(site.Bindings.ByProtocol("http").BindingInformation, Is.EqualTo("*:4887:")); }
public void should_delete_non_http_binding() { // Arrange string hostname = "helloworld.local"; string bindingInfo = "*:helloworld.local"; var serverConfig = new WebServerConfig(new LoggerStub()); serverConfig .AddSite(TestSiteName, 563, 4887) .AddNonHttpBinding(hostname, "net.pipe") .Commit(); // Act serverConfig .GetSite(TestSiteName) .DeleteNonHttpBinding(hostname, "net.pipe") .Commit(); // Assert var mgr = new ServerManager(); var site = mgr.Sites[TestSiteName]; Binding binding = site.Bindings.FirstOrDefault(x => x.BindingInformation == bindingInfo); Assert.That(binding, Is.Null); }
public void should_add_site() { // Arrange var serverConfig = new WebServerConfig(new LoggerStub()); // Act serverConfig .AddSite(TestSiteName, 563, 8887) .Commit(); // Assert var mgr = new ServerManager(); var site = mgr.Sites[TestSiteName]; Assert.That(site.Id, Is.EqualTo(563)); Assert.That(site.Bindings.ByProtocol("http").BindingInformation, Is.EqualTo("*:8887:")); Assert.That(site.ServerAutoStart, Is.True); }
public void should_create_site_with_ssl_port() { // Arrange string certPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "iisconfiguration.pfx"); var serverConfig = new WebServerConfig(new LoggerStub()); // Act serverConfig .AddSite(TestSiteName, 563, 8887) .WithSecurePort(4887, certPath, "password") .Commit(); // Assert var mgr = new ServerManager(); var site = mgr.Sites[TestSiteName]; Assert.That(site.Bindings.ByProtocol("https").BindingInformation, Is.EqualTo("*:4887:")); }
public void should_add_virtual_directory_with_config_substitution() { // Arrange string iisPath = "/test"; var serverConfig = new WebServerConfig(new LoggerStub()); // Act serverConfig .AddSite(TestSiteName, 563, 8887) .AddVirtualDirectory(iisPath, @"{WebRoot}\mysite") .Commit(); // Assert var mgr = new ServerManager(); var site = mgr.Sites[TestSiteName]; Assert.That(site.Applications[0].VirtualDirectories[iisPath].PhysicalPath, Is.EqualTo(@"d:\websites\mysite")); }
public void should_add_site_with_application() { // Arrange const string applicationPhysicalPath = @"C:\temp"; var serverConfig = new WebServerConfig(new LoggerStub()); // Act serverConfig .AddSite(TestSiteName, 563, 8887) .AddApplication("/", applicationPhysicalPath, TestSiteName) .Commit(); // Assert var mgr = new ServerManager(); var site = mgr.Sites[TestSiteName]; Assert.That(site.Applications[0].ApplicationPoolName, Is.EqualTo(TestSiteName)); Assert.That(site.Applications[0].VirtualDirectories[0].PhysicalPath, Is.EqualTo(applicationPhysicalPath)); }
public void should_add_non_http_binding() { // Arrange string expectedBindingInfo = "helloworld.local"; var serverConfig = new WebServerConfig(new LoggerStub()); // Act serverConfig .AddSite(TestSiteName, 563, 4887) .AddNonHttpBinding(expectedBindingInfo, "net.pipe") .Commit(); // Assert var mgr = new ServerManager(); var site = mgr.Sites[TestSiteName]; Binding binding = site.Bindings.First(x => x.BindingInformation == expectedBindingInfo); Assert.That(binding, Is.Not.Null); }
public void should_add_site_with_alternate_logging_directory() { // Arrange var serverConfig = new WebServerConfig(new LoggerStub()); // Act serverConfig .AddSite(TestSiteName, 563, 8887) .WithLogDirectory(@"C:\logs") .Commit(); // Assert var mgr = new ServerManager(); var site = mgr.Sites[TestSiteName]; Assert.That(site.Id, Is.EqualTo(563)); Assert.That(site.Bindings.ByProtocol("http").BindingInformation, Is.EqualTo("*:8887:")); Assert.That(site.LogFile.Directory, Is.EqualTo(@"C:\logs")); }
public void Start() { var logger = new ConsoleLogger(); var serverConfig = new WebServerConfig(logger); // Current directory: src\Roadkill.Tests\bin\Debug string webRoot = Environment.CurrentDirectory + @"..\..\..\..\Roadkill.Web"; var dirInfo = new DirectoryInfo(webRoot); serverConfig .AddAppPool(_siteName, "v4.0", ManagedPipelineMode.Integrated, ProcessModelIdentityType.LocalService) .WithProcessModel(TimeSpan.FromMinutes(60), false) .Commit(); serverConfig .AddSite(_siteName, _webPort, _webPort) .AddApplication("/", dirInfo.FullName, _siteName) .WithLogging(false) .Commit(); }
public void should_add_binding() { // Arrange string hostname = ""; string expectedBindingInfo = "*:4887:"; var serverConfig = new WebServerConfig(new LoggerStub()); // Act serverConfig .AddSite(TestSiteName, 563, 4887) .AddBinding(4887, hostname, false) .Commit(); // Assert var mgr = new ServerManager(); var site = mgr.Sites[TestSiteName]; Binding binding = site.Bindings.First(x => x.BindingInformation == expectedBindingInfo); Assert.That(binding, Is.Not.Null); }
public void should_add_protocol() { // Arrange string hostname = "helloworld.local"; string expectedProtocol = "http,net.pipe"; var serverConfig = new WebServerConfig(new LoggerStub()); // Act serverConfig .AddSite(TestSiteName, 563, 4887) .AddBinding(4887, hostname, false) .AddProtocol(4887, hostname, "net.pipe") .Commit(); // Assert var mgr = new ServerManager(); var site = mgr.Sites[TestSiteName]; var application = site.Applications.First(); Assert.AreEqual(expectedProtocol, application.EnabledProtocols); }