Пример #1
0
        public void IsLocalUrlShouldReturnFalseWhenUrlStartsWithForwardBackwardSlash()
        {
            var request = new StubHttpRequest();

            Assert.That(request.IsLocalUrl("/\\"), Is.False);
            Assert.That(request.IsLocalUrl(" /\\"), Is.False);
        }
        public void IsLocalUrlShouldReturnFalseWhenUrlIsNullOrEmpty() {
            var request = new StubHttpRequest();

            Assert.That(request.IsLocalUrl(null), Is.False);
            Assert.That(request.IsLocalUrl("   "), Is.False);
            Assert.That(request.IsLocalUrl(""), Is.False);
        }
Пример #3
0
        public void IsLocalUrlShouldReturnFalseWhenUrlStartsWithDoubleSlash()
        {
            var request = new StubHttpRequest();

            Assert.That(request.IsLocalUrl("//"), Is.False);
            Assert.That(request.IsLocalUrl("  //"), Is.False);
        }
        public void IsLocalUrlShouldReturnFalseWhenAuthoritiesDiffer() {
            var request = new StubHttpRequest();
            request.Headers.Add("Host", "localhost");

            Assert.That(request.IsLocalUrl("http://somedomain"), Is.False);
            Assert.That(request.IsLocalUrl("http://localhost:8080"), Is.False);
        }
Пример #5
0
        public void IsLocalUrlShouldReturnFalseWhenUrlIsNullOrEmpty()
        {
            var request = new StubHttpRequest();

            Assert.That(request.IsLocalUrl(null), Is.False);
            Assert.That(request.IsLocalUrl("   "), Is.False);
            Assert.That(request.IsLocalUrl(""), Is.False);
        }
        public void IsLocalUrlShouldReturnTrueWhenUrlStartsWithSlashAndAnythingElse() {
            var request = new StubHttpRequest();

            Assert.That(request.IsLocalUrl("/"), Is.True);
            Assert.That(request.IsLocalUrl("/контакты"), Is.True);
            Assert.That(request.IsLocalUrl("/  "), Is.True);
            Assert.That(request.IsLocalUrl("/abc-def"), Is.True);
        }
Пример #7
0
        public void IsLocalUrlShouldReturnFalseWhenAuthoritiesDiffer()
        {
            var request = new StubHttpRequest();

            request.Headers.Add("Host", "localhost");

            Assert.That(request.IsLocalUrl("http://somedomain"), Is.False);
            Assert.That(request.IsLocalUrl("http://localhost:8080"), Is.False);
        }
Пример #8
0
        public void IsLocalUrlShouldReturnTrueWhenAuthoritiesMatch()
        {
            var request = new StubHttpRequest();

            request.Headers.Add("Host", "localhost");

            Assert.That(request.IsLocalUrl("http://localhost"), Is.True);
            Assert.That(request.IsLocalUrl("https://localhost"), Is.True);
        }
        public void IsLocalUrlShouldReturnTrueWhenUrlStartsWithSlashAndAnythingElse()
        {
            var request = new StubHttpRequest();

            Assert.That(request.IsLocalUrl("/"), Is.True);
            Assert.That(request.IsLocalUrl("/контакты"), Is.True);
            Assert.That(request.IsLocalUrl("/  "), Is.True);
            Assert.That(request.IsLocalUrl("/abc-def"), Is.True);
        }
Пример #10
0
        public void IsLocalUrlShouldReturnFalseForNonHttpSchemes()
        {
            var request = new StubHttpRequest();

            request.Headers.Add("Host", "localhost");

            Assert.That(request.IsLocalUrl("httpx://localhost"), Is.False);
            Assert.That(request.IsLocalUrl("foo://localhost"), Is.False);
            Assert.That(request.IsLocalUrl("data://localhost"), Is.False);
            Assert.That(request.IsLocalUrl("mailto://localhost"), Is.False);
        }
Пример #11
0
        public void IsLocalUrlShouldReturnFalseForEverythingElse()
        {
            var request = new StubHttpRequest();

            request.Headers.Add("Host", "localhost");

            Assert.That(request.IsLocalUrl("abc"), Is.False);
        }
        public void IsLocalUrlShouldReturnFalseForEverythingElse() {
            var request = new StubHttpRequest();
            request.Headers.Add("Host", "localhost");

            Assert.That(request.IsLocalUrl("abc"), Is.False);
        }
        public void IsLocalUrlShouldReturnTrueWhenAuthoritiesMatch() {
            var request = new StubHttpRequest();
            request.Headers.Add("Host", "localhost");

            Assert.That(request.IsLocalUrl("http://localhost"), Is.True);
        }
        public void IsLocalUrlShouldReturnFalseWhenUrlStartsWithForwardBackwardSlash() {
            var request = new StubHttpRequest();

            Assert.That(request.IsLocalUrl("/\\"), Is.False);
        }
        public void IsLocalUrlShouldReturnFalseWhenUrlStartsWithDoubleSlash() {
            var request = new StubHttpRequest();

            Assert.That(request.IsLocalUrl("//"), Is.False);
        }