public void GetIpAddress_ChecksContextSecond()
        {
            var request = new Mock <HttpRequest>();

            MockHttpRequest(request, "5.6.7.8");

            string ip = ApplicationInsightsLogger.GetIpAddress(request.Object);

            Assert.Equal("5.6.7.8", ip);
        }
Beispiel #2
0
        public void GetIpAddress_ChecksContextSecond()
        {
            HttpRequestMessage request = new HttpRequestMessage();

            MockIpAddress(request, "5.6.7.8");

            string ip = ApplicationInsightsLogger.GetIpAddress(request);

            Assert.Equal("5.6.7.8", ip);
        }
Beispiel #3
0
        public void GetIpAddress_ChecksHeaderFirst(string headerIp)
        {
            HttpRequestMessage request = new HttpRequestMessage();

            request.Headers.Add(ApplicationInsightsScopeKeys.ForwardedForHeaderName, headerIp);
            MockIpAddress(request, "5.6.7.8");

            string ip = ApplicationInsightsLogger.GetIpAddress(request);

            Assert.Equal("1.2.3.4", ip);
        }
        public void GetIpAddress_ChecksHeaderFirst(string headerIp)
        {
            var request = new Mock <HttpRequest>();
            var headers = new HeaderDictionary
            {
                { ApplicationInsightsScopeKeys.ForwardedForHeaderName, headerIp }
            };

            request.SetupGet(r => r.Headers).Returns(headers);

            MockHttpRequest(request, "5.6.7.8");

            string ip = ApplicationInsightsLogger.GetIpAddress(request.Object);

            Assert.Equal("1.2.3.4", ip);
        }