From c942cabd8a5d280672c288f43fab59e85f11c6da Mon Sep 17 00:00:00 2001 From: davidmatson Date: Wed, 24 Oct 2012 16:45:13 -0700 Subject: Remove need for TestHttpNamespace.bat. The only reason we needed to have TestHttpNamespace.bat is because some tests were taking calls for http://+:50231/ instead of http://localhost:50231/, and this behavior happened only when using HttpSelfHost. Configuring our tests not to take the broader URL space means they don't ever need admin-level access. --- .../ContentNegotiation/CustomFormatterTests.cs | 6 ++++- .../ContentNegotiation/HttpResponseReturnTests.cs | 2 ++ .../ModelBinding/HttpContentBindingTests.cs | 2 ++ .../Authentication/BasicOverHttpTest.cs | 2 ++ .../DeeplyNestedTypeTests.cs | 2 ++ .../HttpSelfHostResponseTest.cs | 2 ++ .../HttpSelfHostServerTest.cs | 1 + tools/TestHttpNamespace.bat | 27 ---------------------- 8 files changed, 16 insertions(+), 28 deletions(-) delete mode 100644 tools/TestHttpNamespace.bat diff --git a/test/System.Web.Http.Integration.Test/ContentNegotiation/CustomFormatterTests.cs b/test/System.Web.Http.Integration.Test/ContentNegotiation/CustomFormatterTests.cs index 6e9875fe..0f507178 100644 --- a/test/System.Web.Http.Integration.Test/ContentNegotiation/CustomFormatterTests.cs +++ b/test/System.Web.Http.Integration.Test/ContentNegotiation/CustomFormatterTests.cs @@ -7,6 +7,7 @@ using System.Net; using System.Net.Http; using System.Net.Http.Formatting; using System.Net.Http.Headers; +using System.ServiceModel; using System.Threading.Tasks; using System.Web.Http.SelfHost; using System.Web.Http.Util; @@ -111,7 +112,10 @@ namespace System.Web.Http.ContentNegotiation private void SetupHost() { baseAddress = "http://localhost/"; - config = new HttpSelfHostConfiguration(baseAddress); + config = new HttpSelfHostConfiguration(baseAddress) + { + HostNameComparisonMode = HostNameComparisonMode.Exact + }; config.Routes.MapHttpRoute("Default", "{controller}/{action}", new { controller = "CustomFormatterTests", action = "EchoOrder" }); config.MessageHandlers.Add(new ConvertToStreamMessageHandler()); config.Formatters.Add(new PlainTextFormatterWithVersionInfo()); diff --git a/test/System.Web.Http.Integration.Test/ContentNegotiation/HttpResponseReturnTests.cs b/test/System.Web.Http.Integration.Test/ContentNegotiation/HttpResponseReturnTests.cs index 6afe1854..14fc1ae9 100644 --- a/test/System.Web.Http.Integration.Test/ContentNegotiation/HttpResponseReturnTests.cs +++ b/test/System.Web.Http.Integration.Test/ContentNegotiation/HttpResponseReturnTests.cs @@ -5,6 +5,7 @@ using System.Net; using System.Net.Http; using System.Net.Http.Formatting; using System.Net.Http.Headers; +using System.ServiceModel; using System.Web.Http.SelfHost; using System.Web.Http.Util; using Microsoft.TestCommon; @@ -80,6 +81,7 @@ namespace System.Web.Http.ContentNegotiation baseAddress = "http://localhost/"; HttpSelfHostConfiguration config = new HttpSelfHostConfiguration(baseAddress); + config.HostNameComparisonMode = HostNameComparisonMode.Exact; config.Routes.MapHttpRoute("Default", "{controller}/{action}", new { controller = "HttpResponseReturn" }); config.MessageHandlers.Add(new ConvertToStreamMessageHandler()); diff --git a/test/System.Web.Http.Integration.Test/ModelBinding/HttpContentBindingTests.cs b/test/System.Web.Http.Integration.Test/ModelBinding/HttpContentBindingTests.cs index 89e334a3..bfff7d29 100644 --- a/test/System.Web.Http.Integration.Test/ModelBinding/HttpContentBindingTests.cs +++ b/test/System.Web.Http.Integration.Test/ModelBinding/HttpContentBindingTests.cs @@ -4,6 +4,7 @@ using System.Net; using System.Net.Http; using System.Net.Http.Formatting; using System.Net.Http.Headers; +using System.ServiceModel; using System.Web.Http.SelfHost; using System.Web.Http.Util; using Microsoft.TestCommon; @@ -52,6 +53,7 @@ namespace System.Web.Http.ModelBinding baseAddress = "http://localhost/"; HttpSelfHostConfiguration config = new HttpSelfHostConfiguration(baseAddress); + config.HostNameComparisonMode = HostNameComparisonMode.Exact; config.Routes.MapHttpRoute("Default", "{controller}/{action}", new { controller = "HttpContentBinding", action = "HandleMessage" }); config.MessageHandlers.Add(new ConvertToStreamMessageHandler()); diff --git a/test/System.Web.Http.SelfHost.Test/Authentication/BasicOverHttpTest.cs b/test/System.Web.Http.SelfHost.Test/Authentication/BasicOverHttpTest.cs index 66475909..6d14212e 100644 --- a/test/System.Web.Http.SelfHost.Test/Authentication/BasicOverHttpTest.cs +++ b/test/System.Web.Http.SelfHost.Test/Authentication/BasicOverHttpTest.cs @@ -2,6 +2,7 @@ using System.Net; using System.Net.Http; +using System.ServiceModel; using System.Web.Http.SelfHost; using Microsoft.TestCommon; @@ -39,6 +40,7 @@ namespace System.Web.Http { // Arrange HttpSelfHostConfiguration config = new HttpSelfHostConfiguration(BaseAddress); + config.HostNameComparisonMode = HostNameComparisonMode.Exact; config.Routes.MapHttpRoute("Default", "{controller}" + routeSuffix, new { controller = controllerName }); config.UserNamePasswordValidator = new CustomUsernamePasswordValidator(); config.MessageHandlers.Add(new CustomMessageHandler()); diff --git a/test/System.Web.Http.SelfHost.Test/DeeplyNestedTypeTests.cs b/test/System.Web.Http.SelfHost.Test/DeeplyNestedTypeTests.cs index 62e2191c..a6ac02ab 100644 --- a/test/System.Web.Http.SelfHost.Test/DeeplyNestedTypeTests.cs +++ b/test/System.Web.Http.SelfHost.Test/DeeplyNestedTypeTests.cs @@ -4,6 +4,7 @@ using System.IO; using System.Net; using System.Net.Http; using System.Net.Http.Headers; +using System.ServiceModel; using System.Text; using System.Xml.Linq; using Microsoft.TestCommon; @@ -27,6 +28,7 @@ namespace System.Web.Http.SelfHost baseAddress = String.Format("http://localhost/"); HttpSelfHostConfiguration config = new HttpSelfHostConfiguration(baseAddress); + config.HostNameComparisonMode = HostNameComparisonMode.Exact; config.Routes.MapHttpRoute("Default", "{controller}/{action}", new { controller = "DeepNestedType" }); server = new HttpSelfHostServer(config); diff --git a/test/System.Web.Http.SelfHost.Test/HttpSelfHostResponseTest.cs b/test/System.Web.Http.SelfHost.Test/HttpSelfHostResponseTest.cs index 1cf94d2b..98ebfb67 100644 --- a/test/System.Web.Http.SelfHost.Test/HttpSelfHostResponseTest.cs +++ b/test/System.Web.Http.SelfHost.Test/HttpSelfHostResponseTest.cs @@ -5,6 +5,7 @@ using System.Net; using System.Net.Http; using System.Net.Http.Formatting; using System.Net.Http.Headers; +using System.ServiceModel; using System.Threading.Tasks; using Microsoft.TestCommon; @@ -27,6 +28,7 @@ namespace System.Web.Http.SelfHost baseAddress = String.Format("http://localhost:{0}/", HttpSelfHostServerTest.TestPort); HttpSelfHostConfiguration config = new HttpSelfHostConfiguration(baseAddress); + config.HostNameComparisonMode = HostNameComparisonMode.Exact; config.Routes.MapHttpRoute("Default", "{controller}/{action}", new { controller = "NullResponse" }); messageHandler = new NullResponseMessageHandler(); diff --git a/test/System.Web.Http.SelfHost.Test/HttpSelfHostServerTest.cs b/test/System.Web.Http.SelfHost.Test/HttpSelfHostServerTest.cs index 095a93cb..ead46f52 100644 --- a/test/System.Web.Http.SelfHost.Test/HttpSelfHostServerTest.cs +++ b/test/System.Web.Http.SelfHost.Test/HttpSelfHostServerTest.cs @@ -242,6 +242,7 @@ namespace System.Web.Http.SelfHost private static HttpSelfHostServer CreateServer(TransferMode transferMode) { HttpSelfHostConfiguration config = new HttpSelfHostConfiguration(BaseUri(transferMode)); + config.HostNameComparisonMode = HostNameComparisonMode.Exact; config.Routes.MapHttpRoute("Default", "{controller}/{action}"); config.TransferMode = transferMode; diff --git a/tools/TestHttpNamespace.bat b/tools/TestHttpNamespace.bat deleted file mode 100644 index 7aea4091..00000000 --- a/tools/TestHttpNamespace.bat +++ /dev/null @@ -1,27 +0,0 @@ -@ECHO OFF -:CHECKFORSWITCHES -IF '%1'=='/h' GOTO DISPINFO -IF '%1'=='/H' GOTO DISPINFO -IF '%1'=='/?' GOTO DISPINFO -IF '%1'=='/register' GOTO REGISTER -IF '%1'=='/unregister' GOTO UNREGISTER -IF '%1'=='/REGISTER' GOTO REGISTER -IF '%1'=='/UNREGISTER' GOTO UNREGISTER - -GOTO DISPINFO - -:REGISTER -netsh http add urlacl http://+:50231/ user=%USERDOMAIN%\%USERNAME% -GOTO END - -:UNREGISTER -netsh http delete urlacl http://+:50231/ -GOTO END - -:DISPINFO -ECHO Reserve/Unreserve http.sys url's used by aspnetwebstack unit tests -ECHO. -ECHO Syntax: TestHttpNamespace [/register] [/unregister] [/h] -GOTO END - -:END -- cgit v1.2.3