Files
PnvPanel/backend/tests/PnvPanel.IntegrationTests/TestSupport/HttpClientJsonExtensions.cs
T
Leonid Pershin ed07221ca5
CI / Backend (build + test) (push) Failing after 1m35s
CI / Frontend (lint + typecheck + build) (push) Successful in 35s
Enhance Docker setup and user notification features
- Updated docker-compose.yml to include environment variables and health checks for the app service.
- Modified Dockerfile to install curl for health checks and adjusted the build process for backend services.
- Improved user notification handling in activation, blocking, and config revocation commands by integrating Telegram notifications.
- Added new test cases to validate the updated command handlers and Telegram notifier functionality.
- Enhanced documentation to reflect the new Telegram bot features and user management improvements.
2026-07-02 01:16:53 +03:00

23 lines
961 B
C#

using System.Net.Http.Headers;
using System.Net.Http.Json;
using System.Text.Json;
namespace PnvPanel.IntegrationTests.TestSupport;
public static class HttpClientJsonExtensions
{
public static readonly JsonSerializerOptions JsonOptions = new(JsonSerializerDefaults.Web);
public static void UseBearerToken(this HttpClient client, string accessToken)
=> client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
public static async Task<T?> ReadAsAsync<T>(this HttpResponseMessage response)
=> await response.Content.ReadFromJsonAsync<T>(JsonOptions);
public static Task<HttpResponseMessage> PostJsonAsync(this HttpClient client, string url, object body)
=> client.PostAsJsonAsync(url, body, JsonOptions);
public static Task<HttpResponseMessage> SendPutJsonAsync(this HttpClient client, string url, object body)
=> client.PutAsJsonAsync(url, body, JsonOptions);
}