diff options
author | Jeff Ames | 2009-05-17 10:26:00 +0000 |
---|---|---|
committer | Jeff Ames | 2009-05-17 10:26:00 +0000 |
commit | 5cfd84c92427658d88c4b36e1470744babd3d54d (patch) | |
tree | 5a08dd22f5866dd4e0cf0bdbed9353561390fa70 /OpenSim | |
parent | Removing a superfluous message, just to make bamboo run again. (diff) | |
download | opensim-SC-5cfd84c92427658d88c4b36e1470744babd3d54d.zip opensim-SC-5cfd84c92427658d88c4b36e1470744babd3d54d.tar.gz opensim-SC-5cfd84c92427658d88c4b36e1470744babd3d54d.tar.bz2 opensim-SC-5cfd84c92427658d88c4b36e1470744babd3d54d.tar.xz |
Update svn properties.
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Data/MySQL/Resources/002_GridStore.sql | 10 | ||||
-rw-r--r-- | OpenSim/Framework/Client/IClientIPEndpoint.cs | 24 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/Agent/IPBan/IPBanModule.cs | 162 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/Agent/IPBan/SceneBanner.cs | 104 | ||||
-rw-r--r-- | OpenSim/Servers/Connectors/Asset/AssetServiceConnector.cs | 12 | ||||
-rw-r--r-- | OpenSim/SimulatorServices/RegionAssetService.cs | 246 | ||||
-rw-r--r-- | OpenSim/Tests/Common/Mock/BaseAssetRepository.cs | 66 | ||||
-rw-r--r-- | OpenSim/Tests/Common/Mock/TestAssetCache.cs | 184 | ||||
-rw-r--r-- | OpenSim/Tests/Common/Mock/TestAssetService.cs | 154 | ||||
-rw-r--r-- | OpenSim/Tests/Common/Mock/TestOSHttpResponse.cs | 48 | ||||
-rw-r--r-- | OpenSim/Tests/Common/Setup/GetAssetStreamHandlerTestHelpers.cs | 128 |
11 files changed, 569 insertions, 569 deletions
diff --git a/OpenSim/Data/MySQL/Resources/002_GridStore.sql b/OpenSim/Data/MySQL/Resources/002_GridStore.sql index bda43d0..35b9be1 100644 --- a/OpenSim/Data/MySQL/Resources/002_GridStore.sql +++ b/OpenSim/Data/MySQL/Resources/002_GridStore.sql | |||
@@ -1,5 +1,5 @@ | |||
1 | BEGIN; | 1 | BEGIN; |
2 | 2 | ||
3 | ALTER TABLE regions add column access integer unsigned default 1; | 3 | ALTER TABLE regions add column access integer unsigned default 1; |
4 | 4 | ||
5 | COMMIT; | 5 | COMMIT; |
diff --git a/OpenSim/Framework/Client/IClientIPEndpoint.cs b/OpenSim/Framework/Client/IClientIPEndpoint.cs index b80dea5..d59bd31 100644 --- a/OpenSim/Framework/Client/IClientIPEndpoint.cs +++ b/OpenSim/Framework/Client/IClientIPEndpoint.cs | |||
@@ -1,12 +1,12 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using System.Net; | 3 | using System.Net; |
4 | using System.Text; | 4 | using System.Text; |
5 | 5 | ||
6 | namespace OpenSim.Framework.Client | 6 | namespace OpenSim.Framework.Client |
7 | { | 7 | { |
8 | public interface IClientIPEndpoint | 8 | public interface IClientIPEndpoint |
9 | { | 9 | { |
10 | IPAddress EndPoint { get; } | 10 | IPAddress EndPoint { get; } |
11 | } | 11 | } |
12 | } | 12 | } |
diff --git a/OpenSim/Region/CoreModules/Agent/IPBan/IPBanModule.cs b/OpenSim/Region/CoreModules/Agent/IPBan/IPBanModule.cs index b904cb0..28e0382 100644 --- a/OpenSim/Region/CoreModules/Agent/IPBan/IPBanModule.cs +++ b/OpenSim/Region/CoreModules/Agent/IPBan/IPBanModule.cs | |||
@@ -1,81 +1,81 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using System.IO; | 3 | using System.IO; |
4 | using System.Text; | 4 | using System.Text; |
5 | using Nini.Config; | 5 | using Nini.Config; |
6 | using OpenSim.Framework; | 6 | using OpenSim.Framework; |
7 | using OpenSim.Region.Framework.Interfaces; | 7 | using OpenSim.Region.Framework.Interfaces; |
8 | using OpenSim.Region.Framework.Scenes; | 8 | using OpenSim.Region.Framework.Scenes; |
9 | 9 | ||
10 | namespace OpenSim.Region.CoreModules.Agent.IPBan | 10 | namespace OpenSim.Region.CoreModules.Agent.IPBan |
11 | { | 11 | { |
12 | public class IPBanModule : IRegionModule | 12 | public class IPBanModule : IRegionModule |
13 | { | 13 | { |
14 | #region Implementation of IRegionModule | 14 | #region Implementation of IRegionModule |
15 | 15 | ||
16 | private List<string> m_bans = new List<string>(); | 16 | private List<string> m_bans = new List<string>(); |
17 | 17 | ||
18 | public void Initialise(Scene scene, IConfigSource source) | 18 | public void Initialise(Scene scene, IConfigSource source) |
19 | { | 19 | { |
20 | new SceneBanner(scene, m_bans); | 20 | new SceneBanner(scene, m_bans); |
21 | 21 | ||
22 | lock(m_bans) | 22 | lock(m_bans) |
23 | { | 23 | { |
24 | foreach (EstateBan ban in scene.RegionInfo.EstateSettings.EstateBans) | 24 | foreach (EstateBan ban in scene.RegionInfo.EstateSettings.EstateBans) |
25 | { | 25 | { |
26 | if(!String.IsNullOrEmpty(ban.BannedHostIPMask)) | 26 | if(!String.IsNullOrEmpty(ban.BannedHostIPMask)) |
27 | m_bans.Add(ban.BannedHostIPMask); | 27 | m_bans.Add(ban.BannedHostIPMask); |
28 | if (!String.IsNullOrEmpty(ban.BannedHostNameMask)) | 28 | if (!String.IsNullOrEmpty(ban.BannedHostNameMask)) |
29 | m_bans.Add(ban.BannedHostNameMask); | 29 | m_bans.Add(ban.BannedHostNameMask); |
30 | } | 30 | } |
31 | } | 31 | } |
32 | } | 32 | } |
33 | 33 | ||
34 | public void PostInitialise() | 34 | public void PostInitialise() |
35 | { | 35 | { |
36 | if(File.Exists("bans.txt")) | 36 | if(File.Exists("bans.txt")) |
37 | { | 37 | { |
38 | string[] bans = File.ReadAllLines("bans.txt"); | 38 | string[] bans = File.ReadAllLines("bans.txt"); |
39 | foreach (string ban in bans) | 39 | foreach (string ban in bans) |
40 | { | 40 | { |
41 | m_bans.Add(ban); | 41 | m_bans.Add(ban); |
42 | } | 42 | } |
43 | } | 43 | } |
44 | } | 44 | } |
45 | 45 | ||
46 | public void Close() | 46 | public void Close() |
47 | { | 47 | { |
48 | 48 | ||
49 | } | 49 | } |
50 | 50 | ||
51 | public string Name | 51 | public string Name |
52 | { | 52 | { |
53 | get { return "IPBanModule"; } | 53 | get { return "IPBanModule"; } |
54 | } | 54 | } |
55 | 55 | ||
56 | public bool IsSharedModule | 56 | public bool IsSharedModule |
57 | { | 57 | { |
58 | get { return true; } | 58 | get { return true; } |
59 | } | 59 | } |
60 | 60 | ||
61 | #endregion | 61 | #endregion |
62 | 62 | ||
63 | /// <summary> | 63 | /// <summary> |
64 | /// Bans all users from the specified network from connecting. | 64 | /// Bans all users from the specified network from connecting. |
65 | /// DNS bans are in the form "somewhere.com" will block ANY | 65 | /// DNS bans are in the form "somewhere.com" will block ANY |
66 | /// matching domain (including "betasomewhere.com", "beta.somewhere.com", | 66 | /// matching domain (including "betasomewhere.com", "beta.somewhere.com", |
67 | /// "somewhere.com.beta") - make sure to be reasonably specific in DNS | 67 | /// "somewhere.com.beta") - make sure to be reasonably specific in DNS |
68 | /// bans. | 68 | /// bans. |
69 | /// | 69 | /// |
70 | /// IP address bans match on first characters, so, | 70 | /// IP address bans match on first characters, so, |
71 | /// "127.0.0.1" will ban only that address, | 71 | /// "127.0.0.1" will ban only that address, |
72 | /// "127.0.1" will ban "127.0.10.0" | 72 | /// "127.0.1" will ban "127.0.10.0" |
73 | /// but "127.0.1." will ban only the "127.0.1.*" network | 73 | /// but "127.0.1." will ban only the "127.0.1.*" network |
74 | /// </summary> | 74 | /// </summary> |
75 | /// <param name="host">See summary for explanation of parameter</param> | 75 | /// <param name="host">See summary for explanation of parameter</param> |
76 | public void Ban(string host) | 76 | public void Ban(string host) |
77 | { | 77 | { |
78 | m_bans.Add(host); | 78 | m_bans.Add(host); |
79 | } | 79 | } |
80 | } | 80 | } |
81 | } | 81 | } |
diff --git a/OpenSim/Region/CoreModules/Agent/IPBan/SceneBanner.cs b/OpenSim/Region/CoreModules/Agent/IPBan/SceneBanner.cs index 20a2159..a5e9963 100644 --- a/OpenSim/Region/CoreModules/Agent/IPBan/SceneBanner.cs +++ b/OpenSim/Region/CoreModules/Agent/IPBan/SceneBanner.cs | |||
@@ -1,52 +1,52 @@ | |||
1 | using System.Collections.Generic; | 1 | using System.Collections.Generic; |
2 | using System.Net; | 2 | using System.Net; |
3 | using OpenSim.Framework.Client; | 3 | using OpenSim.Framework.Client; |
4 | using OpenSim.Region.Framework.Scenes; | 4 | using OpenSim.Region.Framework.Scenes; |
5 | 5 | ||
6 | namespace OpenSim.Region.CoreModules.Agent.IPBan | 6 | namespace OpenSim.Region.CoreModules.Agent.IPBan |
7 | { | 7 | { |
8 | internal class SceneBanner | 8 | internal class SceneBanner |
9 | { | 9 | { |
10 | private static readonly log4net.ILog m_log | 10 | private static readonly log4net.ILog m_log |
11 | = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | 11 | = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
12 | 12 | ||
13 | private List<string> bans; | 13 | private List<string> bans; |
14 | private SceneBase m_scene; | 14 | private SceneBase m_scene; |
15 | public SceneBanner(SceneBase scene, List<string> banList) | 15 | public SceneBanner(SceneBase scene, List<string> banList) |
16 | { | 16 | { |
17 | scene.EventManager.OnClientConnect += EventManager_OnClientConnect; | 17 | scene.EventManager.OnClientConnect += EventManager_OnClientConnect; |
18 | 18 | ||
19 | bans = banList; | 19 | bans = banList; |
20 | m_scene = scene; | 20 | m_scene = scene; |
21 | } | 21 | } |
22 | 22 | ||
23 | void EventManager_OnClientConnect(IClientCore client) | 23 | void EventManager_OnClientConnect(IClientCore client) |
24 | { | 24 | { |
25 | IClientIPEndpoint ipEndpoint; | 25 | IClientIPEndpoint ipEndpoint; |
26 | if(client.TryGet(out ipEndpoint)) | 26 | if(client.TryGet(out ipEndpoint)) |
27 | { | 27 | { |
28 | IPAddress end = ipEndpoint.EndPoint; | 28 | IPAddress end = ipEndpoint.EndPoint; |
29 | 29 | ||
30 | try | 30 | try |
31 | { | 31 | { |
32 | IPHostEntry rDNS = Dns.GetHostEntry(end); | 32 | IPHostEntry rDNS = Dns.GetHostEntry(end); |
33 | foreach (string ban in bans) | 33 | foreach (string ban in bans) |
34 | { | 34 | { |
35 | if (rDNS.HostName.Contains(ban) || | 35 | if (rDNS.HostName.Contains(ban) || |
36 | end.ToString().StartsWith(ban)) | 36 | end.ToString().StartsWith(ban)) |
37 | { | 37 | { |
38 | client.Disconnect("Banned - network \"" + ban + "\" is not allowed to connect to this server."); | 38 | client.Disconnect("Banned - network \"" + ban + "\" is not allowed to connect to this server."); |
39 | m_log.Warn("[IPBAN] Disconnected '" + end + "' due to '" + ban + "' ban."); | 39 | m_log.Warn("[IPBAN] Disconnected '" + end + "' due to '" + ban + "' ban."); |
40 | return; | 40 | return; |
41 | } | 41 | } |
42 | } | 42 | } |
43 | } | 43 | } |
44 | catch (System.Net.Sockets.SocketException sex) | 44 | catch (System.Net.Sockets.SocketException sex) |
45 | { | 45 | { |
46 | m_log.WarnFormat("[IPBAN] IP address \"{0}\" cannot be resolved via DNS", end); | 46 | m_log.WarnFormat("[IPBAN] IP address \"{0}\" cannot be resolved via DNS", end); |
47 | } | 47 | } |
48 | m_log.WarnFormat("[IPBAN] User \"{0}\" not in any ban lists. Allowing connection.", end); | 48 | m_log.WarnFormat("[IPBAN] User \"{0}\" not in any ban lists. Allowing connection.", end); |
49 | } | 49 | } |
50 | } | 50 | } |
51 | } | 51 | } |
52 | } | 52 | } |
diff --git a/OpenSim/Servers/Connectors/Asset/AssetServiceConnector.cs b/OpenSim/Servers/Connectors/Asset/AssetServiceConnector.cs index b2b4cc2..df9507a 100644 --- a/OpenSim/Servers/Connectors/Asset/AssetServiceConnector.cs +++ b/OpenSim/Servers/Connectors/Asset/AssetServiceConnector.cs | |||
@@ -45,14 +45,14 @@ namespace OpenSim.Servers.Connectors | |||
45 | MethodBase.GetCurrentMethod().DeclaringType); | 45 | MethodBase.GetCurrentMethod().DeclaringType); |
46 | 46 | ||
47 | private string m_ServerURI = String.Empty; | 47 | private string m_ServerURI = String.Empty; |
48 | private IImprovedAssetCache m_Cache = null; | 48 | private IImprovedAssetCache m_Cache = null; |
49 | 49 | ||
50 | public AssetServicesConnector() | 50 | public AssetServicesConnector() |
51 | { | 51 | { |
52 | } | 52 | } |
53 | 53 | ||
54 | public AssetServicesConnector(string serverURI) | 54 | public AssetServicesConnector(string serverURI) |
55 | { | 55 | { |
56 | m_ServerURI = serverURI; | 56 | m_ServerURI = serverURI; |
57 | } | 57 | } |
58 | 58 | ||
@@ -201,7 +201,7 @@ namespace OpenSim.Servers.Connectors | |||
201 | if (newID != String.Empty) | 201 | if (newID != String.Empty) |
202 | { | 202 | { |
203 | // Placing this here, so that this work with old asset servers that don't send any reply back | 203 | // Placing this here, so that this work with old asset servers that don't send any reply back |
204 | // SynchronousRestObjectRequester returns somethins that is not an empty string | 204 | // SynchronousRestObjectRequester returns somethins that is not an empty string |
205 | if (newID != null) | 205 | if (newID != null) |
206 | asset.ID = newID; | 206 | asset.ID = newID; |
207 | 207 | ||
diff --git a/OpenSim/SimulatorServices/RegionAssetService.cs b/OpenSim/SimulatorServices/RegionAssetService.cs index 9a2cbb9..651e6d4 100644 --- a/OpenSim/SimulatorServices/RegionAssetService.cs +++ b/OpenSim/SimulatorServices/RegionAssetService.cs | |||
@@ -1,123 +1,123 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System.Reflection; | 28 | using System.Reflection; |
29 | using log4net; | 29 | using log4net; |
30 | using Nini.Config; | 30 | using Nini.Config; |
31 | using OpenSim.Framework; | 31 | using OpenSim.Framework; |
32 | using OpenSim.Framework.Servers.HttpServer; | 32 | using OpenSim.Framework.Servers.HttpServer; |
33 | using OpenSim.Region.Framework.Scenes; | 33 | using OpenSim.Region.Framework.Scenes; |
34 | using OpenSim.Region.Framework.Interfaces; | 34 | using OpenSim.Region.Framework.Interfaces; |
35 | using OpenSim.Servers.AssetServer.Handlers; | 35 | using OpenSim.Servers.AssetServer.Handlers; |
36 | 36 | ||
37 | namespace OpenSim.Region.SimulatorServices | 37 | namespace OpenSim.Region.SimulatorServices |
38 | { | 38 | { |
39 | public class RegionAssetService : IRegionModule | 39 | public class RegionAssetService : IRegionModule |
40 | { | 40 | { |
41 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 41 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
42 | private static bool initialized = false; | 42 | private static bool initialized = false; |
43 | private static bool enabled = false; | 43 | private static bool enabled = false; |
44 | 44 | ||
45 | private bool m_gridMode = false; | 45 | private bool m_gridMode = false; |
46 | Scene m_scene; | 46 | Scene m_scene; |
47 | 47 | ||
48 | #region IRegionModule interface | 48 | #region IRegionModule interface |
49 | 49 | ||
50 | public void Initialise(Scene scene, IConfigSource config) | 50 | public void Initialise(Scene scene, IConfigSource config) |
51 | { | 51 | { |
52 | if (!initialized) | 52 | if (!initialized) |
53 | { | 53 | { |
54 | initialized = true; | 54 | initialized = true; |
55 | m_scene = scene; | 55 | m_scene = scene; |
56 | 56 | ||
57 | // This module is only on for standalones in hypergrid mode | 57 | // This module is only on for standalones in hypergrid mode |
58 | enabled = ((!config.Configs["Startup"].GetBoolean("gridmode", true)) && | 58 | enabled = ((!config.Configs["Startup"].GetBoolean("gridmode", true)) && |
59 | config.Configs["Startup"].GetBoolean("hypergrid", true)) || | 59 | config.Configs["Startup"].GetBoolean("hypergrid", true)) || |
60 | ((config.Configs["MXP"] != null) && config.Configs["MXP"].GetBoolean("Enabled", true)); | 60 | ((config.Configs["MXP"] != null) && config.Configs["MXP"].GetBoolean("Enabled", true)); |
61 | m_gridMode = config.Configs["Startup"].GetBoolean("gridmode", true); | 61 | m_gridMode = config.Configs["Startup"].GetBoolean("gridmode", true); |
62 | } | 62 | } |
63 | } | 63 | } |
64 | 64 | ||
65 | public void PostInitialise() | 65 | public void PostInitialise() |
66 | { | 66 | { |
67 | if (enabled) | 67 | if (enabled) |
68 | { | 68 | { |
69 | m_log.Info("[RegionAssetService]: Starting..."); | 69 | m_log.Info("[RegionAssetService]: Starting..."); |
70 | 70 | ||
71 | new AssetService(m_scene,m_gridMode); | 71 | new AssetService(m_scene,m_gridMode); |
72 | } | 72 | } |
73 | } | 73 | } |
74 | 74 | ||
75 | public void Close() | 75 | public void Close() |
76 | { | 76 | { |
77 | } | 77 | } |
78 | 78 | ||
79 | public string Name | 79 | public string Name |
80 | { | 80 | { |
81 | get { return "RegionAssetService"; } | 81 | get { return "RegionAssetService"; } |
82 | } | 82 | } |
83 | 83 | ||
84 | public bool IsSharedModule | 84 | public bool IsSharedModule |
85 | { | 85 | { |
86 | get { return true; } | 86 | get { return true; } |
87 | } | 87 | } |
88 | 88 | ||
89 | #endregion | 89 | #endregion |
90 | 90 | ||
91 | } | 91 | } |
92 | 92 | ||
93 | public class AssetService | 93 | public class AssetService |
94 | { | 94 | { |
95 | private bool m_doLookup = false; | 95 | private bool m_doLookup = false; |
96 | private bool m_gridMode = false; | 96 | private bool m_gridMode = false; |
97 | 97 | ||
98 | public bool DoLookup | 98 | public bool DoLookup |
99 | { | 99 | { |
100 | get { return m_doLookup; } | 100 | get { return m_doLookup; } |
101 | set { m_doLookup = value; } | 101 | set { m_doLookup = value; } |
102 | } | 102 | } |
103 | // private static readonly ILog m_log | 103 | // private static readonly ILog m_log |
104 | // = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 104 | // = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
105 | 105 | ||
106 | public AssetService(Scene m_scene, bool gridMode) | 106 | public AssetService(Scene m_scene, bool gridMode) |
107 | { | 107 | { |
108 | m_gridMode = gridMode; | 108 | m_gridMode = gridMode; |
109 | AddHttpHandlers(m_scene); | 109 | AddHttpHandlers(m_scene); |
110 | } | 110 | } |
111 | 111 | ||
112 | protected void AddHttpHandlers(Scene m_scene) | 112 | protected void AddHttpHandlers(Scene m_scene) |
113 | { | 113 | { |
114 | IHttpServer httpServer = m_scene.CommsManager.HttpServer; | 114 | IHttpServer httpServer = m_scene.CommsManager.HttpServer; |
115 | 115 | ||
116 | httpServer.AddStreamHandler(new AssetServerGetHandler(m_scene.AssetService)); | 116 | httpServer.AddStreamHandler(new AssetServerGetHandler(m_scene.AssetService)); |
117 | httpServer.AddStreamHandler(new AssetServerPostHandler(m_scene.AssetService)); | 117 | httpServer.AddStreamHandler(new AssetServerPostHandler(m_scene.AssetService)); |
118 | httpServer.AddStreamHandler(new AssetServerDeleteHandler(m_scene.AssetService)); | 118 | httpServer.AddStreamHandler(new AssetServerDeleteHandler(m_scene.AssetService)); |
119 | 119 | ||
120 | 120 | ||
121 | } | 121 | } |
122 | } | 122 | } |
123 | } | 123 | } |
diff --git a/OpenSim/Tests/Common/Mock/BaseAssetRepository.cs b/OpenSim/Tests/Common/Mock/BaseAssetRepository.cs index acfe4fe..b284abc 100644 --- a/OpenSim/Tests/Common/Mock/BaseAssetRepository.cs +++ b/OpenSim/Tests/Common/Mock/BaseAssetRepository.cs | |||
@@ -1,34 +1,34 @@ | |||
1 | using System.Collections.Generic; | 1 | using System.Collections.Generic; |
2 | using OpenMetaverse; | 2 | using OpenMetaverse; |
3 | using OpenSim.Framework; | 3 | using OpenSim.Framework; |
4 | 4 | ||
5 | namespace OpenSim.Tests.Common.Mock | 5 | namespace OpenSim.Tests.Common.Mock |
6 | { | 6 | { |
7 | public class BaseAssetRepository | 7 | public class BaseAssetRepository |
8 | { | 8 | { |
9 | protected Dictionary<UUID, AssetBase> Assets = new Dictionary<UUID, AssetBase>(); | 9 | protected Dictionary<UUID, AssetBase> Assets = new Dictionary<UUID, AssetBase>(); |
10 | 10 | ||
11 | public AssetBase FetchAsset(UUID uuid) | 11 | public AssetBase FetchAsset(UUID uuid) |
12 | { | 12 | { |
13 | if (ExistsAsset(uuid)) | 13 | if (ExistsAsset(uuid)) |
14 | return Assets[uuid]; | 14 | return Assets[uuid]; |
15 | else | 15 | else |
16 | return null; | 16 | return null; |
17 | } | 17 | } |
18 | 18 | ||
19 | public void CreateAsset(AssetBase asset) | 19 | public void CreateAsset(AssetBase asset) |
20 | { | 20 | { |
21 | Assets[asset.FullID] = asset; | 21 | Assets[asset.FullID] = asset; |
22 | } | 22 | } |
23 | 23 | ||
24 | public void UpdateAsset(AssetBase asset) | 24 | public void UpdateAsset(AssetBase asset) |
25 | { | 25 | { |
26 | CreateAsset(asset); | 26 | CreateAsset(asset); |
27 | } | 27 | } |
28 | 28 | ||
29 | public bool ExistsAsset(UUID uuid) | 29 | public bool ExistsAsset(UUID uuid) |
30 | { | 30 | { |
31 | return Assets.ContainsKey(uuid); | 31 | return Assets.ContainsKey(uuid); |
32 | } | 32 | } |
33 | } | 33 | } |
34 | } \ No newline at end of file | 34 | } \ No newline at end of file |
diff --git a/OpenSim/Tests/Common/Mock/TestAssetCache.cs b/OpenSim/Tests/Common/Mock/TestAssetCache.cs index d621763..a9949bb 100644 --- a/OpenSim/Tests/Common/Mock/TestAssetCache.cs +++ b/OpenSim/Tests/Common/Mock/TestAssetCache.cs | |||
@@ -1,92 +1,92 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using System.Text; | 3 | using System.Text; |
4 | using OpenMetaverse; | 4 | using OpenMetaverse; |
5 | using OpenMetaverse.Packets; | 5 | using OpenMetaverse.Packets; |
6 | using OpenSim.Framework; | 6 | using OpenSim.Framework; |
7 | 7 | ||
8 | namespace OpenSim.Tests.Common.Mock | 8 | namespace OpenSim.Tests.Common.Mock |
9 | { | 9 | { |
10 | public class TestAssetCache : BaseAssetRepository, IAssetCache | 10 | public class TestAssetCache : BaseAssetRepository, IAssetCache |
11 | { | 11 | { |
12 | public void AssetReceived(AssetBase asset, bool IsTexture) | 12 | public void AssetReceived(AssetBase asset, bool IsTexture) |
13 | { | 13 | { |
14 | throw new NotImplementedException(); | 14 | throw new NotImplementedException(); |
15 | } | 15 | } |
16 | 16 | ||
17 | public void AssetNotFound(UUID assetID, bool IsTexture) | 17 | public void AssetNotFound(UUID assetID, bool IsTexture) |
18 | { | 18 | { |
19 | throw new NotImplementedException(); | 19 | throw new NotImplementedException(); |
20 | } | 20 | } |
21 | 21 | ||
22 | public void Dispose() | 22 | public void Dispose() |
23 | { | 23 | { |
24 | throw new NotImplementedException(); | 24 | throw new NotImplementedException(); |
25 | } | 25 | } |
26 | 26 | ||
27 | public string Version | 27 | public string Version |
28 | { | 28 | { |
29 | get { throw new NotImplementedException(); } | 29 | get { throw new NotImplementedException(); } |
30 | } | 30 | } |
31 | 31 | ||
32 | public string Name | 32 | public string Name |
33 | { | 33 | { |
34 | get { throw new NotImplementedException(); } | 34 | get { throw new NotImplementedException(); } |
35 | } | 35 | } |
36 | 36 | ||
37 | public void Initialise() | 37 | public void Initialise() |
38 | { | 38 | { |
39 | throw new NotImplementedException(); | 39 | throw new NotImplementedException(); |
40 | } | 40 | } |
41 | 41 | ||
42 | public IAssetServer AssetServer | 42 | public IAssetServer AssetServer |
43 | { | 43 | { |
44 | get { throw new NotImplementedException(); } | 44 | get { throw new NotImplementedException(); } |
45 | } | 45 | } |
46 | 46 | ||
47 | public void Initialise(ConfigSettings cs, IAssetServer server) | 47 | public void Initialise(ConfigSettings cs, IAssetServer server) |
48 | { | 48 | { |
49 | throw new NotImplementedException(); | 49 | throw new NotImplementedException(); |
50 | } | 50 | } |
51 | 51 | ||
52 | public void ShowState() | 52 | public void ShowState() |
53 | { | 53 | { |
54 | throw new NotImplementedException(); | 54 | throw new NotImplementedException(); |
55 | } | 55 | } |
56 | 56 | ||
57 | public void Clear() | 57 | public void Clear() |
58 | { | 58 | { |
59 | throw new NotImplementedException(); | 59 | throw new NotImplementedException(); |
60 | } | 60 | } |
61 | 61 | ||
62 | public bool TryGetCachedAsset(UUID assetID, out AssetBase asset) | 62 | public bool TryGetCachedAsset(UUID assetID, out AssetBase asset) |
63 | { | 63 | { |
64 | throw new NotImplementedException(); | 64 | throw new NotImplementedException(); |
65 | } | 65 | } |
66 | 66 | ||
67 | public void GetAsset(UUID assetID, AssetRequestCallback callback, bool isTexture) | 67 | public void GetAsset(UUID assetID, AssetRequestCallback callback, bool isTexture) |
68 | { | 68 | { |
69 | throw new NotImplementedException(); | 69 | throw new NotImplementedException(); |
70 | } | 70 | } |
71 | 71 | ||
72 | public AssetBase GetAsset(UUID assetID, bool isTexture) | 72 | public AssetBase GetAsset(UUID assetID, bool isTexture) |
73 | { | 73 | { |
74 | return FetchAsset(assetID); | 74 | return FetchAsset(assetID); |
75 | } | 75 | } |
76 | 76 | ||
77 | public void AddAsset(AssetBase asset) | 77 | public void AddAsset(AssetBase asset) |
78 | { | 78 | { |
79 | CreateAsset( asset ); | 79 | CreateAsset( asset ); |
80 | } | 80 | } |
81 | 81 | ||
82 | public void ExpireAsset(UUID assetID) | 82 | public void ExpireAsset(UUID assetID) |
83 | { | 83 | { |
84 | throw new NotImplementedException(); | 84 | throw new NotImplementedException(); |
85 | } | 85 | } |
86 | 86 | ||
87 | public void AddAssetRequest(IClientAPI userInfo, TransferRequestPacket transferRequest) | 87 | public void AddAssetRequest(IClientAPI userInfo, TransferRequestPacket transferRequest) |
88 | { | 88 | { |
89 | throw new NotImplementedException(); | 89 | throw new NotImplementedException(); |
90 | } | 90 | } |
91 | } | 91 | } |
92 | } | 92 | } |
diff --git a/OpenSim/Tests/Common/Mock/TestAssetService.cs b/OpenSim/Tests/Common/Mock/TestAssetService.cs index 23a1137..91ea921 100644 --- a/OpenSim/Tests/Common/Mock/TestAssetService.cs +++ b/OpenSim/Tests/Common/Mock/TestAssetService.cs | |||
@@ -1,78 +1,78 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using OpenMetaverse; | 30 | using OpenMetaverse; |
31 | using OpenSim.Framework; | 31 | using OpenSim.Framework; |
32 | using OpenSim.Data; | 32 | using OpenSim.Data; |
33 | using OpenSim.Services.Interfaces; | 33 | using OpenSim.Services.Interfaces; |
34 | 34 | ||
35 | namespace OpenSim.Tests.Common.Mock | 35 | namespace OpenSim.Tests.Common.Mock |
36 | { | 36 | { |
37 | public class TestAssetService : IAssetService | 37 | public class TestAssetService : IAssetService |
38 | { | 38 | { |
39 | private readonly Dictionary<string, AssetBase> Assets = new Dictionary<string, AssetBase>(); | 39 | private readonly Dictionary<string, AssetBase> Assets = new Dictionary<string, AssetBase>(); |
40 | 40 | ||
41 | public AssetBase Get(string id) | 41 | public AssetBase Get(string id) |
42 | { | 42 | { |
43 | return Assets[ id ]; | 43 | return Assets[ id ]; |
44 | } | 44 | } |
45 | 45 | ||
46 | public AssetMetadata GetMetadata(string id) | 46 | public AssetMetadata GetMetadata(string id) |
47 | { | 47 | { |
48 | throw new System.NotImplementedException(); | 48 | throw new System.NotImplementedException(); |
49 | } | 49 | } |
50 | 50 | ||
51 | public byte[] GetData(string id) | 51 | public byte[] GetData(string id) |
52 | { | 52 | { |
53 | throw new System.NotImplementedException(); | 53 | throw new System.NotImplementedException(); |
54 | } | 54 | } |
55 | 55 | ||
56 | public bool Get(string id, object sender, AssetRetrieved handler) | 56 | public bool Get(string id, object sender, AssetRetrieved handler) |
57 | { | 57 | { |
58 | throw new NotImplementedException(); | 58 | throw new NotImplementedException(); |
59 | } | 59 | } |
60 | 60 | ||
61 | public string Store(AssetBase asset) | 61 | public string Store(AssetBase asset) |
62 | { | 62 | { |
63 | Assets[asset.ID] = asset; | 63 | Assets[asset.ID] = asset; |
64 | 64 | ||
65 | return asset.ID; | 65 | return asset.ID; |
66 | } | 66 | } |
67 | 67 | ||
68 | public bool UpdateContent(string id, byte[] data) | 68 | public bool UpdateContent(string id, byte[] data) |
69 | { | 69 | { |
70 | throw new System.NotImplementedException(); | 70 | throw new System.NotImplementedException(); |
71 | } | 71 | } |
72 | 72 | ||
73 | public bool Delete(string id) | 73 | public bool Delete(string id) |
74 | { | 74 | { |
75 | throw new System.NotImplementedException(); | 75 | throw new System.NotImplementedException(); |
76 | } | 76 | } |
77 | } | 77 | } |
78 | } \ No newline at end of file | 78 | } \ No newline at end of file |
diff --git a/OpenSim/Tests/Common/Mock/TestOSHttpResponse.cs b/OpenSim/Tests/Common/Mock/TestOSHttpResponse.cs index 9e097b8..59d4000 100644 --- a/OpenSim/Tests/Common/Mock/TestOSHttpResponse.cs +++ b/OpenSim/Tests/Common/Mock/TestOSHttpResponse.cs | |||
@@ -1,24 +1,24 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using System.Text; | 3 | using System.Text; |
4 | using OpenSim.Framework.Servers.HttpServer; | 4 | using OpenSim.Framework.Servers.HttpServer; |
5 | 5 | ||
6 | namespace OpenSim.Tests.Common.Mock | 6 | namespace OpenSim.Tests.Common.Mock |
7 | { | 7 | { |
8 | public class TestOSHttpResponse : OSHttpResponse | 8 | public class TestOSHttpResponse : OSHttpResponse |
9 | { | 9 | { |
10 | private int m_statusCode; | 10 | private int m_statusCode; |
11 | public override int StatusCode | 11 | public override int StatusCode |
12 | { | 12 | { |
13 | get { return m_statusCode; } | 13 | get { return m_statusCode; } |
14 | set { m_statusCode = value; } | 14 | set { m_statusCode = value; } |
15 | } | 15 | } |
16 | 16 | ||
17 | private string m_contentType; | 17 | private string m_contentType; |
18 | public override string ContentType | 18 | public override string ContentType |
19 | { | 19 | { |
20 | get { return m_contentType; } | 20 | get { return m_contentType; } |
21 | set { m_contentType = value; } | 21 | set { m_contentType = value; } |
22 | } | 22 | } |
23 | } | 23 | } |
24 | } | 24 | } |
diff --git a/OpenSim/Tests/Common/Setup/GetAssetStreamHandlerTestHelpers.cs b/OpenSim/Tests/Common/Setup/GetAssetStreamHandlerTestHelpers.cs index 593beae..26851d6 100644 --- a/OpenSim/Tests/Common/Setup/GetAssetStreamHandlerTestHelpers.cs +++ b/OpenSim/Tests/Common/Setup/GetAssetStreamHandlerTestHelpers.cs | |||
@@ -1,64 +1,64 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using System.IO; | 3 | using System.IO; |
4 | using System.Net; | 4 | using System.Net; |
5 | using System.Text; | 5 | using System.Text; |
6 | using System.Xml; | 6 | using System.Xml; |
7 | using System.Xml.Serialization; | 7 | using System.Xml.Serialization; |
8 | using NUnit.Framework; | 8 | using NUnit.Framework; |
9 | using OpenSim.Framework; | 9 | using OpenSim.Framework; |
10 | using OpenSim.Framework.Servers; | 10 | using OpenSim.Framework.Servers; |
11 | using OpenSim.Framework.Servers.HttpServer; | 11 | using OpenSim.Framework.Servers.HttpServer; |
12 | using OpenSim.Tests.Common.Mock; | 12 | using OpenSim.Tests.Common.Mock; |
13 | 13 | ||
14 | namespace OpenSim.Tests.Common.Setup | 14 | namespace OpenSim.Tests.Common.Setup |
15 | { | 15 | { |
16 | public class GetAssetStreamHandlerTestHelpers | 16 | public class GetAssetStreamHandlerTestHelpers |
17 | { | 17 | { |
18 | public static void BaseFetchExistingAssetXmlTest(AssetBase asset, BaseGetAssetStreamHandler handler, OSHttpResponse response) | 18 | public static void BaseFetchExistingAssetXmlTest(AssetBase asset, BaseGetAssetStreamHandler handler, OSHttpResponse response) |
19 | { | 19 | { |
20 | byte[] expected = BaseGetAssetStreamHandler.GetXml(asset); | 20 | byte[] expected = BaseGetAssetStreamHandler.GetXml(asset); |
21 | 21 | ||
22 | byte[] actual = handler.Handle("/assets/" + asset.ID , null, null, response); | 22 | byte[] actual = handler.Handle("/assets/" + asset.ID , null, null, response); |
23 | 23 | ||
24 | Assert.Greater(actual.Length, 10, "Too short xml on fetching xml without trailing slash."); | 24 | Assert.Greater(actual.Length, 10, "Too short xml on fetching xml without trailing slash."); |
25 | Assert.AreEqual(expected, actual, "Failed on fetching xml without trailing slash."); | 25 | Assert.AreEqual(expected, actual, "Failed on fetching xml without trailing slash."); |
26 | // Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on first fetch."); | 26 | // Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on first fetch."); |
27 | 27 | ||
28 | byte[] actual1 = handler.Handle("/assets/" + asset.ID + "/", null, null, response); | 28 | byte[] actual1 = handler.Handle("/assets/" + asset.ID + "/", null, null, response); |
29 | Assert.Greater(actual1.Length, 10, "Too short xml on fetching xml with trailing slash."); | 29 | Assert.Greater(actual1.Length, 10, "Too short xml on fetching xml with trailing slash."); |
30 | Assert.AreEqual(expected, actual1, "Failed on fetching xml with trailing slash."); | 30 | Assert.AreEqual(expected, actual1, "Failed on fetching xml with trailing slash."); |
31 | // Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on second fetch."); | 31 | // Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on second fetch."); |
32 | } | 32 | } |
33 | 33 | ||
34 | public static void BaseFetchExistingAssetDataTest(AssetBase asset, BaseGetAssetStreamHandler handler, OSHttpResponse response) | 34 | public static void BaseFetchExistingAssetDataTest(AssetBase asset, BaseGetAssetStreamHandler handler, OSHttpResponse response) |
35 | { | 35 | { |
36 | Assert.AreEqual(asset.Data, handler.Handle("/assets/" + asset.ID + "/data", null, null, response), "Failed on fetching data without trailing slash."); | 36 | Assert.AreEqual(asset.Data, handler.Handle("/assets/" + asset.ID + "/data", null, null, response), "Failed on fetching data without trailing slash."); |
37 | Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on first fetch."); | 37 | Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on first fetch."); |
38 | 38 | ||
39 | Assert.AreEqual(asset.Data, handler.Handle("/assets/" + asset.ID + "/data/", null, null, response), "Failed on fetching data with trailing slash."); | 39 | Assert.AreEqual(asset.Data, handler.Handle("/assets/" + asset.ID + "/data/", null, null, response), "Failed on fetching data with trailing slash."); |
40 | Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on second fetch."); | 40 | Assert.AreEqual((int)HttpStatusCode.OK, response.StatusCode, "Wrong http response code on second fetch."); |
41 | } | 41 | } |
42 | 42 | ||
43 | public static AssetBase CreateCommonTestResources(out OSHttpResponse response) | 43 | public static AssetBase CreateCommonTestResources(out OSHttpResponse response) |
44 | { | 44 | { |
45 | AssetBase asset = CreateTestAsset(); | 45 | AssetBase asset = CreateTestAsset(); |
46 | response = new TestOSHttpResponse(); | 46 | response = new TestOSHttpResponse(); |
47 | return asset; | 47 | return asset; |
48 | } | 48 | } |
49 | 49 | ||
50 | public static AssetBase CreateTestAsset() | 50 | public static AssetBase CreateTestAsset() |
51 | { | 51 | { |
52 | byte[] expected = new byte[] { 1,2,3 }; | 52 | byte[] expected = new byte[] { 1,2,3 }; |
53 | AssetBase asset = new AssetBase( ); | 53 | AssetBase asset = new AssetBase( ); |
54 | asset.ID = Guid.NewGuid().ToString(); | 54 | asset.ID = Guid.NewGuid().ToString(); |
55 | asset.Data = expected; | 55 | asset.Data = expected; |
56 | return asset; | 56 | return asset; |
57 | } | 57 | } |
58 | 58 | ||
59 | public static void BaseFetchMissingAsset(BaseGetAssetStreamHandler handler) | 59 | public static void BaseFetchMissingAsset(BaseGetAssetStreamHandler handler) |
60 | { | 60 | { |
61 | Assert.AreEqual(BaseRequestHandlerTestHelper.EmptyByteArray, handler.Handle("/assets/" + Guid.NewGuid(), null, null, null), "Failed on bad guid."); | 61 | Assert.AreEqual(BaseRequestHandlerTestHelper.EmptyByteArray, handler.Handle("/assets/" + Guid.NewGuid(), null, null, null), "Failed on bad guid."); |
62 | } | 62 | } |
63 | } | 63 | } |
64 | } | 64 | } |