Files
ClawdDotNet/tests/ClawdDotNet.Core.Tests/Deploymentcenter/DeploymentcenterApiTests.cs
T
RichardandClaude Opus 5.5 837a634a22 Stufe 4c (#764): Kommentare in C#, WebUI-Skripten, CSS und HTML auf Englisch
Rund 2.600 Kommentarblöcke in 310 C#-Dateien übersetzt, Begründungen vollständig
erhalten: blockweise gleiche Anzahl wie vorher, kein Block unter 60 % seiner
Länge, der Code außerhalb der Kommentare per Tokenizer byte-identisch geprüft.
Zitate deutscher Oberflächentexte und Testdaten bleiben deutsch.

WebUI: Kommentare in JS/CSS/HTML übersetzt, JSDoc-@param an die in 4b
umbenannten Parameter angeglichen.

Dabei behoben:
- 4b hatte "tag" (HTML-Tag) als deutsches "Tag" gelesen und zu "dayValue"
  gemacht (makeElement, svg, Tagesübersicht) - zurück auf tag/day.
- Aufgaben "InProgress" bekamen die Plakettenart "laufend", für die es nie eine
  CSS-Klasse gab - jetzt "success" wie laufende Instanzen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 12:45:03 +02:00

70 lines
2.4 KiB
C#

using System.Net;
using ClawdDotNet.Core.Deploymentcenter;
using Shouldly;
namespace ClawdDotNet.Core.Tests.Deploymentcenter;
public sealed class DeploymentcenterApiTests
{
[Fact]
public async Task Token_geht_als_Bearer_mit()
{
var handler = new CapturingHandler();
using var api = new DeploymentcenterApi("https://dc.example", "tok-1", new HttpClient(handler));
await api.PostAsync("/api/health", new { }, default);
handler.LastRequest!.Headers.Authorization!.ToString().ShouldBe("Bearer tok-1");
}
[Fact]
public async Task Fehlerumschlag_wird_zu_einer_Ausnahme_mit_Code()
{
var handler = new CapturingHandler(HttpStatusCode.Unauthorized,
"""{"status":"error","error":{"code":"unauthorized","message":"Kein gueltiges Token."}}""");
using var api = new DeploymentcenterApi("https://dc.example", "tok", new HttpClient(handler));
var ex = await Should.ThrowAsync<DeploymentcenterException>(
() => api.PostAsync("/api/watchdog/v1/ping", new { }, default));
ex.Code.ShouldBe("unauthorized");
ex.IsAuthorizationProblem.ShouldBeTrue();
}
/// <summary>
/// An error envelope counts even if the status code is 200 — the server
/// does not answer with a matching HTTP code everywhere.
/// </summary>
[Fact]
public async Task Fehlerumschlag_mit_HTTP_200_zaehlt_trotzdem()
{
var handler = new CapturingHandler(HttpStatusCode.OK,
"""{"status":"error","error":{"code":"rate_limited","message":"Zu viele."}}""");
using var api = new DeploymentcenterApi("https://dc.example", "tok", new HttpClient(handler));
var ex = await Should.ThrowAsync<DeploymentcenterException>(
() => api.PostAsync("/x", new { }, default));
ex.Code.ShouldBe("rate_limited");
ex.IsAuthorizationProblem.ShouldBeFalse();
}
[Fact]
public void Nicht_HTTPS_wird_abgelehnt()
{
// Over an unsecured connection the token would go in plain text.
Should.Throw<ArgumentException>(() => new DeploymentcenterApi("http://dc.example", "tok"));
}
[Fact]
public void Localhost_darf_auch_ohne_TLS()
{
// A local test installation rarely has a certificate, and nobody can listen in
// on the own machine.
using var api = new DeploymentcenterApi("http://localhost:8080", "tok");
api.BaseUrl.ShouldBe("http://localhost:8080");
}
}