From 70f6a2852eaea68bad0d26e5a5c1c7d8df3d8942 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sat, 23 May 2009 07:51:29 +0000 Subject: * Fixes [irritating] edge case in Util.GetLocalHost which could return an IPv6 address if no non-loopback IPv4 address can be found. * Restores internal IPv6 support to NetworkUtil.* * Fixes bad login unit tests. --- .../Communications/Tests/LoginServiceTests.cs | 45 ++++++++++++++++------ 1 file changed, 33 insertions(+), 12 deletions(-) (limited to 'OpenSim/Framework/Communications/Tests') diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs index a2a388e..7fda38c 100644 --- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs @@ -103,7 +103,10 @@ namespace OpenSim.Framework.Communications.Tests XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); - XmlRpcResponse response = loginService.XmlRpcLoginMethod(request, new IPEndPoint(Util.GetLocalHost(), 80)); + IPAddress tmpLocal = Util.GetLocalHost(); + IPEndPoint tmpEnd = new IPEndPoint(tmpLocal, 80); + XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, tmpEnd); + Hashtable responseData = (Hashtable)response.Value; Assert.That(responseData["first_name"], Is.EqualTo(m_firstName)); @@ -113,7 +116,7 @@ namespace OpenSim.Framework.Communications.Tests Regex capsSeedPattern = new Regex("^http://" - + m_regionExternalName + + NetworkUtil.GetHostFor(tmpLocal, m_regionExternalName) + ":9000/CAPS/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}0000/$"); Assert.That(capsSeedPattern.IsMatch((string)responseData["seed_capability"]), Is.True); @@ -140,7 +143,10 @@ namespace OpenSim.Framework.Communications.Tests XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); - XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, new IPEndPoint(Util.GetLocalHost(), 80)); + IPAddress tmpLocal = Util.GetLocalHost(); + IPEndPoint tmpEnd = new IPEndPoint(tmpLocal, 80); + XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, tmpEnd); + Hashtable responseData = (Hashtable)response.Value; UserAgentData uagent = m_userProfileData.CurrentAgent; @@ -163,7 +169,7 @@ namespace OpenSim.Framework.Communications.Tests Regex capsSeedPattern = new Regex("^http://" - + m_regionExternalName + + NetworkUtil.GetHostFor(tmpLocal, m_regionExternalName) + ":9000/CAPS/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}0000/$"); Assert.That(capsSeedPattern.IsMatch((string)responseData["seed_capability"]), Is.True); @@ -194,14 +200,16 @@ namespace OpenSim.Framework.Communications.Tests XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); - XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, new IPEndPoint(Util.GetLocalHost(), 80)); + IPAddress tmpLocal = Util.GetLocalHost(); + IPEndPoint tmpEnd = new IPEndPoint(tmpLocal, 80); + XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, tmpEnd); + Hashtable responseData = (Hashtable)response.Value; ArrayList friendslist = (ArrayList) responseData["buddy-list"]; Assert.That(friendslist,Is.Not.Null); - Hashtable buddy1 = (Hashtable) friendslist[0]; Hashtable buddy2 = (Hashtable) friendslist[1]; Assert.That(friendslist.Count, Is.EqualTo(2)); @@ -231,7 +239,10 @@ namespace OpenSim.Framework.Communications.Tests XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); - XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, new IPEndPoint(Util.GetLocalHost(), 80)); + IPAddress tmpLocal = Util.GetLocalHost(); + IPEndPoint tmpEnd = new IPEndPoint(tmpLocal, 80); + XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, tmpEnd); + Hashtable responseData = (Hashtable)response.Value; Assert.That(responseData["message"], Is.EqualTo(error_auth_message)); @@ -256,7 +267,10 @@ namespace OpenSim.Framework.Communications.Tests XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); - XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, new IPEndPoint(Util.GetLocalHost(), 80)); + IPAddress tmpLocal = Util.GetLocalHost(); + IPEndPoint tmpEnd = new IPEndPoint(tmpLocal, 80); + XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, tmpEnd); + Hashtable responseData = (Hashtable)response.Value; Assert.That(responseData["message"], Is.EqualTo(error_auth_message)); @@ -281,7 +295,10 @@ namespace OpenSim.Framework.Communications.Tests XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); - XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, new IPEndPoint(Util.GetLocalHost(), 80)); + IPAddress tmpLocal = Util.GetLocalHost(); + IPEndPoint tmpEnd = new IPEndPoint(tmpLocal, 80); + XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, tmpEnd); + Hashtable responseData = (Hashtable)response.Value; Assert.That(responseData["message"], Is.EqualTo(error_xml_message)); @@ -312,20 +329,24 @@ namespace OpenSim.Framework.Communications.Tests // First we log in. XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); - XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, new IPEndPoint(Util.GetLocalHost(), 80)); + + IPAddress tmpLocal = Util.GetLocalHost(); + IPEndPoint tmpEnd = new IPEndPoint(tmpLocal, 80); + XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, tmpEnd); + Hashtable responseData = (Hashtable)response.Value; Assert.That(responseData["message"], Is.EqualTo("Hello folks")); // Then we try again, this time expecting failure. request = new XmlRpcRequest("login_to_simulator", sendParams); - response = m_loginService.XmlRpcLoginMethod(request, new IPEndPoint(Util.GetLocalHost(), 80)); + response = m_loginService.XmlRpcLoginMethod(request, tmpEnd); responseData = (Hashtable)response.Value; Assert.That(responseData["message"], Is.EqualTo(error_already_logged)); // Finally the third time we should be able to get right back in. request = new XmlRpcRequest("login_to_simulator", sendParams); - response = m_loginService.XmlRpcLoginMethod(request, new IPEndPoint(Util.GetLocalHost(), 80)); + response = m_loginService.XmlRpcLoginMethod(request, tmpEnd); responseData = (Hashtable)response.Value; Assert.That(responseData["message"], Is.EqualTo("Hello folks")); -- cgit v1.1