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.
This commit is contained in:
davidmatson 2012-10-24 16:45:13 -07:00
Родитель bfa28d1ddb
Коммит c942cabd8a
8 изменённых файлов: 16 добавлений и 28 удалений

Просмотреть файл

@ -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());

Просмотреть файл

@ -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());

Просмотреть файл

@ -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());

Просмотреть файл

@ -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());

Просмотреть файл

@ -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);

Просмотреть файл

@ -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();

Просмотреть файл

@ -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;

Просмотреть файл

@ -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