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 QueryStringsItem(null, false);

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

            Assert.Equal("test1", _feature.SelectedItem.QueryString);
            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 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("denyQueryStringSequences");
            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 QueryStringsItem(null, false);

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

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

            XmlAssert.Equal(Helper.IsRunningOnMono() ? OriginalMono : Original, Current);
            XmlAssert.Equal(expected, site);
        }
Beispiel #3
0
        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("alwaysAllowedQueryStrings",
                                                       new XElement("add",
                                                                    new XAttribute("queryString", "test1"))))));
            document.Save(expected);

            var item = new QueryStringsItem(null, true);

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

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

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

            var item = new QueryStringsItem(null, false);

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

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

            XmlAssert.Equal(Helper.IsRunningOnMono() ? OriginalMono : Original, Current);
            XmlAssert.Equal(Path.Combine("RequestFiltering", "QueryStrings", "expected_add_deny.site.config"), Path.Combine("Website1", "web.config"));
        }
Beispiel #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 QueryStringsItem(null, false);

            item.QueryString = "test1";
            _feature.AddItem(item);
            Assert.NotNull(_feature.SelectedItem);
            Assert.Equal("test1", _feature.SelectedItem.QueryString);
            Assert.Equal(3, _feature.Items.Count);
            XmlAssert.Equal(
                Helper.IsRunningOnMono()
                    ? Path.Combine("RequestFiltering", "QueryStrings", ExpectedMono)
                    : Path.Combine("RequestFiltering", "QueryStrings", Expected),
                Current);
        }
Beispiel #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/denyQueryStringSequences");
            var          element  = new XElement("add");

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

            var item = new QueryStringsItem(null, false);

            item.QueryString = "test1";
            _feature.AddItem(item);
            Assert.NotNull(_feature.SelectedItem);
            Assert.Equal("test1", _feature.SelectedItem.QueryString);
            Assert.Equal(3, _feature.Items.Count);
            XmlAssert.Equal(Expected, Current);
        }
Beispiel #7
0
        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/alwaysAllowedQueryStrings");

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

            var item = new QueryStringsItem(null, true);

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