clockwerk-opensim-stable – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 vero 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 OpenSimulator 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.Collections.Generic;
29 using OpenMetaverse;
30 using OpenSim.Framework.Communications;
31 using OpenSim.Region.Framework.Scenes;
32 using OpenSim.Services.Interfaces;
33  
34 namespace OpenSim.Tests.Common
35 {
36 /// <summary>
37 /// Utility functions for carrying out user profile related tests.
38 /// </summary>
39 public static class UserAccountHelpers
40 {
41 // /// <summary>
42 // /// Create a test user with a standard inventory
43 // /// </summary>
44 // /// <param name="commsManager"></param>
45 // /// <param name="callback">
46 // /// Callback to invoke when inventory has been loaded. This is required because
47 // /// loading may be asynchronous, even on standalone
48 // /// </param>
49 // /// <returns></returns>
50 // public static CachedUserInfo CreateUserWithInventory(
51 // CommunicationsManager commsManager, OnInventoryReceivedDelegate callback)
52 // {
53 // UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000099");
54 // return CreateUserWithInventory(commsManager, userId, callback);
55 // }
56 //
57 // /// <summary>
58 // /// Create a test user with a standard inventory
59 // /// </summary>
60 // /// <param name="commsManager"></param>
61 // /// <param name="userId">User ID</param>
62 // /// <param name="callback">
63 // /// Callback to invoke when inventory has been loaded. This is required because
64 // /// loading may be asynchronous, even on standalone
65 // /// </param>
66 // /// <returns></returns>
67 // public static CachedUserInfo CreateUserWithInventory(
68 // CommunicationsManager commsManager, UUID userId, OnInventoryReceivedDelegate callback)
69 // {
70 // return CreateUserWithInventory(commsManager, "Bill", "Bailey", userId, callback);
71 // }
72 //
73 // /// <summary>
74 // /// Create a test user with a standard inventory
75 // /// </summary>
76 // /// <param name="commsManager"></param>
77 // /// <param name="firstName">First name of user</param>
78 // /// <param name="lastName">Last name of user</param>
79 // /// <param name="userId">User ID</param>
80 // /// <param name="callback">
81 // /// Callback to invoke when inventory has been loaded. This is required because
82 // /// loading may be asynchronous, even on standalone
83 // /// </param>
84 // /// <returns></returns>
85 // public static CachedUserInfo CreateUserWithInventory(
86 // CommunicationsManager commsManager, string firstName, string lastName,
87 // UUID userId, OnInventoryReceivedDelegate callback)
88 // {
89 // return CreateUserWithInventory(commsManager, firstName, lastName, "troll", userId, callback);
90 // }
91 //
92 // /// <summary>
93 // /// Create a test user with a standard inventory
94 // /// </summary>
95 // /// <param name="commsManager"></param>
96 // /// <param name="firstName">First name of user</param>
97 // /// <param name="lastName">Last name of user</param>
98 // /// <param name="password">Password</param>
99 // /// <param name="userId">User ID</param>
100 // /// <param name="callback">
101 // /// Callback to invoke when inventory has been loaded. This is required because
102 // /// loading may be asynchronous, even on standalone
103 // /// </param>
104 // /// <returns></returns>
105 // public static CachedUserInfo CreateUserWithInventory(
106 // CommunicationsManager commsManager, string firstName, string lastName, string password,
107 // UUID userId, OnInventoryReceivedDelegate callback)
108 // {
109 // LocalUserServices lus = (LocalUserServices)commsManager.UserService;
110 // lus.AddUser(firstName, lastName, password, "bill@bailey.com", 1000, 1000, userId);
111 //
112 // CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId);
113 // userInfo.OnInventoryReceived += callback;
114 // userInfo.FetchInventory();
115 //
116 // return userInfo;
117 // }
118  
119 public static UserAccount CreateUserWithInventory(Scene scene)
120 {
121 return CreateUserWithInventory(scene, TestHelpers.ParseTail(99));
122 }
123  
124 public static UserAccount CreateUserWithInventory(Scene scene, UUID userId)
125 {
126 return CreateUserWithInventory(scene, "Bill", "Bailey", userId, "troll");
127 }
128  
129 public static UserAccount CreateUserWithInventory(Scene scene, int userId)
130 {
131 return CreateUserWithInventory(scene, "Bill", "Bailey", TestHelpers.ParseTail(userId), "troll");
132 }
133  
134 public static UserAccount CreateUserWithInventory(
135 Scene scene, string firstName, string lastName, UUID userId, string pw)
136 {
137 UserAccount ua = new UserAccount(userId) { FirstName = firstName, LastName = lastName };
138 CreateUserWithInventory(scene, ua, pw);
139 return ua;
140 }
141  
142 public static UserAccount CreateUserWithInventory(
143 Scene scene, string firstName, string lastName, int userId, string pw)
144 {
145 UserAccount ua
146 = new UserAccount(TestHelpers.ParseTail(userId)) { FirstName = firstName, LastName = lastName };
147 CreateUserWithInventory(scene, ua, pw);
148 return ua;
149 }
150  
151 public static void CreateUserWithInventory(Scene scene, UserAccount ua, string pw)
152 {
153 // FIXME: This should really be set up by UserAccount itself
154 ua.ServiceURLs = new Dictionary<string, object>();
155 scene.UserAccountService.StoreUserAccount(ua);
156 scene.InventoryService.CreateUserInventory(ua.PrincipalID);
157 scene.AuthenticationService.SetPassword(ua.PrincipalID, pw);
158 }
159 }
160 }