Example #1
0
        public void Should_Create_Website_With_Directly_Defined_Binding()
        {
            // Arrange
            var          settings          = CakeHelper.GetWebsiteSettings("CaptainAmerica");
            const string expectedHostName  = "CaptainAmerica.web";
            const string expectedIpAddress = "*";
            const int    expectedPort      = 981;

            var binding = new BindingSettings(BindingProtocol.Http)
            {
                HostName  = expectedHostName,
                IpAddress = expectedIpAddress,
                Port      = expectedPort,
            };

            settings.Binding = binding;

            CakeHelper.DeleteWebsite(settings.Name);

            // Act
            WebsiteManager manager = CakeHelper.CreateWebsiteManager();

            manager.Create(settings);

            // Assert
            var website = CakeHelper.GetWebsite(settings.Name);

            Assert.NotNull(website);
            Assert.Equal(1, website.Bindings.Count);
            Assert.Contains(website.Bindings, b => b.Protocol == BindingProtocol.Http.ToString() &&
                            b.BindingInformation == binding.BindingInformation &&
                            b.BindingInformation.Contains(expectedPort.ToString()) &&
                            b.BindingInformation.Contains(expectedHostName) &&
                            b.BindingInformation.Contains(expectedIpAddress));
        }
Example #2
0
        public void Should_Create_Website_With_Predefined_EnabledProtocols()
        {
            // Arrange
            var settings = CakeHelper.GetWebsiteSettings("Vision");

            settings.AlternateEnabledProtocols = "http,net.msmq,net.tcp";
            CakeHelper.DeleteWebsite(settings.Name);

            // Act
            WebsiteManager manager = CakeHelper.CreateWebsiteManager();

            manager.Create(settings);

            // Assert
            var website = CakeHelper.GetWebsite(settings.Name);

            Assert.NotNull(website);
            Assert.Contains(BindingProtocol.Http.ToString(),
                            website.ApplicationDefaults.EnabledProtocols,
                            StringComparison.OrdinalIgnoreCase);
            Assert.Contains(BindingProtocol.NetMsmq.ToString(),
                            website.ApplicationDefaults.EnabledProtocols,
                            StringComparison.OrdinalIgnoreCase);
            Assert.Contains(BindingProtocol.NetTcp.ToString(),
                            website.ApplicationDefaults.EnabledProtocols,
                            StringComparison.OrdinalIgnoreCase);
        }
Example #3
0
        public void Should_Create_Application_With_Predefined_EnabledProtocols()
        {
            // Arrange
            var websiteSettings = CakeHelper.GetWebsiteSettings();

            CakeHelper.DeleteWebsite(websiteSettings.Name);
            CakeHelper.CreateWebsite(websiteSettings);

            var appSettings = CakeHelper.GetApplicationSettings(websiteSettings.Name);

            appSettings.AlternateEnabledProtocols = "http,net.pipe";

            // Act
            WebsiteManager manager = CakeHelper.CreateWebsiteManager();
            var            added   = manager.AddApplication(appSettings);

            // Assert
            Assert.True(added);
            var application = CakeHelper.GetApplication(websiteSettings.Name, appSettings.ApplicationPath);

            Assert.NotNull(application);
            Assert.Contains(BindingProtocol.Http.ToString(),
                            application.EnabledProtocols,
                            StringComparison.OrdinalIgnoreCase);
            Assert.Contains(BindingProtocol.NetPipe.ToString(),
                            application.EnabledProtocols,
                            StringComparison.OrdinalIgnoreCase);
        }
Example #4
0
        public void Should_Create_Application_Without_DirectoryBrowsing_In_Settings()
        {
            //Setup
            var websiteName     = "Banner";
            var websiteSettings = CakeHelper.GetWebsiteSettings("Banner");

            Cleanup(websiteSettings);

            // Arrange
            var appSettings = CakeHelper.GetApplicationSettings(websiteSettings.Name);

            appSettings.EnableDirectoryBrowsing = false;
            // Make sure the web.config exists
            CakeHelper.CreateWebConfig(appSettings);

            // Act
            var manager = CakeHelper.CreateWebsiteManager();

            manager.Create(websiteSettings);
            manager.AddApplication(appSettings);

            // Assert
            var value = CakeHelper.GetWebConfigurationValue(websiteSettings.Name, appSettings.ApplicationPath, "system.webServer/directoryBrowse", "enabled");

            Assert.False((bool)value);

            //Teardown
            Cleanup(websiteSettings);
        }
Example #5
0
        public void Should_Create_Application_Without_DirectoryBrowsing()
        {
            // Arrange
            var websiteSettings = CakeHelper.GetWebsiteSettings("Smash");

            CakeHelper.DeleteWebsite(websiteSettings.Name);

            // Act
            var appSettings = CakeHelper.GetApplicationSettings(websiteSettings.Name);

            CakeHelper.CreateWebConfig(appSettings);

            var manager = CakeHelper.CreateWebsiteManager();

            manager.Create(websiteSettings);
            manager.AddApplication(appSettings);
            manager.SetWebConfiguration(websiteSettings.Name, appSettings.ApplicationPath, config => config.DisableDirectoryBrowsing());

            // Assert
            var value = CakeHelper.GetWebConfigurationValue(websiteSettings.Name, appSettings.ApplicationPath, "system.webServer/directoryBrowse", "enabled");

            ((bool)value).ShouldBeFalse();

            CakeHelper.DeleteWebsite(websiteSettings.Name);
        }
