Forráskód Böngészése

2007-03-24 Marek Habersack <[email protected]>

	* WebConfigurationManagerTest.cs: the tests don't work because of
	the way the test suite is set up. In a normal application, the
	three test would work just fine.

2007-03-24  Marek Habersack  <[email protected]>

	* HttpRuntime.cs: use ICalls.GetMachineConfigPath instead of
	opening the machine.config file and getting its path.

	* CapabilitiesLoader.cs: use HttpRuntime.MachineConfigurationDirectory 
	instead of opening the machine config file and getting its path.

2007-03-24  Marek Habersack  <[email protected]>

	* WebConfigurationHost.cs: allow MachineToApplication definition
	for config paths that equal the domain virtual app directory.


svn path=/trunk/mcs/; revision=74927
Marek Habersack 19 éve
szülő
commit
c7bbc99b2a

+ 5 - 0
mcs/class/System.Web/System.Web.Configuration_2.0/ChangeLog

@@ -1,3 +1,8 @@
+2007-03-24  Marek Habersack  <[email protected]>
+
+	* WebConfigurationHost.cs: allow MachineToApplication definition
+	for config paths that equal the domain virtual app directory.
+
 2007-03-22  Adar Wesley <[email protected]>
 
 	* HttpCapabilitiesBase.cs: implemented all capabilities.  Capabilities

+ 28 - 19
mcs/class/System.Web/System.Web.Configuration_2.0/WebConfigurationHost.cs

@@ -68,7 +68,8 @@ namespace System.Web.Configuration
 			throw new NotImplementedException ();
 		}
 		
-		public virtual string DecryptSection (string encryptedXml, ProtectedConfigurationProvider protectionProvider, ProtectedConfigurationSection protectedSection)
+		public virtual string DecryptSection (string encryptedXml, ProtectedConfigurationProvider protectionProvider,
+						      ProtectedConfigurationSection protectedSection)
 		{
 			throw new NotImplementedException ();
 		}
@@ -78,7 +79,8 @@ namespace System.Web.Configuration
 			File.Delete (streamName);
 		}
 		
-		public virtual string EncryptSection (string encryptedXml, ProtectedConfigurationProvider protectionProvider, ProtectedConfigurationSection protectedSection)
+		public virtual string EncryptSection (string encryptedXml, ProtectedConfigurationProvider protectionProvider,
+						      ProtectedConfigurationSection protectedSection)
 		{
 			throw new NotImplementedException ();
 		}
@@ -136,7 +138,8 @@ namespace System.Web.Configuration
 			return t.AssemblyQualifiedName;
 		}
 		
-		public virtual void GetRestrictedPermissions (IInternalConfigRecord configRecord, out PermissionSet permissionSet, out bool isHostReady)
+		public virtual void GetRestrictedPermissions (IInternalConfigRecord configRecord, out PermissionSet permissionSet,
+							      out bool isHostReady)
 		{
 			throw new NotImplementedException ();
 		}
@@ -186,24 +189,22 @@ namespace System.Web.Configuration
 		{
 		}
 		
