Esempio n. 1
0
        public FakeReverseProxyTests()
        {
            _sut = null;
            AppFunc proxiedAppFunc = async env =>
            {
                var context = new OwinContext(env);
                _sut = context;
                context.Response.StatusCode   = 200;
                context.Response.ReasonPhrase = "OK";
                await context.Response.WriteAsync("Hello");
            };
            var settings = new FakeReverseProxySettings();

            settings
            .Forward("/some/path/")
            .To(proxiedAppFunc, new Uri("http://internal1.example.com:8080/link/"));

            var handler = new OwinHttpMessageHandler(new FakeReverseProxy(settings).AppFunc)
            {
                AllowAutoRedirect = false,
                UseCookies        = true
            };

            _client = new HttpClient(handler)
            {
                BaseAddress = new Uri("https://example.com")
            };
        }
Esempio n. 2
0
        public void Should_not_find_match(string location)
        {
            var settings = new FakeReverseProxySettings();

            settings
            .Forward("/some/path")
            .To(env => Task.FromResult(0), new Uri("http://internal.example.com/link/"));

            var forwardEntry = settings.FindForwardEntry(location);

            forwardEntry.Should().BeNull();
        }
Esempio n. 3
0
        public void Should_find_match(string location, string expectedProxiedUrl)
        {
            var settings = new FakeReverseProxySettings();

            settings
            .Forward(location)
            .To(env => Task.FromResult(0), new Uri("http://internal.example.com/link/"));

            var forwardEntry = settings.FindForwardEntry("/some/path/page.html");
            var url          = forwardEntry.GetUri("/some/path/page.html");

            forwardEntry.Should().NotBeNull();
            url.ToString().Should().Be(expectedProxiedUrl);
        }