Exemplo n.º 1
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);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
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));
        }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
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);
        }