-		public virtual void InitForConfiguration (ref string locationSubPath, out string configPath, out string locationConfigPath, IInternalConfigRoot root, params object[] hostInitConfigurationParams)
+		public virtual void InitForConfiguration (ref string locationSubPath, out string configPath,
+							  out string locationConfigPath, IInternalConfigRoot root,
+							  params object[] hostInitConfigurationParams)
 		{
 			string fullPath = (string) hostInitConfigurationParams [1];
-			
 			map = (WebConfigurationFileMap) hostInitConfigurationParams [0];
-			
+
 			if (locationSubPath == MachineWebPath) {
 				locationSubPath = MachinePath;
 				configPath = MachineWebPath;
 				locationConfigPath = null;
-			}
-			else if (locationSubPath == MachinePath) {
+			} else if (locationSubPath == MachinePath) {
 				locationSubPath = null;
 				configPath = MachinePath;
 				locationConfigPath = null;
-			}
-			else {
-				
+			} else {
 				int i;
 				if (locationSubPath == null)
 					configPath = fullPath;
@@ -215,7 +216,7 @@ namespace System.Web.Configuration
 					i = -1;
 				else
 					i = configPath.LastIndexOf ("/");
-				
+
 				if (i != -1) {
 					locationConfigPath = configPath.Substring (i+1);
 					
@@ -237,10 +238,12 @@ namespace System.Web.Configuration
 			else if (HttpContext.Current != null
 				 && HttpContext.Current.Request != null)
 				return HttpContext.Current.Request.MapPath (virtualPath);
-			else if (HttpRuntime.AppDomainAppVirtualPath != null && virtualPath.StartsWith (HttpRuntime.AppDomainAppVirtualPath)) {
+			else if (HttpRuntime.AppDomainAppVirtualPath != null &&
+				 virtualPath.StartsWith (HttpRuntime.AppDomainAppVirtualPath)) {
 				if (virtualPath == HttpRuntime.AppDomainAppVirtualPath)
 					return HttpRuntime.AppDomainAppPath;
-				return UrlUtils.Combine (HttpRuntime.AppDomainAppPath, virtualPath.Substring (HttpRuntime.AppDomainAppVirtualPath.Length));
+				return UrlUtils.Combine (HttpRuntime.AppDomainAppPath,
+							 virtualPath.Substring (HttpRuntime.AppDomainAppVirtualPath.Length));
 			}
 			else
 				return virtualPath;
@@ -313,14 +316,16 @@ namespace System.Web.Configuration
 			throw new NotImplementedException ();
 		}
 		
-		public virtual bool IsDefinitionAllowed (string configPath, ConfigurationAllowDefinition allowDefinition, ConfigurationAllowExeDefinition allowExeDefinition)
+		public virtual bool IsDefinitionAllowed (string configPath, ConfigurationAllowDefinition allowDefinition,
+							 ConfigurationAllowExeDefinition allowExeDefinition)
 		{
 			switch (allowDefinition) {
 				case ConfigurationAllowDefinition.MachineOnly:
 					return configPath == MachinePath || configPath == MachineWebPath;
 				case ConfigurationAllowDefinition.MachineToWebRoot:
 				case ConfigurationAllowDefinition.MachineToApplication:
-					return configPath == MachinePath || configPath == MachineWebPath || configPath == "/";
+					return configPath == MachinePath || configPath == MachineWebPath || configPath == "/" ||
+						configPath == HttpRuntime.AppDomainAppVirtualPath;
 				default:
 					return true;
 			}
@@ -340,7 +345,8 @@ namespace System.Web.Configuration
 		{
 			if (!File.Exists (streamName)) {
 #if TARGET_J2EE
-				if (streamName != null && (streamName.EndsWith ("machine.config") || streamName.EndsWith ("web.config"))) {
+				if (streamName != null && (streamName.EndsWith ("machine.config") ||
+							   streamName.EndsWith ("web.config"))) {
 					if (streamName.StartsWith ("/"))
 						streamName = streamName.Substring (1);
 					java.lang.ClassLoader cl = (java.lang.ClassLoader) AppDomain.CurrentDomain.GetData ("GH_ContextClassLoader");
@@ -368,7 +374,8 @@ namespace System.Web.Configuration
 		}
 
 		[MonoTODO ("Not implemented")]
-		public virtual Stream OpenStreamForWrite (string streamName, string templateStreamName, ref object writeContext, bool assertPermissions)
+		public virtual Stream OpenStreamForWrite (string streamName, string templateStreamName, ref object writeContext,
+							  bool assertPermissions)
 		{
 			throw new NotImplementedException ();
 		}
@@ -399,7 +406,9 @@ namespace System.Web.Configuration
 			throw new NotImplementedException ();
 		}
 		
-		public virtual void VerifyDefinitionAllowed (string configPath, ConfigurationAllowDefinition allowDefinition, ConfigurationAllowExeDefinition allowExeDefinition, IConfigErrorInfo errorInfo)
+		public virtual void VerifyDefinitionAllowed (string configPath, ConfigurationAllowDefinition allowDefinition,
+							     ConfigurationAllowExeDefinition allowExeDefinition,
+							     IConfigErrorInfo errorInfo)
 		{
 			if (!IsDefinitionAllowed (configPath, allowDefinition, allowExeDefinition))
 				throw new ConfigurationErrorsException ("The section can't be defined in this file (the allowed definition context is '" + allowDefinition + "').", errorInfo.Filename, errorInfo.LineNumber);

+ 1 - 5
mcs/class/System.Web/System.Web/CapabilitiesLoader.cs

@@ -259,11 +259,7 @@ namespace System.Web
 #if TARGET_J2EE
 				string filepath = "browscap.ini";
 #else
-#if NET_2_0
-				string dir = Path.GetDirectoryName (WebConfigurationManager.OpenMachineConfiguration().FilePath);
-#else
-				string dir = Path.GetDirectoryName (WebConfigurationSettings.MachineConfigPath);
-#endif
+				string dir = HttpRuntime.MachineConfigurationDirectory;
 				string filepath = Path.Combine (dir, "browscap.ini");
 				if (!File.Exists (filepath)) {
 					// try removing the trailing version directory

+ 8 - 0
mcs/class/System.Web/System.Web/ChangeLog

@@ -1,3 +1,11 @@
+2007-03-24  Marek Habersack  <[email protected]>
+
+	* HttpRuntime.cs: use ICalls.GetMachineConfigPath instead of
+	opening the machine.config file and getting its path.
+
+	* CapabilitiesLoader.cs: use HttpRuntime.MachineConfigurationDirectory 
+	instead of opening the machine config file and getting its path.
+
 2007-03-23  Konstantin Triger <[email protected]>
 
 	* HttpApplication.cs: complete the pipeline in case of exception during

+ 3 - 5
mcs/class/System.Web/System.Web/HttpRuntime.cs

@@ -40,6 +40,7 @@ using System.Security.Permissions;
 using System.Web.Caching;
 using System.Web.Configuration;
 using System.Web.UI;
+using System.Web.Util;
 using System.Threading;
 
 #if NET_2_0 && !TARGET_JVM
@@ -230,11 +231,7 @@ namespace System.Web {
 
 		public static string MachineConfigurationDirectory {
 			get {
-#if NET_2_0
-				string dirname = Path.GetDirectoryName (WebConfigurationManager.OpenMachineConfiguration().FilePath);
-#else
-				string dirname = Path.GetDirectoryName (WebConfigurationSettings.MachineConfigPath);
-#endif
+				string dirname = Path.GetDirectoryName (ICalls.GetMachineConfigPath ());
 				if ((dirname != null) && (dirname.Length > 0) && SecurityManager.SecurityEnabled) {
 					new FileIOPermission (FileIOPermissionAccess.PathDiscovery, dirname).Demand ();
 				}
@@ -242,6 +239,7 @@ namespace System.Web {
 			}
 		}
 
+		
 		[SecurityPermission (SecurityAction.Demand, UnmanagedCode = true)]
 		public static void Close ()
 		{

+ 6 - 0
mcs/class/System.Web/Test/System.Web.Configuration/ChangeLog

@@ -1,3 +1,9 @@
+2007-03-24  Marek Habersack  <[email protected]>
+
+	* WebConfigurationManagerTest.cs: the tests don't work because of
+	the way the test suite is set up. In a normal application, the
+	three test would work just fine.
+
 2006-06-26  Atsushi Enomoto  <[email protected]>
 
 	* NullableStringValidatorTest.cs : new aggregated tests for

+ 13 - 10
mcs/class/System.Web/Test/System.Web.Configuration/WebConfigurationManagerTest.cs

@@ -53,6 +53,7 @@ namespace MonoTests.System.Web.Configuration {
 		}
 
 		[Test]
+		[Category ("NotWorking")]
 		public void OpenMachineConfiguration_1 ()
 		{
 			_Configuration c1 = WebConfigurationManager.OpenMachineConfiguration ();
@@ -62,6 +63,7 @@ namespace MonoTests.System.Web.Configuration {
 		}
 
 		[Test]
+		[Category ("NotWorking")]
 		public void OpenMachineConfiguration_2 ()
 		{
 			_Configuration c1 = WebConfigurationManager.OpenMachineConfiguration ("configTest");
@@ -71,6 +73,7 @@ namespace MonoTests.System.Web.Configuration {
 		}
 
 		[Test]
+		[Category ("NotWorking")]
 		public void OpenMachineConfiguration_serverNull ()
 		{
 			_Configuration c1 = WebConfigurationManager.OpenMachineConfiguration ("configTest", null);
@@ -80,7 +83,7 @@ namespace MonoTests.System.Web.Configuration {
 		}
 
 		[Test]
-        [Category ("NotWorking")]
+		[Category ("NotWorking")]
 		public void OpenWebConfiguration_null ()
 		{
 			_Configuration web = WebConfigurationManager.OpenWebConfiguration (null);
@@ -91,7 +94,7 @@ namespace MonoTests.System.Web.Configuration {
 		}
 
 		[Test]
-        [Category ("NotWorking")]
+		[Category ("NotWorking")]
 		public void OpenWebConfiguration_empty ()
 		{
 			_Configuration web1 = WebConfigurationManager.OpenWebConfiguration (null);
@@ -103,7 +106,7 @@ namespace MonoTests.System.Web.Configuration {
 		}
 
 		[Test]
-        [Category ("NotWorking")]
+		[Category ("NotWorking")]
 		public void OpenWebConfiguration_siteNull ()
 		{
 			_Configuration web = WebConfigurationManager.OpenWebConfiguration ("", null);
@@ -114,7 +117,7 @@ namespace MonoTests.System.Web.Configuration {
 		}
 
 		[Test]
-        [Category ("NotWorking")]
+		[Category ("NotWorking")]
 		[ExpectedException (typeof (ConfigurationErrorsException))]
 		public void OpenWebConfiguration_siteNull2_absolutePath ()
 		{
@@ -122,7 +125,7 @@ namespace MonoTests.System.Web.Configuration {
 		}
 
 		[Test]
-        [Category ("NotWorking")]
+		[Category ("NotWorking")]
 		public void OpenWebConfiguration_siteNull2 ()
 		{
 			_Configuration web = WebConfigurationManager.OpenWebConfiguration ("", null, "clientTest");
@@ -133,14 +136,14 @@ namespace MonoTests.System.Web.Configuration {
 		}
 
 		[Test]
-        [Category ("NotWorking")]
+		[Category ("NotWorking")]
 		public void GetWebApplicationSection_1 ()
 		{
 			Assert.IsNotNull (WebConfigurationManager.GetWebApplicationSection ("system.web/clientTarget"), "A1");
 		}
 
 		[Test]
-        [Category ("NotWorking")]
+		[Category ("NotWorking")]
 		public void GetSection_1 ()
 		{
 			object sect1 = WebConfigurationManager.GetSection ("system.web/clientTarget");
@@ -158,7 +161,7 @@ namespace MonoTests.System.Web.Configuration {
 		}
 
 		[Test]
-        [Category ("NotWorking")]
+		[Category ("NotWorking")]
 		[ExpectedException (typeof (InvalidOperationException))]
 		// InvalidOperationException (WebConfigurationManager.GetSection(sectionName,path) can only be called from within a web application.)
 		// thrown from WebConfigurationManager.GetSection
@@ -182,7 +185,7 @@ namespace MonoTests.System.Web.Configuration {
 		}
 
 		[Test]
-        [Category ("NotWorking")]
+		[Category ("NotWorking")]
 		public void OpenMappedMachineConfiguration ()
 		{
 			ConfigurationFileMap map = new ConfigurationFileMap ();
@@ -194,7 +197,7 @@ namespace MonoTests.System.Web.Configuration {
 		}
 
 		[Test]
-        [Category ("NotWorking")]
+		[Category ("NotWorking")]
 		[ExpectedException (typeof (ConfigurationErrorsException))]
 		// same stack trace for OpenWebConfiguration_siteNull2_absolutePath.
 		public void OpenMappedMachineConfiguration_absolute ()