Skip to content

Commit

Permalink
Use port over 1024 to overcome permission issue on Unix platform
Browse files Browse the repository at this point in the history
  • Loading branch information
arenekosreal committed Aug 21, 2024
1 parent b144737 commit d5b1f42
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions E5Renewer.Tests/WebApplicationExtendsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ namespace E5Renewer.Tests;
[TestClass]
public class WebApplicationExtendsTests
{
private static readonly Uri baseAddress = new ("http://localhost:65530/");
/// <summary>Test
/// <see cref="WebApplicationExtends.UseAuthTokenAuthentication(Microsoft.AspNetCore.Builder.WebApplication, string)"/>
/// </summary>
Expand All @@ -26,7 +27,7 @@ public async Task TestUseAuthTokenAuthentication(string token, HttpStatusCode ta
const string validAuthToken = "example-auth-token";

WebApplicationBuilder webApplicationBuilder = WebApplication.CreateBuilder();
webApplicationBuilder.WebHost.UseTestServer();
webApplicationBuilder.WebHost.UseTestServer((opt) => opt.BaseAddress = WebApplicationExtendsTests.baseAddress);
using (WebApplication app = webApplicationBuilder.Build())
{
app.UseAuthTokenAuthentication(validAuthToken);
Expand All @@ -49,7 +50,7 @@ public async Task TestUseAuthTokenAuthentication(string token, HttpStatusCode ta
public async Task TestUseAuthTokenAuthentication()
{
WebApplicationBuilder webApplicationBuilder = WebApplication.CreateBuilder();
webApplicationBuilder.WebHost.UseTestServer();
webApplicationBuilder.WebHost.UseTestServer((opt) => opt.BaseAddress = WebApplicationExtendsTests.baseAddress);
using (WebApplication app = webApplicationBuilder.Build())
{
app.UseAuthTokenAuthentication("example-auth-token");
Expand All @@ -76,7 +77,7 @@ public async Task TestUseHttpMethodChecker(string method, HttpStatusCode target)
const string methodAllowed = "GET";

WebApplicationBuilder webApplicationBuilder = WebApplication.CreateBuilder();
webApplicationBuilder.WebHost.UseTestServer();
webApplicationBuilder.WebHost.UseTestServer((opt) => opt.BaseAddress = WebApplicationExtendsTests.baseAddress);
using (WebApplication app = webApplicationBuilder.Build())
{
app.UseHttpMethodChecker(methodAllowed);
Expand Down Expand Up @@ -108,7 +109,7 @@ public class TestUseUnixTimestampChecker
public async Task TestUseUnixTimestampCheckerMissingGet()
{
WebApplicationBuilder webApplicationBuilder = WebApplication.CreateBuilder();
webApplicationBuilder.WebHost.UseTestServer();
webApplicationBuilder.WebHost.UseTestServer((opt) => opt.BaseAddress = WebApplicationExtendsTests.baseAddress);
webApplicationBuilder.Services.AddSingleton<IUnixTimestampGenerator, UnixTimestampGenerator>();
using (WebApplication app = webApplicationBuilder.Build())
{
Expand All @@ -131,7 +132,7 @@ public async Task TestUseUnixTimestampCheckerMissingGet()
public async Task TestUseUnixTimestampCheckerMissingPost()
{
WebApplicationBuilder webApplicationBuilder = WebApplication.CreateBuilder();
webApplicationBuilder.WebHost.UseTestServer();
webApplicationBuilder.WebHost.UseTestServer((opt) => opt.BaseAddress = WebApplicationExtendsTests.baseAddress);
webApplicationBuilder.Services.AddSingleton<IUnixTimestampGenerator, UnixTimestampGenerator>();
using (WebApplication app = webApplicationBuilder.Build())
{
Expand Down Expand Up @@ -180,7 +181,7 @@ public async Task TestUseUnixTimestampCheckerInvalidGet()
public async Task TestUseUnixTimestampCheckerInvalidPost()
{
WebApplicationBuilder webApplicationBuilder = WebApplication.CreateBuilder();
webApplicationBuilder.WebHost.UseTestServer();
webApplicationBuilder.WebHost.UseTestServer((opt) => opt.BaseAddress = WebApplicationExtendsTests.baseAddress);
webApplicationBuilder.Services.AddSingleton<IUnixTimestampGenerator, UnixTimestampGenerator>();
using (WebApplication app = webApplicationBuilder.Build())
{
Expand Down Expand Up @@ -210,7 +211,7 @@ public async Task TestUseUnixTimestampCheckerInvalidPost()
public async Task TestUseUnixTimestampCheckerGet()
{
WebApplicationBuilder webApplicationBuilder = WebApplication.CreateBuilder();
webApplicationBuilder.WebHost.UseTestServer();
webApplicationBuilder.WebHost.UseTestServer((opt) => opt.BaseAddress = WebApplicationExtendsTests.baseAddress);
webApplicationBuilder.Services.AddSingleton<IUnixTimestampGenerator, UnixTimestampGenerator>();
using (WebApplication app = webApplicationBuilder.Build())
{
Expand All @@ -236,7 +237,7 @@ public async Task TestUseUnixTimestampCheckerGet()
public async Task TestUseUnixTimestampCheckerPost()
{
WebApplicationBuilder webApplicationBuilder = WebApplication.CreateBuilder();
webApplicationBuilder.WebHost.UseTestServer();
webApplicationBuilder.WebHost.UseTestServer((opt) => opt.BaseAddress = WebApplicationExtendsTests.baseAddress);
webApplicationBuilder.Services.AddSingleton<IUnixTimestampGenerator, UnixTimestampGenerator>();
using (WebApplication app = webApplicationBuilder.Build())
{
Expand Down

0 comments on commit d5b1f42

Please sign in to comment.