Example #6
0
        public void Should_Create_Application_With_Predefined_EnabledProtocols()
        {
            // Arrange
            var websiteSettings = CakeHelper.GetWebsiteSettings("Batman");

            CakeHelper.CreateWebsite(websiteSettings);

            // Act
            var appSettings = CakeHelper.GetApplicationSettings(websiteSettings.Name);

            appSettings.AlternateEnabledProtocols = "http,net.pipe";

            WebsiteManager manager = CakeHelper.CreateWebsiteManager();
            var            added   = manager.AddApplication(appSettings);

            // Assert
            added.ShouldBeTrue();
            var application = CakeHelper.GetApplication(websiteSettings.Name, appSettings.ApplicationPath);

            application.ShouldNotBeNull();
            application.EnabledProtocols.ShouldContain(BindingProtocol.Http.ToString());
            application.EnabledProtocols.ShouldContain(BindingProtocol.NetPipe.ToString());

            CakeHelper.DeleteWebsite(websiteSettings.Name);
        }
Example #7
0
        public void Should_Create_Website_With_Fluently_Defined_Binding()
        {
            // Arrange
            var          settings          = CakeHelper.GetWebsiteSettings("Thor");
            const string expectedHostName  = "Thor.web";
            const string expectedIpAddress = "*";
            const int    expectedPort      = 981;

            settings.Binding = IISBindings.Http
                               .SetHostName(expectedHostName)
                               .SetIpAddress(expectedIpAddress)
                               .SetPort(expectedPort);

            CakeHelper.DeleteWebsite(settings.Name);

            // Act
            WebsiteManager manager = CakeHelper.CreateWebsiteManager();

            manager.Create(settings);

            // Assert
            var binding = settings.Binding;
            var website = CakeHelper.GetWebsite(settings.Name);

            Assert.NotNull(website);
            Assert.Equal(1, website.Bindings.Count);
            Assert.Contains(website.Bindings, b => b.Protocol == BindingProtocol.Http.ToString() &&
                            b.BindingInformation == binding.BindingInformation &&
                            b.BindingInformation.Contains(expectedPort.ToString()) &&
                            b.BindingInformation.Contains(expectedHostName) &&
                            b.BindingInformation.Contains(expectedIpAddress));
        }
Example #8
0
        public void Should_Create_Application_With_DirectoryBrowsing_In_Settings()
        {
            // Arrange
            var websiteSettings = CakeHelper.GetWebsiteSettings("Bruce");

            CakeHelper.DeleteWebsite(websiteSettings.Name);

            // Act
            var appSettings = CakeHelper.GetApplicationSettings(websiteSettings.Name);

            appSettings.EnableDirectoryBrowsing = true;
            CakeHelper.CreateWebConfig(appSettings);

            var manager = CakeHelper.CreateWebsiteManager();

            manager.Create(websiteSettings);
            manager.AddApplication(appSettings);

            // Assert
            var value = CakeHelper.GetWebConfigurationValue(websiteSettings.Name, appSettings.ApplicationPath, "system.webServer/directoryBrowse", "enabled");

            ((bool)value).ShouldBeTrue();

            CakeHelper.DeleteWebsite(websiteSettings.Name);
        }
Example #9
0
        private WebsiteSettings CreateWebSite()
        {
            // Arrange
            var settings = CakeHelper.GetWebsiteSettings();

            CakeHelper.DeleteWebsite(settings.Name);
            WebsiteManager manager = CakeHelper.CreateWebsiteManager();

            manager.Create(settings);

            return(settings);
        }
Example #10
0
        public void Should_Delete_Website()
        {
            // Arrange
            var settings = CakeHelper.GetWebsiteSettings("Wasp");

            CakeHelper.CreateWebsite(settings);

            // Act
            CakeHelper.CreateWebsiteManager().Delete(settings.Name);

            // Assert
            Assert.Null(CakeHelper.GetWebsite(settings.Name));
        }
Example #11
0
        public void Should_Create_Website()
        {
            // Arrange
            var settings = CakeHelper.GetWebsiteSettings("Deadpool");

            CakeHelper.DeleteWebsite(settings.Name);

            // Act
            WebsiteManager manager = CakeHelper.CreateWebsiteManager();

            manager.Create(settings);

            // Assert
            Assert.NotNull(CakeHelper.GetWebsite(settings.Name));
        }
Example #12
0
        public void Should_Start_Website()
        {
            // Arrange
            var settings = CakeHelper.GetWebsiteSettings("Sunspot");

            CakeHelper.CreateWebsite(settings);
            CakeHelper.StopWebsite(settings.Name);

            // Act
            CakeHelper.CreateWebsiteManager().Start(settings.Name);

            // Assert
            Site site = CakeHelper.GetWebsite(settings.Name);

            site.ShouldNotBeNull();
            site.State.ShouldBe(ObjectState.Started);
        }
