save progress
This commit is contained in:
@@ -1,11 +1,31 @@
|
||||
using System;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
|
||||
namespace StellaOps.Scanner.WebService.Tests;
|
||||
|
||||
public sealed class ScannerApplicationFixture : IDisposable
|
||||
{
|
||||
private ScannerApplicationFactory? _authenticatedFactory;
|
||||
|
||||
public ScannerApplicationFactory Factory { get; } = new();
|
||||
|
||||
public void Dispose() => Factory.Dispose();
|
||||
/// <summary>
|
||||
/// Creates an HTTP client with test authentication enabled.
|
||||
/// </summary>
|
||||
public HttpClient CreateAuthenticatedClient()
|
||||
{
|
||||
_authenticatedFactory ??= Factory.WithOverrides(useTestAuthentication: true);
|
||||
var client = _authenticatedFactory.CreateClient();
|
||||
// Add a valid test bearer token (must have at least 3 dot-separated segments per TestAuthenticationHandler)
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "test.valid.token");
|
||||
return client;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_authenticatedFactory?.Dispose();
|
||||
Factory.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user