aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs
diff options
context:
space:
mode:
authorJustin Clarke Casey2009-01-05 17:38:39 +0000
committerJustin Clarke Casey2009-01-05 17:38:39 +0000
commit04ffcce7ea4fd303cd05e31aa8ece999c17f45b0 (patch)
tree74196c15e8c716d3361cce6343eb1c7a48338c5d /OpenSim/Framework/Communications/Tests/LoginServiceTests.cs
parent* Check in login service tests beachhead (diff)
downloadopensim-SC-04ffcce7ea4fd303cd05e31aa8ece999c17f45b0.zip
opensim-SC-04ffcce7ea4fd303cd05e31aa8ece999c17f45b0.tar.gz
opensim-SC-04ffcce7ea4fd303cd05e31aa8ece999c17f45b0.tar.bz2
opensim-SC-04ffcce7ea4fd303cd05e31aa8ece999c17f45b0.tar.xz
* Extend stub to test the successful login of a user on the local login service
* Test does not do authentication
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Communications/Tests/LoginServiceTests.cs96
1 files changed, 96 insertions, 0 deletions
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
28using System;
29using System.Collections;
30using System.Net;
31using NUnit.Framework;
32using NUnit.Framework.SyntaxHelpers;
33using Nwc.XmlRpc;
34using OpenSim.Framework.Communications.Cache;
35using OpenSim.Region.Communications.Local;
36using OpenSim.Tests.Common.Mock;
37
38namespace 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}