yep
This commit is contained in:
@@ -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