mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-15 09:41:28 +00:00
Fix tests ..ish.
This commit is contained in:
parent
5e27f8c29b
commit
e4bb16100d
6 changed files with 57 additions and 6 deletions
|
@ -19,7 +19,7 @@ namespace LBPUnion.ProjectLighthouse.Tests
|
||||||
|
|
||||||
public LighthouseTest()
|
public LighthouseTest()
|
||||||
{
|
{
|
||||||
this.Server = new TestServer(new WebHostBuilder().UseStartup<Startup>());
|
this.Server = new TestServer(new WebHostBuilder().UseStartup<TestStartup>());
|
||||||
|
|
||||||
this.Client = this.Server.CreateClient();
|
this.Client = this.Server.CreateClient();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
using System.Net.Http;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using LBPUnion.ProjectLighthouse.Types;
|
using LBPUnion.ProjectLighthouse.Types;
|
||||||
using LBPUnion.ProjectLighthouse.Types.Levels;
|
using LBPUnion.ProjectLighthouse.Types.Levels;
|
||||||
|
@ -48,10 +49,17 @@ namespace LBPUnion.ProjectLighthouse.Tests
|
||||||
|
|
||||||
LoginResult loginResult = await this.Authenticate();
|
LoginResult loginResult = await this.Authenticate();
|
||||||
|
|
||||||
string respA = await (await this.AuthenticatedRequest("LITTLEBIGPLANETPS3_XML/slots/by?u=unitTestUser0", loginResult.AuthTicket)).Content
|
HttpResponseMessage respMessageA = await this.AuthenticatedRequest("LITTLEBIGPLANETPS3_XML/slots/by?u=unitTestUser0", loginResult.AuthTicket);
|
||||||
.ReadAsStringAsync();
|
HttpResponseMessage respMessageB = await this.AuthenticatedRequest("LITTLEBIGPLANETPS3_XML/slots/by?u=unitTestUser1", loginResult.AuthTicket);
|
||||||
string respB = await (await this.AuthenticatedRequest("LITTLEBIGPLANETPS3_XML/slots/by?u=unitTestUser1", loginResult.AuthTicket)).Content
|
|
||||||
.ReadAsStringAsync();
|
Assert.True(respMessageA.IsSuccessStatusCode);
|
||||||
|
Assert.True(respMessageB.IsSuccessStatusCode);
|
||||||
|
|
||||||
|
string respA = await respMessageA.Content.ReadAsStringAsync();
|
||||||
|
string respB = await respMessageB.Content.ReadAsStringAsync();
|
||||||
|
|
||||||
|
Assert.False(string.IsNullOrEmpty(respA));
|
||||||
|
Assert.False(string.IsNullOrEmpty(respB));
|
||||||
|
|
||||||
Assert.NotEqual(respA, respB);
|
Assert.NotEqual(respA, respB);
|
||||||
Assert.DoesNotContain(respA, "slotB");
|
Assert.DoesNotContain(respA, "slotB");
|
||||||
|
|
|
@ -73,6 +73,7 @@
|
||||||
<s:String x:Key="/Default/CodeStyle/CSharpVarKeywordUsage/ForOtherTypes/@EntryValue">UseExplicitType</s:String>
|
<s:String x:Key="/Default/CodeStyle/CSharpVarKeywordUsage/ForOtherTypes/@EntryValue">UseExplicitType</s:String>
|
||||||
<s:String x:Key="/Default/CodeStyle/CSharpVarKeywordUsage/ForSimpleTypes/@EntryValue">UseExplicitType</s:String>
|
<s:String x:Key="/Default/CodeStyle/CSharpVarKeywordUsage/ForSimpleTypes/@EntryValue">UseExplicitType</s:String>
|
||||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=DLC/@EntryIndexedValue">DLC</s:String>
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=DLC/@EntryIndexedValue">DLC</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=IP/@EntryIndexedValue">IP</s:String>
|
||||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=LBP/@EntryIndexedValue">LBP</s:String>
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=LBP/@EntryIndexedValue">LBP</s:String>
|
||||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=MM/@EntryIndexedValue">MM</s:String>
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=MM/@EntryIndexedValue">MM</s:String>
|
||||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=NAT/@EntryIndexedValue">NAT</s:String>
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=NAT/@EntryIndexedValue">NAT</s:String>
|
||||||
|
|
24
ProjectLighthouse/FakeRemoteIPAddressMiddleware.cs
Normal file
24
ProjectLighthouse/FakeRemoteIPAddressMiddleware.cs
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
using System.Net;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
|
||||||
|
namespace LBPUnion.ProjectLighthouse
|
||||||
|
{
|
||||||
|
public class FakeRemoteIPAddressMiddleware
|
||||||
|
{
|
||||||
|
private readonly RequestDelegate next;
|
||||||
|
private readonly IPAddress fakeIpAddress = IPAddress.Parse("127.0.0.1");
|
||||||
|
|
||||||
|
public FakeRemoteIPAddressMiddleware(RequestDelegate next)
|
||||||
|
{
|
||||||
|
this.next = next;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task Invoke(HttpContext httpContext)
|
||||||
|
{
|
||||||
|
httpContext.Connection.RemoteIpAddress = this.fakeIpAddress;
|
||||||
|
|
||||||
|
await this.next(httpContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -51,7 +51,7 @@ namespace LBPUnion.ProjectLighthouse
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
public virtual void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||||
{
|
{
|
||||||
bool computeDigests = true;
|
bool computeDigests = true;
|
||||||
string serverDigestKey = Environment.GetEnvironmentVariable("SERVER_DIGEST_KEY");
|
string serverDigestKey = Environment.GetEnvironmentVariable("SERVER_DIGEST_KEY");
|
||||||
|
|
18
ProjectLighthouse/TestStartup.cs
Normal file
18
ProjectLighthouse/TestStartup.cs
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
using Microsoft.AspNetCore.Builder;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
|
||||||
|
namespace LBPUnion.ProjectLighthouse
|
||||||
|
{
|
||||||
|
public class TestStartup : Startup
|
||||||
|
{
|
||||||
|
public TestStartup(IConfiguration configuration) : base(configuration)
|
||||||
|
{}
|
||||||
|
|
||||||
|
public override void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||||
|
{
|
||||||
|
app.UseMiddleware<FakeRemoteIPAddressMiddleware>();
|
||||||
|
base.Configure(app, env);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue