Exemplo n.º 1
0
        public void Can_apply_forwarded_headers(
            string proto,
            string @for,
            string host,
            string pathBase,
            string expected)
        {
            var ipAddress = @for == null ? null : IPAddress.Parse(@for);

            _headers.ApplyForwardedHeaders(ipAddress, new HostString(host), proto, pathBase);

            if (expected == null)
            {
                _headers.Contains(ForwardedExtensions.Forwarded).ShouldBeFalse();
            }
            else
            {
                _headers.Contains(ForwardedExtensions.Forwarded).ShouldBeTrue();
                _headers.GetValues(ForwardedExtensions.Forwarded)
                .SingleOrDefault()
                .ShouldBe(expected);
            }
        }