public void ParseClientIp_WithNoServerVariables_ReturnsEmptyString() { // Arrange var sut = new ClientIpParser(); var requestServerVariables = new HeaderDictionary(); // Act var result = sut.ParseClientIp(requestServerVariables); // Assert Assert.AreEqual(string.Empty, result); }
public void ParseClientIp_WithSingleIpInServerVariableAndALocalIp_ReturnsIp() { // Arrange var sut = new ClientIpParser(); var requestServerVariables = new HeaderDictionary { { "HTTP_FORWARDED_FOR", "12.34.56.78" }, { "HTTP_X_FORWARDED_FOR", "192.168.1.1" } }; // Act var result = sut.ParseClientIp(requestServerVariables); // Assert Assert.AreEqual("12.34.56.78", result); }
public void ParseClientIp_WithMultipleIpsInServerVariable_ReturnsIp() { // Arrange var sut = new ClientIpParser(); var requestServerVariables = new HeaderDictionary { { "HTTP_FORWARDED_FOR", "12.34.56.78, 12.34.56.79" } }; // Act var result = sut.ParseClientIp(requestServerVariables); // Assert Assert.AreEqual("12.34.56.78", result); }
public void ParseClientIp_WithSingleInvalidIpInServerVariable_ReturnsEmptyString() { // Arrange var sut = new ClientIpParser(); var requestServerVariables = new HeaderDictionary { { "HTTP_FORWARDED_FOR", "xxxx" } }; // Act var result = sut.ParseClientIp(requestServerVariables); // Assert Assert.AreEqual(string.Empty, result); }