Stufe 4c (#764): Bezeichner auf Englisch - Typen, Methoden, Felder, Parameter, Locals, Testnamen
Mit Roslyn umbenannt (Verweise folgen, Zeichenketten bleiben unberuehrt). Nicht umbenannt, weil gespeichert oder ueber die API gebunden (Stufe 4e): Properties, Record-Parameter, Enum-Member sowie die Parameter der Endpunkt-Handler (Routen-/Query-Bindung ueber den Namen). Die JSON-Felder anonymer Objekte bleiben ausdruecklich benannt (JsonFilter: pfad). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
837a634a22
commit
77062facc9
@@ -11,7 +11,7 @@ namespace ClawdDotNet.Web.Tests;
|
||||
/// </summary>
|
||||
public sealed class WebUiOptionsTests
|
||||
{
|
||||
private static InstanceConfig Instanz(
|
||||
private static InstanceConfig Instance(
|
||||
bool enabled = true,
|
||||
string binding = "loopback",
|
||||
string token = "ein-hinreichend-langes-token",
|
||||
@@ -25,7 +25,7 @@ public sealed class WebUiOptionsTests
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void Sie_ist_in_der_Vorbelegung_aus()
|
||||
public void It_is_off_by_default()
|
||||
{
|
||||
// Whoever wants a network service switches it on. Not the other way round.
|
||||
new InstanceConfig().WebUiEnabled.ShouldBeFalse();
|
||||
@@ -34,25 +34,25 @@ public sealed class WebUiOptionsTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Abgeschaltet_ist_kein_Fehler()
|
||||
public void Switched_off_is_not_an_error()
|
||||
{
|
||||
WebUiOptions.TryCreate(Instanz(enabled: false), out var problem).ShouldBeNull();
|
||||
WebUiOptions.TryCreate(Instance(enabled: false), out var problem).ShouldBeNull();
|
||||
problem.ShouldBeNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Ohne_Token_startet_sie_nicht_einmal_auf_Loopback()
|
||||
public void Without_token_it_does_not_start_even_on_loopback()
|
||||
{
|
||||
// On a machine on which agents operate browser tools,
|
||||
// "localhost" is no trust boundary.
|
||||
WebUiOptions.TryCreate(Instanz(token: ""), out var problem).ShouldBeNull();
|
||||
WebUiOptions.TryCreate(Instance(token: ""), out var problem).ShouldBeNull();
|
||||
problem.ShouldNotBeNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Alle_Adressen_ohne_Token_werden_abgelehnt_und_nicht_bemaengelt()
|
||||
public void All_addresses_without_token_are_rejected_and_not_flagged()
|
||||
{
|
||||
var options = WebUiOptions.TryCreate(Instanz(binding: "any", token: ""), out var problem);
|
||||
var options = WebUiOptions.TryCreate(Instance(binding: "any", token: ""), out var problem);
|
||||
|
||||
options.ShouldBeNull();
|
||||
problem.ShouldNotBeNull();
|
||||
@@ -60,16 +60,16 @@ public sealed class WebUiOptionsTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Ein_zu_kurzes_Token_zaehlt_nicht()
|
||||
public void A_too_short_token_does_not_count()
|
||||
{
|
||||
WebUiOptions.TryCreate(Instanz(token: "kurz"), out var problem).ShouldBeNull();
|
||||
WebUiOptions.TryCreate(Instance(token: "kurz"), out var problem).ShouldBeNull();
|
||||
problem.ShouldNotBeNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Loopback_bindet_an_127_0_0_1()
|
||||
public void Loopback_binds_to_127_0_0_1()
|
||||
{
|
||||
var options = WebUiOptions.TryCreate(Instanz(port: 9001), out _);
|
||||
var options = WebUiOptions.TryCreate(Instance(port: 9001), out _);
|
||||
|
||||
options.ShouldNotBeNull();
|
||||
options!.Url.ShouldBe("http://127.0.0.1:9001");
|
||||
@@ -77,17 +77,17 @@ public sealed class WebUiOptionsTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Alles_ausser_any_bleibt_Loopback()
|
||||
public void Everything_except_any_stays_loopback()
|
||||
{
|
||||
// A typo in the instance file must not put the user interface onto the network.
|
||||
WebUiOptions.TryCreate(Instanz(binding: "alle"), out _)!.LoopbackOnly.ShouldBeTrue();
|
||||
WebUiOptions.TryCreate(Instanz(binding: ""), out _)!.LoopbackOnly.ShouldBeTrue();
|
||||
WebUiOptions.TryCreate(Instance(binding: "alle"), out _)!.LoopbackOnly.ShouldBeTrue();
|
||||
WebUiOptions.TryCreate(Instance(binding: ""), out _)!.LoopbackOnly.ShouldBeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Mit_Token_darf_sie_an_alle_Adressen()
|
||||
public void With_token_it_may_reach_all_addresses()
|
||||
{
|
||||
var options = WebUiOptions.TryCreate(Instanz(binding: "ANY"), out _);
|
||||
var options = WebUiOptions.TryCreate(Instance(binding: "ANY"), out _);
|
||||
|
||||
options.ShouldNotBeNull();
|
||||
options!.LoopbackOnly.ShouldBeFalse();
|
||||
@@ -98,20 +98,20 @@ public sealed class WebUiOptionsTests
|
||||
[InlineData(0)]
|
||||
[InlineData(-1)]
|
||||
[InlineData(70000)]
|
||||
public void Ein_unmoeglicher_Port_wird_abgelehnt(int port)
|
||||
public void An_impossible_port_is_rejected(int port)
|
||||
{
|
||||
WebUiOptions.TryCreate(Instanz(port: port), out var problem).ShouldBeNull();
|
||||
WebUiOptions.TryCreate(Instance(port: port), out var problem).ShouldBeNull();
|
||||
problem.ShouldNotBeNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Das_Token_steht_geschuetzt_in_der_Instanzdatei()
|
||||
public void The_token_is_stored_protected_in_the_instance_file()
|
||||
{
|
||||
// Without the entry in ConfigSecrets it would be in plain text next to the
|
||||
// protected OpenRouter key.
|
||||
Core.Security.ConfigSecrets.IsSecretKey("webUiToken").ShouldBeTrue();
|
||||
|
||||
var config = Instanz(token: "ein-hinreichend-langes-token");
|
||||
var config = Instance(token: "ein-hinreichend-langes-token");
|
||||
Core.Security.ConfigSecrets.Protect(config);
|
||||
|
||||
config.WebUiToken.ShouldNotBe("ein-hinreichend-langes-token");
|
||||
|
||||
Reference in New Issue
Block a user