using System.Net.Http.Headers;
using Bit.Api.IntegrationTest.Factories;
namespace Bit.Api.IntegrationTest.Helpers;
///
/// Helper methods for performance tests to reduce code duplication.
///
public static class PerformanceTestHelpers
{
///
/// Standard password hash used across performance tests.
///
public const string StandardPasswordHash = "c55hlJ/cfdvTd4awTXUqow6X3cOQCfGwn11o3HblnPs=";
///
/// Authenticates an HttpClient with a bearer token for the specified user.
///
/// The application factory to use for login.
/// The HttpClient to authenticate.
/// The user's email address.
/// The user's master password hash. Defaults to StandardPasswordHash.
public static async Task AuthenticateClientAsync(
SqlServerApiApplicationFactory factory,
HttpClient client,
string email,
string? masterPasswordHash = null)
{
var tokens = await factory.LoginAsync(email, masterPasswordHash ?? StandardPasswordHash);
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokens.Token);
}
}