Exemple #1
0
        public void TestAddDeny()
        {
            SetUp();

            var site     = Path.Combine("Website1", "web.config");
            var expected = "expected_remove.site.config";
            var document = XDocument.Load(site);
            var node     = document.Root?.XPathSelectElement("/configuration/system.webServer");
            var security = new XElement("security");
            var request  = new XElement("requestFiltering");
            var file     = new XElement("denyUrlSequences");
            var remove   = new XElement("add");

            remove.SetAttributeValue("sequence", "test1");
            node?.Add(security);
            security.Add(request);
            request.Add(file);
            file.Add(remove);
            document.Save(expected);

            var item = new UrlsItem(null, false);

            item.Url = "test1";
            _feature.AddItem(item);
            Assert.NotNull(_feature.SelectedItem);
            Assert.Equal("test1", _feature.SelectedItem.Url);

            const string Original     = @"original.config";
            const string OriginalMono = @"original.mono.config";

            XmlAssert.Equal(Helper.IsRunningOnMono() ? OriginalMono : Original, Current);
            XmlAssert.Equal(expected, site);
        }
Exemple #2
0
        public void TestRemoveDeny()
        {
            SetUp();

            var site     = Path.Combine("Website1", "web.config");
            var expected = "expected_remove.site.config";
            var document = XDocument.Load(site);

            document.Save(expected);

            var item = new UrlsItem(null, false);

            item.Url = "test1";
            _feature.AddItem(item);

            Assert.Equal("test1", _feature.SelectedItem.Url);
            Assert.Equal(3, _feature.Items.Count);
            _feature.Remove();
            Assert.Null(_feature.SelectedItem);
            Assert.Equal(2, _feature.Items.Count);

            const string Original     = @"original.config";
            const string OriginalMono = @"original.mono.config";

            XmlAssert.Equal(Helper.IsRunningOnMono() ? OriginalMono : Original, Current);
            XmlAssert.Equal(expected, site);
        }
        public void TestAdd()
        {
            SetUp();

            var site     = Path.Combine("Website1", "web.config");
            var expected = "expected_remove.site.config";
            var document = XDocument.Load(site);
            var node     = document.Root?.XPathSelectElement("/configuration/system.webServer");

            node?.Add(
                new XElement("security",
                             new XElement("requestFiltering",
                                          new XElement("alwaysAllowedUrls",
                                                       new XElement("add",
                                                                    new XAttribute("url", "test1"))))));
            document.Save(expected);

            var item = new UrlsItem(null, true);

            item.Url = "test1";
            _feature.AddItem(item);
            Assert.NotNull(_feature.SelectedItem);
            Assert.Equal("test1", _feature.SelectedItem.Url);

            const string Original     = @"original.config";
            const string OriginalMono = @"original.mono.config";

            XmlAssert.Equal(Helper.IsRunningOnMono() ? OriginalMono : Original, Current);
            XmlAssert.Equal(expected, site);
        }
Exemple #4
0
        public async void TestAddDeny()
        {
            await this.SetUp();

            var item = new UrlsItem(null, false);

            item.Url = "test1";
            _feature.AddItem(item);
            Assert.NotNull(_feature.SelectedItem);
            Assert.Equal("test1", _feature.SelectedItem.Url);

            const string Original     = @"original.config";
            const string OriginalMono = @"original.mono.config";

            XmlAssert.Equal(Helper.IsRunningOnMono() ? OriginalMono : Original, Current);
            XmlAssert.Equal(Path.Combine("RequestFiltering", "Urls", "expected_add_deny.site.config"), Path.Combine("Website1", "web.config"));
        }
Exemple #5
0
        public async void TestAddDeny()
        {
            await this.SetUp();

            const string Expected     = @"expected_add_deny.config";
            const string ExpectedMono = @"expected_add_deny.mono.config";

            var item = new UrlsItem(null, false);

            item.Url = "test1";
            _feature.AddItem(item);
            Assert.NotNull(_feature.SelectedItem);
            Assert.Equal("test1", _feature.SelectedItem.Url);
            Assert.Equal(3, _feature.Items.Count);
            XmlAssert.Equal(
                Helper.IsRunningOnMono()
                    ? Path.Combine("RequestFiltering", "Urls", ExpectedMono)
                    : Path.Combine("RequestFiltering", "Urls", Expected),
                Current);
        }
Exemple #6
0
        public void TestAddDeny()
        {
            SetUp();
            const string Expected = @"expected_add_deny.config";
            var          document = XDocument.Load(Current);
            var          node     = document.Root?.XPathSelectElement("/configuration/system.webServer/security/requestFiltering/denyUrlSequences");
            var          element  = new XElement("add");

            element.SetAttributeValue("sequence", "test1");
            node?.Add(element);
            document.Save(Expected);

            var item = new UrlsItem(null, false);

            item.Url = "test1";
            _feature.AddItem(item);
            Assert.NotNull(_feature.SelectedItem);
            Assert.Equal("test1", _feature.SelectedItem.Url);
            Assert.Equal(3, _feature.Items.Count);
            XmlAssert.Equal(Expected, Current);
        }
        public void TestAdd()
        {
            SetUp();
            const string Expected = @"expected_add.config";
            var          document = XDocument.Load(Current);
            var          node     = document.Root?.XPathSelectElement("/configuration/system.webServer/security/requestFiltering/alwaysAllowedUrls");

            node?.Add(
                new XElement("add",
                             new XAttribute("url", "test1")));
            document.Save(Expected);

            var item = new UrlsItem(null, true);

            item.Url = "test1";
            _feature.AddItem(item);
            Assert.NotNull(_feature.SelectedItem);
            Assert.Equal("test1", _feature.SelectedItem.Url);
            Assert.Equal(3, _feature.Items.Count);
            XmlAssert.Equal(Expected, Current);
        }