Release 1.0.8-rc13
All checks were successful
Dotnet build and test / build (pull_request) Successful in 15m13s
Forgejo Release / release (push) Successful in 13m14s

This commit is contained in:
Paul Schneider 2026-09-06 18:02:30 +01:00
commit 369a8eb3c8
Signed by: notazof
GPG key ID: 1DD5D838E5343B06
3 changed files with 118 additions and 1 deletions

View file

@ -0,0 +1,61 @@
using System.Net;
using System.Net.Http.Headers;
using Microsoft.Extensions.DependencyInjection;
using Yavsc.Api.Test.Fixtures;
using Yavsc.Helpers;
using Yavsc.Models;
using Yavsc.Tests.Shared;
namespace Yavsc.Api.Test;
[Collection("Yavsc Api")]
public sealed class FrontOfficeApiControllerTests : IClassFixture<ApiWebServerFixture>
{
private readonly ApiWebServerFixture _fixture;
public FrontOfficeApiControllerTests(ApiWebServerFixture fixture)
{
_fixture = fixture;
}
private HttpClient NewClient(string subject = "alice", string scope = "api")
{
var handler = new HttpClientHandler
{
ServerCertificateCustomValidationCallback = (_, _, _, _) => true
};
var http = new HttpClient(handler)
{
BaseAddress = new Uri(_fixture.BaseAddress)
};
http.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Bearer", TestTokenIssuer.Issue(subject, scope));
return http;
}
[Fact]
public async Task Front_accept_query_updates_status_without_server_error()
{
WorkflowHelpers.ConfigureBillingService();
_fixture.ResetAndSeedRdvQueryGraph();
long queryId;
using (var scope = _fixture.Services.CreateScope())
{
var db = scope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
queryId = db.RdvQueries.Select(q => q.Id).Single();
}
using var http = NewClient();
var response = await http.PostAsync($"/api/v1/front/query/accept?billingCode=Rdv&queryId={queryId}", content: null, TestContext.Current.CancellationToken);
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
using var assertScope = _fixture.Services.CreateScope();
var assertDb = assertScope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
var updated = assertDb.RdvQueries.Single(q => q.Id == queryId);
Assert.Equal(QueryStatus.Accepted, updated.Status);
}
}

View file

@ -1,6 +1,7 @@
using System.Reflection;
using Microsoft.EntityFrameworkCore;
using Yavsc.Abstract.Workflow;
using Yavsc.Helpers;
using Yavsc.Models;
namespace Yavsc.Services
@ -35,7 +36,34 @@ namespace Yavsc.Services
public static IQuery GetBillable(ApplicationDbContext context, string billingCode, long queryId)
{
throw new NotImplementedException();
if (context is null) throw new ArgumentNullException(nameof(context));
if (string.IsNullOrWhiteSpace(billingCode) || queryId <= 0)
{
return null;
}
if (Billing.Count == 0)
{
WorkflowHelpers.ConfigureBillingService();
}
var getter = Billing
.FirstOrDefault(kvp => string.Equals(kvp.Key, billingCode.Trim(), StringComparison.OrdinalIgnoreCase))
.Value;
if (getter is null)
{
return null;
}
try
{
return getter(context, queryId);
}
catch (InvalidOperationException)
{
return null;
}
}