Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/testingbot/TestingBotReportFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> findSessionIDs(CaseResult testResult) {
List<String> sessions = new ArrayList<>();
Expand Down
46 changes: 46 additions & 0 deletions src/test/java/testingbot/TestingBotSessionIdParsingTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
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<String> found = new ArrayList<>();
TestingBotReportFactory.collectSessionIDs("TestingBotSessionID=" + sid, found);
assertThat(found).containsExactly(sid);
}

@Test
public void capturesPlainHexSessionId() {
List<String> found = new ArrayList<>();
TestingBotReportFactory.collectSessionIDs("log TestingBotSessionID=abc123DEF more", found);
assertThat(found).containsExactly("abc123DEF");
}

@Test
public void capturesMultipleSessionIds() {
List<String> found = new ArrayList<>();
TestingBotReportFactory.collectSessionIDs(
"TestingBotSessionID=aaa-111\nTestingBotSessionID=bbb-222\nTestingBotSessionID=abc_def-123",
found);
assertThat(found).containsExactly("aaa-111", "bbb-222", "abc_def-123");
}

@Test
public void ignoresTextWithoutToken() {
List<String> found = new ArrayList<>();
TestingBotReportFactory.collectSessionIDs("no session here", found);
assertThat(found).isEmpty();
}
}