コード例 #1
0
        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);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: pawelkmiec/syringe
        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);
            }
        }
コード例 #3
0
        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:"));
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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:"));
        }
コード例 #7
0
        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"));
        }
コード例 #8
0
        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));
        }
コード例 #9
0
        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);
        }
コード例 #10
0
        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"));
        }
コード例 #11
0
        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();
        }
コード例 #12
0
        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);
        }
コード例 #13
0
ファイル: IIS.cs プロジェクト: j717273419/roadkill
		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();
		}
コード例 #14
0
        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);
        }