From 6b65c956afe39cbb2b6096b008f95f1790deed53 Mon Sep 17 00:00:00 2001 From: James Rosewell Date: Mon, 9 Nov 2026 22:46:51 +0000 Subject: [PATCH 1/2] Let Java use the default JSON endpoint and still accept its old one --- BrowserCache/SessionStorageCacheTests.cs | 9 ++++++--- Examples/ExampleApps.cs | 21 ++++++++++++++++++++- Examples/ExampleDescriptor.cs | 10 ++++++++-- TestsCommon/Helpers/TestHelpers.cs | 22 +++++++++++++--------- 4 files changed, 47 insertions(+), 15 deletions(-) diff --git a/BrowserCache/SessionStorageCacheTests.cs b/BrowserCache/SessionStorageCacheTests.cs index 0aebb0b..c0ee3d9 100644 --- a/BrowserCache/SessionStorageCacheTests.cs +++ b/BrowserCache/SessionStorageCacheTests.cs @@ -168,7 +168,7 @@ private void RunTest(WebDriver driver, bool enableCookies) ClientServerUrl, _app.BaseUrl.ToString(), BuildPage(enableCookies), - ExampleApps.JsonEndpointPath, + ExampleApps.JsonEndpointPaths, clientServerTokenSource.Token); clientServer = serverListener.Listener; clientHttpServer = serverListener.Server; @@ -265,9 +265,12 @@ private static void AssertSameResults( private int CountJsonPosts() { - var expected = $"POST {ExampleApps.JsonEndpointPath}"; + var expected = ExampleApps.JsonEndpointPaths + .Select(p => $"POST {p}") + .ToList(); return clientHttpServer.RequestLog - .Count(r => string.Equals(r, expected, StringComparison.OrdinalIgnoreCase)); + .Count(r => expected.Any(e => string.Equals( + r, e, StringComparison.OrdinalIgnoreCase))); } private static List GetSessionStorageKeys(IJavaScriptExecutor js) diff --git a/Examples/ExampleApps.cs b/Examples/ExampleApps.cs index 4f6414c..998fcb4 100644 --- a/Examples/ExampleApps.cs +++ b/Examples/ExampleApps.cs @@ -32,6 +32,25 @@ public static class ExampleApps ? descriptor.JsonEndpointPath : "/51dpipeline/json"; + /// + /// Every path the selected language's client-side script may post to, + /// being and any older path the + /// language still answers. + /// + public static IReadOnlyList JsonEndpointPaths + { + get + { + var paths = new List { JsonEndpointPath }; + if (Descriptors.TryGetValue(SelectedLang, out var descriptor) + && descriptor.AlternativeJsonEndpointPaths != null) + { + paths.AddRange(descriptor.AlternativeJsonEndpointPaths); + } + return paths; + } + } + /// /// Element the selected language's page renders its client-side results /// into. Read from the descriptor so it is available for the CI case @@ -245,7 +264,7 @@ public static ExampleAppOptions BuildOptions( BuildArgs: new[] { "-pl", "web/getting-started.cloud", "-am", "package", "-DskipTests" }, RunArtifactGlob: "web/getting-started.cloud/target/*-jar-with-dependencies.jar", BuildTimeoutSeconds: 600, - JsonEndpointPath: "/51Degrees.core.json", + AlternativeJsonEndpointPaths: new[] { "/51Degrees.core.json" }, // the java page renders the client-side results into its // Apple detection section rather than the shared container ClientResultsElementId: "apple-detection"), diff --git a/Examples/ExampleDescriptor.cs b/Examples/ExampleDescriptor.cs index f876a1d..f2909c2 100644 --- a/Examples/ExampleDescriptor.cs +++ b/Examples/ExampleDescriptor.cs @@ -23,7 +23,12 @@ namespace FiftyOne.Pipeline.Cloud.SeleniumTests.Examples /// integration picks its own, so a test that proxies or counts those /// requests has to ask the descriptor rather than assume one: dotnet and /// rust use the default, java uses /51Degrees.core.json, and node, python - /// and php use /json. + /// and php use /json, and java uses the default and still answers the + /// older /51Degrees.core.json. + /// + /// + /// Older paths the integration still answers, so a test accepts a build + /// whose script uses either. /// /// /// Id of the element the example's page asks the shared examples helper to @@ -44,5 +49,6 @@ public sealed record ExampleDescriptor( string RunArtifactGlob = null, int BuildTimeoutSeconds = 0, string JsonEndpointPath = "/51dpipeline/json", - string ClientResultsElementId = "content"); + string ClientResultsElementId = "content", + IReadOnlyList AlternativeJsonEndpointPaths = null); } diff --git a/TestsCommon/Helpers/TestHelpers.cs b/TestsCommon/Helpers/TestHelpers.cs index a4ab1b7..70ee654 100644 --- a/TestsCommon/Helpers/TestHelpers.cs +++ b/TestsCommon/Helpers/TestHelpers.cs @@ -103,28 +103,32 @@ public static ServerListener ReverseProxyListener( /// Creates an HttpListener that serves /// for page paths and proxies the 51Degrees script and pipeline /// endpoints to without caching. - /// is the path the client-side - /// script posts refreshed evidence to, which differs per web - /// integration, so the caller supplies the one its example uses. + /// are the paths the client-side + /// script may post refreshed evidence to, which differ per web + /// integration, so the caller supplies the ones its example uses. /// public static ServerListener ExampleProxyListener( string clientUrl, string exampleUrl, string pageData, - string jsonEndpointPath, + IEnumerable jsonEndpointPaths, CancellationToken token) { var listener = new HttpListener(); listener.Prefixes.Add(clientUrl); listener.Start(); + var routes = new Dictionary + { + ["/51Degrees.core.js"] = exampleUrl, + }; + foreach (var path in jsonEndpointPaths) + { + routes[path] = exampleUrl; + } var server = new HttpServer(listener, pageData) { - ProxyRoutes = new Dictionary - { - ["/51Degrees.core.js"] = exampleUrl, - [jsonEndpointPath] = exampleUrl, - }, + ProxyRoutes = routes, ProxiedHeaderOverrides = new Dictionary { ["Cache-Control"] = "no-store", From 1a5291ba3ef65f5264dbca8d3f6ac831e84f2490 Mon Sep 17 00:00:00 2001 From: James Rosewell Date: Tue, 10 Nov 2026 08:36:23 +0000 Subject: [PATCH 2/2] Say once which JSON path each language uses