- Also renamed ServerAddressFacts to ServerAddressTests to match existing test classes
This commit is contained in:
parent
6098880132
commit
5ca6592677
|
|
@ -78,17 +78,6 @@ namespace Microsoft.AspNetCore.Server.Kestrel
|
||||||
int schemeDelimiterStart = url.IndexOf("://", StringComparison.Ordinal);
|
int schemeDelimiterStart = url.IndexOf("://", StringComparison.Ordinal);
|
||||||
if (schemeDelimiterStart < 0)
|
if (schemeDelimiterStart < 0)
|
||||||
{
|
{
|
||||||
int port;
|
|
||||||
if (int.TryParse(url, NumberStyles.None, CultureInfo.InvariantCulture, out port))
|
|
||||||
{
|
|
||||||
return new ServerAddress()
|
|
||||||
{
|
|
||||||
Scheme = "http",
|
|
||||||
Host = "+",
|
|
||||||
Port = port,
|
|
||||||
PathBase = "/"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
int schemeDelimiterEnd = schemeDelimiterStart + "://".Length;
|
int schemeDelimiterEnd = schemeDelimiterStart + "://".Length;
|
||||||
|
|
|
||||||
|
|
@ -97,8 +97,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
||||||
// Static port
|
// Static port
|
||||||
var port1 = GetNextPort();
|
var port1 = GetNextPort();
|
||||||
var port2 = GetNextPort();
|
var port2 = GetNextPort();
|
||||||
dataset.Add($"{port1}", _ => new[] { $"http://localhost:{port1}/" });
|
|
||||||
dataset.Add($"{port1};{port2}", _ => new[] { $"http://localhost:{port1}/", $"http://localhost:{port2}/" });
|
// Ensure multiple addresses can be separated by semicolon
|
||||||
|
dataset.Add($"http://localhost:{port1};http://localhost:{port2}",
|
||||||
|
_ => new[] { $"http://localhost:{port1}/", $"http://localhost:{port2}/" });
|
||||||
|
|
||||||
// Ensure "localhost" and "127.0.0.1" are equivalent
|
// Ensure "localhost" and "127.0.0.1" are equivalent
|
||||||
dataset.Add($"http://localhost:{port1}", _ => new[] { $"http://localhost:{port1}/", $"http://127.0.0.1:{port1}/" });
|
dataset.Add($"http://localhost:{port1}", _ => new[] { $"http://localhost:{port1}/", $"http://127.0.0.1:{port1}/" });
|
||||||
|
|
@ -108,7 +110,6 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
||||||
dataset.Add($"http://localhost:{port1}/base/path", _ => new[] { $"http://localhost:{port1}/base/path" });
|
dataset.Add($"http://localhost:{port1}/base/path", _ => new[] { $"http://localhost:{port1}/base/path" });
|
||||||
|
|
||||||
// Dynamic port
|
// Dynamic port
|
||||||
dataset.Add("0", GetTestUrls);
|
|
||||||
dataset.Add("http://localhost:0/", GetTestUrls);
|
dataset.Add("http://localhost:0/", GetTestUrls);
|
||||||
dataset.Add($"http://{Dns.GetHostName()}:0/", GetTestUrls);
|
dataset.Add($"http://{Dns.GetHostName()}:0/", GetTestUrls);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,11 @@ using Xunit;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Server.KestrelTests
|
namespace Microsoft.AspNetCore.Server.KestrelTests
|
||||||
{
|
{
|
||||||
public class ServerAddressFacts
|
public class ServerAddressTests
|
||||||
{
|
{
|
||||||
[Theory]
|
[Theory]
|
||||||
[InlineData("")]
|
[InlineData("")]
|
||||||
|
[InlineData("5000")]
|
||||||
[InlineData("//noscheme")]
|
[InlineData("//noscheme")]
|
||||||
public void FromUriReturnsNullForSchemelessUrls(string url)
|
public void FromUriReturnsNullForSchemelessUrls(string url)
|
||||||
{
|
{
|
||||||
|
|
@ -19,7 +20,6 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
|
||||||
}
|
}
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
[InlineData("5000", "http", "+", 5000, "/", "http://+:5000/")]
|
|
||||||
[InlineData("://emptyscheme", "", "emptyscheme", 0, "", "://emptyscheme:0")]
|
[InlineData("://emptyscheme", "", "emptyscheme", 0, "", "://emptyscheme:0")]
|
||||||
[InlineData("http://localhost", "http", "localhost", 80, "", "http://localhost:80")]
|
[InlineData("http://localhost", "http", "localhost", 80, "", "http://localhost:80")]
|
||||||
[InlineData("http://www.example.com", "http", "www.example.com", 80, "", "http://www.example.com:80")]
|
[InlineData("http://www.example.com", "http", "www.example.com", 80, "", "http://www.example.com:80")]
|
||||||
Loading…
Reference in New Issue