fix(cli): resolve CLI-008..013 — format validation, exit-code semantics, debug-stream cancellation/disposal, test coverage
This commit is contained in:
@@ -9,8 +9,19 @@ public class ManagementHttpClient : IDisposable
|
||||
private readonly HttpClient _httpClient;
|
||||
|
||||
public ManagementHttpClient(string baseUrl, string username, string password)
|
||||
: this(new HttpClient(), baseUrl, username, password)
|
||||
{
|
||||
_httpClient = new HttpClient { BaseAddress = new Uri(baseUrl.TrimEnd('/') + "/") };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test-only constructor that accepts a pre-built <see cref="HttpClient"/> (typically
|
||||
/// over a stub <see cref="HttpMessageHandler"/>) so the request/response handling can
|
||||
/// be exercised without a live server.
|
||||
/// </summary>
|
||||
internal ManagementHttpClient(HttpClient httpClient, string baseUrl, string username, string password)
|
||||
{
|
||||
_httpClient = httpClient;
|
||||
_httpClient.BaseAddress = new Uri(baseUrl.TrimEnd('/') + "/");
|
||||
var credentials = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{username}:{password}"));
|
||||
_httpClient.DefaultRequestHeaders.Authorization =
|
||||
new AuthenticationHeaderValue("Basic", credentials);
|
||||
|
||||
Reference in New Issue
Block a user