yep
This commit is contained in:
@@ -5,8 +5,8 @@ SET NOCOUNT ON;
|
||||
|
||||
SELECT
|
||||
[Name],
|
||||
CASE Player2Id
|
||||
WHEN NULL THEN 1
|
||||
CASE
|
||||
WHEN Player2Id IS NULL THEN 1
|
||||
ELSE 2
|
||||
END AS PlayerCount
|
||||
FROM [session].[Session];
|
||||
|
||||
@@ -150,7 +150,6 @@ public class SessionController : ControllerBase
|
||||
//}
|
||||
|
||||
[HttpGet]
|
||||
[AllowAnonymous]
|
||||
public async Task<ActionResult<ReadAllSessionsResponse>> GetSessions()
|
||||
{
|
||||
var sessions = await this.queryRespository.ReadAllSessionsMetadata();
|
||||
|
||||
@@ -89,9 +89,8 @@ public class UserController : ControllerBase
|
||||
);
|
||||
}
|
||||
return Ok();
|
||||
|
||||
|
||||
}
|
||||
|
||||
[HttpGet("GuestToken")]
|
||||
public IActionResult GetGuestToken()
|
||||
{
|
||||
|
||||
@@ -1,25 +1,36 @@
|
||||
using Shogi.AcceptanceTests.TestSetup;
|
||||
using Shogi.Contracts.Api;
|
||||
using System.Net;
|
||||
using System.Net.Http.Json;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace Shogi.AcceptanceTests;
|
||||
|
||||
public class AcceptanceTests : IClassFixture<MsalTestFixture>
|
||||
#pragma warning disable xUnit1033 // There is a bug which provides a false positive of xUnit1033.
|
||||
public class AcceptanceTests : IClassFixture<GuestTestFixture>
|
||||
#pragma warning restore xUnit1033
|
||||
{
|
||||
private readonly MsalTestFixture fixture;
|
||||
private readonly GuestTestFixture fixture;
|
||||
private readonly ITestOutputHelper console;
|
||||
|
||||
public AcceptanceTests(MsalTestFixture fixture, ITestOutputHelper console)
|
||||
public AcceptanceTests(GuestTestFixture fixture, ITestOutputHelper console)
|
||||
{
|
||||
this.fixture = fixture;
|
||||
this.console = console;
|
||||
}
|
||||
|
||||
private HttpClient Service => fixture.Service;
|
||||
|
||||
[Fact]
|
||||
public async Task CreateAndReadSession()
|
||||
{
|
||||
var response = await fixture.Service.GetAsync(new Uri("Game", UriKind.Relative));
|
||||
console.WriteLine(await response.Content.ReadAsStringAsync());
|
||||
console.WriteLine(response.Headers.WwwAuthenticate.ToString());
|
||||
response.IsSuccessStatusCode.Should().BeTrue(because: "AAT Client should be authorized.");
|
||||
var createResponse = await Service.PostAsJsonAsync(new Uri("Session", UriKind.Relative), new CreateSessionCommand { Name = "Acceptance Tests" });
|
||||
createResponse.StatusCode.Should().Be(HttpStatusCode.Created);
|
||||
var yep = await createResponse.Content.ReadAsStringAsync();
|
||||
console.WriteLine(yep);
|
||||
|
||||
var readAllResponse = await Service.GetFromJsonAsync<ReadAllSessionsResponse>(new Uri("Session", UriKind.Relative));
|
||||
readAllResponse.Should().NotBeNull();
|
||||
readAllResponse!.AllOtherSessions.Should().ContainSingle(session => session.Name == "Acceptance Tests" && session.PlayerCount == 1);
|
||||
}
|
||||
}
|
||||
@@ -41,4 +41,8 @@
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Shogi.Contracts\Shogi.Contracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Identity.Client;
|
||||
using System.Net.Http.Headers;
|
||||
|
||||
namespace Shogi.AcceptanceTests.TestSetup
|
||||
{
|
||||
@@ -10,7 +8,6 @@ namespace Shogi.AcceptanceTests.TestSetup
|
||||
public class GuestTestFixture : IAsyncLifetime, IDisposable
|
||||
{
|
||||
private bool disposedValue;
|
||||
private readonly IConfidentialClientApplication app;
|
||||
|
||||
public GuestTestFixture()
|
||||
{
|
||||
@@ -24,28 +21,17 @@ namespace Shogi.AcceptanceTests.TestSetup
|
||||
BaseAddress = new Uri(Configuration["ServiceUrl"], UriKind.Absolute)
|
||||
};
|
||||
|
||||
|
||||
publicApp = PublicClientApplicationBuilder
|
||||
.Create(azure["ClientId"])
|
||||
.WithTenantId("common")
|
||||
.Build();
|
||||
|
||||
}
|
||||
|
||||
public IConfiguration Configuration { get; private set; }
|
||||
|
||||
|
||||
public HttpClient Service { get; }
|
||||
|
||||
public async Task InitializeAsync()
|
||||
{
|
||||
var scopes = Configuration.GetSection("Auth:Scopes").Get<string[]>();
|
||||
var authResult = await app
|
||||
.AcquireTokenForClient(scopes)
|
||||
.ExecuteAsync();
|
||||
|
||||
authResult.Should().NotBeNull();
|
||||
authResult.AccessToken.Should().NotBeNullOrEmpty();
|
||||
// Log in as a guest account.
|
||||
var loginResponse = await Service.GetAsync(new Uri("User/LoginAsGuest", UriKind.Relative));
|
||||
loginResponse.EnsureSuccessStatusCode();
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
|
||||
Reference in New Issue
Block a user