Example #13
0
        public void Should_Stop_Website()
        {
            // Arrange
            var settings = CakeHelper.GetWebsiteSettings("HumanTourch");

            CakeHelper.CreateWebsite(settings);
            CakeHelper.StartWebsite(settings.Name);

            // Act
            CakeHelper.CreateWebsiteManager().Stop(settings.Name);

            // Assert
            Site site = CakeHelper.GetWebsite(settings.Name);

            Assert.NotNull(site);
            Assert.True(site.State == ObjectState.Stopped);
        }
Example #14
0
        public void Should_Create_Application()
        {
            // Arrange
            var websiteSettings = CakeHelper.GetWebsiteSettings();

            CakeHelper.DeleteWebsite(websiteSettings.Name);
            CakeHelper.CreateWebsite(websiteSettings);

            var appSettings = CakeHelper.GetApplicationSettings(websiteSettings.Name);

            // Act
            WebsiteManager manager = CakeHelper.CreateWebsiteManager();
            var            added   = manager.AddApplication(appSettings);

            // Assert
            Assert.True(added);
            Assert.NotNull(CakeHelper.GetApplication(websiteSettings.Name, appSettings.ApplicationPath));
        }
Example #15
0
        public void Should_Create_Application()
        {
            // Arrange
            var websiteSettings = CakeHelper.GetWebsiteSettings("Superman");

            CakeHelper.DeleteWebsite(websiteSettings.Name);

            // Act
            CakeHelper.CreateWebsite(websiteSettings);
            var appSettings = CakeHelper.GetApplicationSettings(websiteSettings.Name);

            WebsiteManager manager = CakeHelper.CreateWebsiteManager();
            var            added   = manager.AddApplication(appSettings);

            // Assert
            added.ShouldBeTrue();
            CakeHelper.GetApplication(websiteSettings.Name, appSettings.ApplicationPath).ShouldNotBeNull();

            CakeHelper.DeleteWebsite(websiteSettings.Name);
        }
Example #16
0
        public void Should_Create_Website_With_DirectoryBrowsing_In_Settings()
        {
            // Arrange
            var websiteSettings = CakeHelper.GetWebsiteSettings("Iron");

            websiteSettings.EnableDirectoryBrowsing = true;
            // Make sure the web.config exists
            CakeHelper.CreateWebConfig(websiteSettings);

            // Act
            var manager = CakeHelper.CreateWebsiteManager();

            manager.Create(websiteSettings);

            // Assert
            var value = CakeHelper.GetWebConfigurationValue(websiteSettings.Name, null, "system.webServer/directoryBrowse", "enabled");

            Assert.True((bool)value);

            CakeHelper.DeleteWebsite(websiteSettings.Name);
        }
Example #17
0
        public void Should_Create_Website_Without_DirectoryBrowsing()
        {
            // Arrange
            var websiteSettings = CakeHelper.GetWebsiteSettings("Stark");

            // Make sure the web.config exists
            CakeHelper.CreateWebConfig(websiteSettings);

            // Act
            var manager = CakeHelper.CreateWebsiteManager();

            manager.Create(websiteSettings);
            manager.SetWebConfiguration(websiteSettings.Name, null, config => config.DisableDirectoryBrowsing());

            // Assert
            var value = CakeHelper.GetWebConfigurationValue(websiteSettings.Name, null, "system.webServer/directoryBrowse", "enabled");

            Assert.False((bool)value);

            CakeHelper.DeleteWebsite(websiteSettings.Name);
        }
Example #18
0
        public void Should_Create_Application_With_DirectoryBrowsing()
        {
            // Arrange
            var websiteSettings = CakeHelper.GetWebsiteSettings("Hulk");
            var appSettings     = CakeHelper.GetApplicationSettings(websiteSettings.Name);

            // Make sure the web.config exists
            CakeHelper.CreateWebConfig(appSettings);

            // Act
            var manager = CakeHelper.CreateWebsiteManager();

            manager.Create(websiteSettings);
            manager.AddApplication(appSettings);
            manager.SetWebConfiguration(websiteSettings.Name, appSettings.ApplicationPath, config => config.EnableDirectoryBrowsing());

            // Assert
            var value = CakeHelper.GetWebConfigurationValue(websiteSettings.Name, appSettings.ApplicationPath, "system.webServer/directoryBrowse", "enabled");

            Assert.True((bool)value);

            CakeHelper.DeleteWebsite(websiteSettings.Name);
        }
Example #19
0
        //Website
        public static void CreateWebsite(WebsiteSettings settings)
        {
            WebsiteManager manager = CakeHelper.CreateWebsiteManager();

            manager.Create(settings);
        }
Example #20
0
        private void Act(string siteName, BindingSettings bindingSettings)
        {
            WebsiteManager manager = CakeHelper.CreateWebsiteManager();

            manager.AddBinding(siteName, bindingSettings);
        }