From 90e9658dc8375b63cb978e7d40311a90e648ae4a Mon Sep 17 00:00:00 2001 From: Jochen Delabie Date: Fri, 17 Jul 2026 16:12:27 +0200 Subject: [PATCH 1/2] Accept hyphens in TestingBotSessionID so modern session ids resolve Modern TestingBot / W3C WebDriver session ids are hyphenated (e.g. b0dbacacfa63-342d529ca760-...). The extraction pattern was TestingBotSessionID=([A-Za-z0-9]+), which stopped at the first hyphen and captured only the leading segment. That truncated id 404s against the TestingBot REST API (the full id maps to an internal test id) and, because getAuthenticationHash() then hashes the wrong string, the embedded mini iframe and share links break too. Net effect: every embedded report, Build page and GitHub-checks summary silently failed for real sessions. Widen the character class to [A-Za-z0-9_-]+ and add TestingBotSessionIdParsingTest covering hyphenated, plain, multiple and no-match inputs. --- .../testingbot/TestingBotReportFactory.java | 2 +- .../TestingBotSessionIdParsingTest.java | 45 +++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 src/test/java/testingbot/TestingBotSessionIdParsingTest.java diff --git a/src/main/java/testingbot/TestingBotReportFactory.java b/src/main/java/testingbot/TestingBotReportFactory.java index f97d974..fd1c4b1 100644 --- a/src/main/java/testingbot/TestingBotReportFactory.java +++ b/src/main/java/testingbot/TestingBotReportFactory.java @@ -24,7 +24,7 @@ public TestingBotReportFactory(TestingBotCredentials credentials) { this.credentials = credentials; } - private static final Pattern SESSION_PATTERN = Pattern.compile("TestingBotSessionID=([A-Za-z0-9]+)"); + private static final Pattern SESSION_PATTERN = Pattern.compile("TestingBotSessionID=([A-Za-z0-9_-]+)"); public static List findSessionIDs(CaseResult testResult) { List sessions = new ArrayList<>(); diff --git a/src/test/java/testingbot/TestingBotSessionIdParsingTest.java b/src/test/java/testingbot/TestingBotSessionIdParsingTest.java new file mode 100644 index 0000000..a6b62f2 --- /dev/null +++ b/src/test/java/testingbot/TestingBotSessionIdParsingTest.java @@ -0,0 +1,45 @@ +package testingbot; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.ArrayList; +import java.util.List; +import org.junit.Test; + +/** + * Verifies the {@code TestingBotSessionID=} token parser accepts the full session + * id, including the hyphens present in modern WebDriver session ids. A truncated id + * would 404 against the TestingBot REST API and break every embedded report. + */ +public class TestingBotSessionIdParsingTest { + + @Test + public void capturesHyphenatedSessionId() { + String sid = "b0dbacacfa63-342d529ca760-2f981532f469-178429199039-61532530"; + List found = new ArrayList<>(); + TestingBotReportFactory.collectSessionIDs("TestingBotSessionID=" + sid, found); + assertThat(found).containsExactly(sid); + } + + @Test + public void capturesPlainHexSessionId() { + List found = new ArrayList<>(); + TestingBotReportFactory.collectSessionIDs("log TestingBotSessionID=abc123DEF more", found); + assertThat(found).containsExactly("abc123DEF"); + } + + @Test + public void capturesMultipleSessionIds() { + List found = new ArrayList<>(); + TestingBotReportFactory.collectSessionIDs( + "TestingBotSessionID=aaa-111\nTestingBotSessionID=bbb-222", found); + assertThat(found).containsExactly("aaa-111", "bbb-222"); + } + + @Test + public void ignoresTextWithoutToken() { + List found = new ArrayList<>(); + TestingBotReportFactory.collectSessionIDs("no session here", found); + assertThat(found).isEmpty(); + } +} From 3ce76dd7d6c29bbe12f4d47830be6f3d6d90819c Mon Sep 17 00:00:00 2001 From: Jochen Delabie Date: Fri, 17 Jul 2026 17:37:58 +0200 Subject: [PATCH 2/2] Cover underscore in session-id parsing test The pattern allows [A-Za-z0-9_-]+; add an underscore-containing id (abc_def-123) to capturesMultipleSessionIds so the underscore branch of the character class is exercised alongside the hyphenated ids. --- src/test/java/testingbot/TestingBotSessionIdParsingTest.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/test/java/testingbot/TestingBotSessionIdParsingTest.java b/src/test/java/testingbot/TestingBotSessionIdParsingTest.java index a6b62f2..9285a97 100644 --- a/src/test/java/testingbot/TestingBotSessionIdParsingTest.java +++ b/src/test/java/testingbot/TestingBotSessionIdParsingTest.java @@ -32,8 +32,9 @@ public void capturesPlainHexSessionId() { public void capturesMultipleSessionIds() { List found = new ArrayList<>(); TestingBotReportFactory.collectSessionIDs( - "TestingBotSessionID=aaa-111\nTestingBotSessionID=bbb-222", found); - assertThat(found).containsExactly("aaa-111", "bbb-222"); + "TestingBotSessionID=aaa-111\nTestingBotSessionID=bbb-222\nTestingBotSessionID=abc_def-123", + found); + assertThat(found).containsExactly("aaa-111", "bbb-222", "abc_def-123"); } @Test