diff options
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r-- | OpenSim/Framework/Communications/LoginService.cs | 2 | ||||
-rw-r--r-- | OpenSim/Framework/Communications/Tests/LoginServiceTests.cs | 96 |
2 files changed, 96 insertions, 2 deletions
diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs index b2434c2..f34f10c 100644 --- a/OpenSim/Framework/Communications/LoginService.cs +++ b/OpenSim/Framework/Communications/LoginService.cs | |||
@@ -117,8 +117,6 @@ namespace OpenSim.Framework.Communications | |||
117 | 117 | ||
118 | bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && | 118 | bool GoodXML = (requestData.Contains("first") && requestData.Contains("last") && |
119 | (requestData.Contains("passwd") || requestData.Contains("web_login_key"))); | 119 | (requestData.Contains("passwd") || requestData.Contains("web_login_key"))); |
120 | |||
121 | //bool GoodLogin; | ||
122 | 120 | ||
123 | string startLocationRequest = "last"; | 121 | string startLocationRequest = "last"; |
124 | 122 | ||
diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs new file mode 100644 index 0000000..51adba1 --- /dev/null +++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs | |||
@@ -0,0 +1,96 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Net; | ||
31 | using NUnit.Framework; | ||
32 | using NUnit.Framework.SyntaxHelpers; | ||
33 | using Nwc.XmlRpc; | ||
34 | using OpenSim.Framework.Communications.Cache; | ||
35 | using OpenSim.Region.Communications.Local; | ||
36 | using OpenSim.Tests.Common.Mock; | ||
37 | |||
38 | namespace OpenSim.Framework.Communications.Tests | ||
39 | { | ||
40 | /// <summary> | ||
41 | /// Test the login service. For now, most of this will be done through the LocalLoginService as LoginService | ||
42 | /// is abstract | ||
43 | /// </summary> | ||
44 | [TestFixture] | ||
45 | public class LoginServiceTests | ||
46 | { | ||
47 | /// <summary> | ||
48 | /// Test the normal response to a login. Does not test authentication. Doesn't yet do what it says on the tin. | ||
49 | /// </summary> | ||
50 | [Test] | ||
51 | public void TestNormalLoginResponse() | ||
52 | { | ||
53 | log4net.Config.XmlConfigurator.Configure(); | ||
54 | |||
55 | string firstName = "Timmy"; | ||
56 | string lastName = "Mallet"; | ||
57 | |||
58 | CommunicationsManager commsManager | ||
59 | = new TestCommunicationsManager(new OpenSim.Framework.NetworkServersInfo(42, 43)); | ||
60 | |||
61 | ((LocalUserServices)commsManager.UserService).AddPlugin(new TestUserDataPlugin()); | ||
62 | ((LocalInventoryService)commsManager.InventoryService).AddPlugin(new TestInventoryDataPlugin()); | ||
63 | |||
64 | commsManager.GridService.RegisterRegion( | ||
65 | new RegionInfo(42, 43, new IPEndPoint(IPAddress.Loopback, 9000), "localhost")); | ||
66 | commsManager.GridService.RegionLoginsEnabled = true; | ||
67 | |||
68 | LoginService loginService | ||
69 | = new LocalLoginService( | ||
70 | (UserManagerBase)commsManager.UserService, "Hello folks", commsManager.InterServiceInventoryService, | ||
71 | (LocalBackEndServices)commsManager.GridService, | ||
72 | commsManager.NetworkServersInfo, false, new LibraryRootFolder(String.Empty)); | ||
73 | |||
74 | Hashtable loginParams = new Hashtable(); | ||
75 | loginParams["first"] = firstName; | ||
76 | loginParams["last"] = lastName; | ||
77 | loginParams["passwd"] = "boingboing"; | ||
78 | |||
79 | ArrayList sendParams = new ArrayList(); | ||
80 | sendParams.Add(loginParams); | ||
81 | |||
82 | XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams); | ||
83 | |||
84 | XmlRpcResponse response = loginService.XmlRpcLoginMethod(request); | ||
85 | Hashtable responseData = (Hashtable)response.Value; | ||
86 | |||
87 | // TODO: Not check inventory part of response yet. | ||
88 | // TODO: Not checking all of login response thoroughly yet. | ||
89 | |||
90 | Assert.That( | ||
91 | responseData["circuit_code"], Is.GreaterThanOrEqualTo(0) & Is.LessThanOrEqualTo(System.Int32.MaxValue)); | ||
92 | Assert.That(responseData["first_name"], Is.EqualTo(firstName)); | ||
93 | Assert.That(responseData["last_name"], Is.EqualTo(lastName)); | ||
94 | } | ||
95 | } | ||
96 | } | ||