ServerPack web open: a request never prints its URL; Windows error wording
WebOpenRequest is a record, so its generated ToString printed the URL, which can carry a one-time code. It now names the title only. The browser failure reads "Couldn't open your browser (Windows error N)." Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
8ceba81070
commit
8dda4fdf96
3 changed files with 26 additions and 4 deletions
|
|
@ -10,12 +10,28 @@ internal static class ServerWebOpenTests
|
|||
public static void Register(Runner r)
|
||||
{
|
||||
r.Add("web open: only https on an allowed host, and the route follows the engine", Rules);
|
||||
r.Add("web open: a request never prints its URL, and the browser's error says Windows", NoUrlInText);
|
||||
}
|
||||
|
||||
private static readonly string[] Hosts = { "www.acdreamweave.com" };
|
||||
private static readonly string[] Wild = { "*.acdreamweave.com" };
|
||||
private const string Key = "dreamweave/0123456789abcdef0123456789abcdef";
|
||||
|
||||
private static void NoUrlInText()
|
||||
{
|
||||
const string secret = "AbCdEfGhIjKlMnOpQrStUvWxYz0123456789-_AbCde";
|
||||
var r = new WebOpenRequest("https://www.acdreamweave.com/launch?code=" + secret + "&to=%2Fmarket", Hosts, Key, "DreamWeave");
|
||||
Check.Eq(r.ToString(), "WebOpenRequest(DreamWeave)", "ToString names the title only");
|
||||
Check.False(r.ToString().Contains(secret, StringComparison.Ordinal), "ToString never carries the code");
|
||||
Check.False(("" + r).Contains("acdreamweave", StringComparison.Ordinal), "nor the URL");
|
||||
Check.False((r with { Title = "x" }).ToString().Contains(secret, StringComparison.Ordinal), "a copy neither");
|
||||
|
||||
string web = System.IO.File.ReadAllText(System.IO.Path.Combine(ServerProjectsTests.PluginsDir(), "Shared", "ServerPack", "ServerPackWeb.cs"));
|
||||
Check.True(web.Contains("$\"Couldn't open your browser (Windows error {code}).\"", StringComparison.Ordinal), "the browser failure names the Windows error");
|
||||
Check.True(web.Contains("\"Couldn't open your browser (Windows error 0).\"", StringComparison.Ordinal), "and its exception path");
|
||||
Check.False(web.Contains("(code ", StringComparison.Ordinal), "the old \"(code N)\" wording is gone");
|
||||
}
|
||||
|
||||
private static void Rules()
|
||||
{
|
||||
Check.True(ServerWebOpen.IsAllowedUrl("https://www.acdreamweave.com/x", Hosts), "https on the host");
|
||||
|
|
|
|||
Loading…
Reference in a new issue