The SDI dashboard (mockup 058) with its six counters, the documents to
generate, generate+send, manual receipts import, history, courtesy copy
and mark-as-sent; the channels page (mockup 059) with settings, test,
pause and routing rules; the received invoices, the notifications and
the conservation packages. The SdICoop web service receives pushes at
/sdicoop/{company}, authenticated by the key of the channel, through a
new IEInvoicePushReader feature so the web layer stays country-neutral.
The menu gives each e-invoice page its own permission and keeps the
intent declarations under M10.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9d7cb9e71f
commit
b78260beb0
21 files changed
+2414
-6
No files matched your search
@@ -237,6 +237,55 @@ public sealed class EInvoiceTests
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task TheSdi_PushesANotification_WithTheKeyOfTheChannel()
|
||||
{
|
||||
var (app, address, company) = await TestInstance.StartAsync(CancellationToken.None);
|
||||
await using (app)
|
||||
{
|
||||
await SeedAsync(app.Services, company);
|
||||
var service = app.Services.GetRequiredService<EInvoiceService>();
|
||||
var waiting = (await service.DashboardAsync(Root, company, new EInvoiceFilter(EInvoiceView.Issued))).Rows.First(r => r.Invoice.Status == EInvoiceStatus.Sent).Invoice;
|
||||
var receipt = DemoEInvoiceSeeder.Notification("RicevutaConsegna",
|
||||
$"<IdentificativoSdI>{waiting.ExchangeId ?? "555000111"}</IdentificativoSdI><NomeFile>{waiting.FileName}</NomeFile><Hash>x</Hash>"
|
||||
+ "<DataOraRicezione>2026-11-12T10:00:00</DataOraRicezione><DataOraConsegna>2026-11-12T10:05:00</DataOraConsegna><MessageId>9</MessageId>");
|
||||
var stem = waiting.FileName[..waiting.FileName.IndexOf(".xml", StringComparison.Ordinal)];
|
||||
var soap = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"><soapenv:Body>"
|
||||
+ "<typ:fileSdI xmlns:typ=\"http://www.fatturapa.gov.it/sdi/ws/trasmissione/v1.0/types\">"
|
||||
+ $"<IdentificativoSdI>{waiting.ExchangeId ?? "555000111"}</IdentificativoSdI><NomeFile>{stem}_RC_009.xml</NomeFile><File>{Convert.ToBase64String(receipt)}</File>"
|
||||
+ "</typ:fileSdI></soapenv:Body></soapenv:Envelope>";
|
||||
using var client = new HttpClient { BaseAddress = address };
|
||||
async Task<HttpResponseMessage> PostAsync(string? key, string body)
|
||||
{
|
||||
using var request = new HttpRequestMessage(HttpMethod.Post, "sdicoop/" + company) { Content = new StringContent(body, Encoding.UTF8, "text/xml") };
|
||||
if (key is not null)
|
||||
{
|
||||
request.Headers.Add(SdiPushService.KeyHeader, key);
|
||||
}
|
||||
|
||||
return await client.SendAsync(request);
|
||||
}
|
||||
|
||||
// The channel has no key yet: nobody gets in.
|
||||
Assert.AreEqual(System.Net.HttpStatusCode.Unauthorized, (await PostAsync("chiave", soap)).StatusCode);
|
||||
|
||||
var channels = app.Services.GetRequiredService<EInvoiceChannelService>();
|
||||
await channels.SaveAsync(Root, company, new EInvoiceChannelInput { Code = "SDICOOP", Enabled = true, Endpoint = "https://sdi.example.test/trasmissione", ApiKey = "chiave-di-prova" });
|
||||
Assert.AreEqual(System.Net.HttpStatusCode.Unauthorized, (await PostAsync("chiave-sbagliata", soap)).StatusCode);
|
||||
Assert.AreEqual(System.Net.HttpStatusCode.Unauthorized, (await PostAsync(null, soap)).StatusCode);
|
||||
Assert.AreEqual(System.Net.HttpStatusCode.BadRequest, (await PostAsync("chiave-di-prova", "<niente/>")).StatusCode);
|
||||
Assert.AreEqual(System.Net.HttpStatusCode.NotFound, (await client.PostAsync("sdicoop/NESSUNA", new StringContent(soap))).StatusCode);
|
||||
|
||||
var accepted = await PostAsync("chiave-di-prova", soap);
|
||||
Assert.AreEqual(System.Net.HttpStatusCode.OK, accepted.StatusCode, await accepted.Content.ReadAsStringAsync());
|
||||
StringAssert.Contains(await accepted.Content.ReadAsStringAsync(), "Envelope");
|
||||
var history = await service.HistoryAsync(Root, company, waiting.Family, waiting.DocumentId);
|
||||
Assert.AreEqual(EInvoiceStatus.Delivered, history[0].Invoice.Status);
|
||||
Assert.AreEqual("RC", history[0].Notifications[^1].Code);
|
||||
await app.StopAsync();
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task SeedAsync(IServiceProvider services, string company)
|
||||
{
|
||||
var activation = await services.GetRequiredService<ILicenseActivationService>().ActivateAsync(Root, "KH-TEST-ALL-0000-9999");
|
||||
|
||||
Reference in new issue
Block a user