-
Notifications
You must be signed in to change notification settings - Fork 0
feat(core): correlate BiDi WebSocket endpoint with exact session #189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
seonghobae
merged 7 commits into
feat/webdriver-bidi-websocket-endpoint
from
feat/webdriver-bidi-websocket-session-correlation
Aug 26, 2026
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5d7906a
test(core): require exact BiDi endpoint session correlation
seonghobae 96fdd9d
style(core): apply canonical BiDi session-correlation formatting
seonghobae c4d2e4d
feat(core): correlate BiDi endpoint with exact session
seonghobae 45935f5
feat(core): export correlated BiDi endpoint contract
seonghobae 70461f1
style(core): apply canonical session-correlation formatting
seonghobae 4047cef
docs(changelog): record BiDi session correlation
seonghobae ba38e2c
merge: carry ChromeDriver session compatibility into correlation
seonghobae File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
crates/originweave-core/tests/webdriver_bidi_websocket_session_correlation.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| use std::error::Error; | ||
|
|
||
| use originweave_core::{ | ||
| WebDriverBiDiWebSocketEndpoint, WebDriverBiDiWebSocketEndpointCorrelationError, | ||
| }; | ||
|
|
||
| const SESSION_ID: &str = "01234567-89ab-cdef-0123-456789abcdef"; | ||
| const OTHER_SESSION_ID: &str = "11234567-89ab-cdef-0123-456789abcdef"; | ||
| const CHROMEDRIVER_SESSION_ID: &str = "0123456789abcdef0123456789abcdef"; | ||
|
|
||
| fn endpoint() -> WebDriverBiDiWebSocketEndpoint { | ||
| let result = | ||
| WebDriverBiDiWebSocketEndpoint::new(&format!("ws://127.0.0.1:9515/session/{SESSION_ID}")); | ||
| assert!(result.is_ok(), "{result:?}"); | ||
| let Ok(endpoint) = result else { | ||
| unreachable!("asserted valid endpoint") | ||
| }; | ||
| endpoint | ||
| } | ||
|
|
||
| #[test] | ||
| fn exact_session_identity_correlation_preserves_bounded_endpoint_metadata() { | ||
| let result = endpoint().correlate_session_id(SESSION_ID); | ||
| assert!(result.is_ok(), "{result:?}"); | ||
| let Ok(correlated) = result else { | ||
| return; | ||
| }; | ||
|
|
||
| assert_eq!( | ||
| correlated.as_str(), | ||
| format!("ws://127.0.0.1:9515/session/{SESSION_ID}") | ||
| ); | ||
| assert!(!correlated.is_secure()); | ||
| assert_eq!(correlated.host(), "127.0.0.1"); | ||
| assert_eq!(correlated.port(), 9515); | ||
| assert_eq!(correlated.session_id(), SESSION_ID); | ||
| } | ||
|
|
||
| #[test] | ||
| fn chromedriver_session_identity_correlation_preserves_exact_session_evidence() { | ||
| let endpoint = WebDriverBiDiWebSocketEndpoint::new(&format!( | ||
| "ws://127.0.0.1:9515/session/{CHROMEDRIVER_SESSION_ID}" | ||
| )); | ||
| assert!(endpoint.is_ok(), "{endpoint:?}"); | ||
| let Ok(endpoint) = endpoint else { | ||
| return; | ||
| }; | ||
|
|
||
| let result = endpoint.correlate_session_id(CHROMEDRIVER_SESSION_ID); | ||
| assert!(result.is_ok(), "{result:?}"); | ||
| let Ok(correlated) = result else { | ||
| return; | ||
| }; | ||
| assert_eq!(correlated.session_id(), CHROMEDRIVER_SESSION_ID); | ||
| } | ||
|
|
||
| #[test] | ||
| fn a_different_canonical_session_identity_fails_closed() { | ||
| assert!(matches!( | ||
| endpoint().correlate_session_id(OTHER_SESSION_ID), | ||
| Err(WebDriverBiDiWebSocketEndpointCorrelationError::SessionIdMismatch) | ||
| )); | ||
| } | ||
|
|
||
| #[test] | ||
| fn malformed_expected_session_identity_is_rejected_before_comparison() { | ||
| for expected in [ | ||
| "", | ||
| "01234567-89ab-cdef-0123-456789abcdeF", | ||
| "0123456789ab-cdef-0123-456789abcdef", | ||
| "01234567-89ab-cdef-0123-456789abcdeg", | ||
| "01234567_89ab-cdef-0123-456789abcdef", | ||
| "0123456789abcdef0123456789abcdeF", | ||
| "0123456789abcdef0123456789abcdeg", | ||
| ] { | ||
| assert!(matches!( | ||
| endpoint().correlate_session_id(expected), | ||
| Err(WebDriverBiDiWebSocketEndpointCorrelationError::InvalidExpectedSessionId) | ||
| )); | ||
| } | ||
| } | ||
|
|
||
| #[test] | ||
| fn session_correlation_errors_are_deterministic_and_source_free() { | ||
| for error in [ | ||
| WebDriverBiDiWebSocketEndpointCorrelationError::InvalidExpectedSessionId, | ||
| WebDriverBiDiWebSocketEndpointCorrelationError::SessionIdMismatch, | ||
| ] { | ||
| assert!(!error.to_string().is_empty()); | ||
| assert!(error.source().is_none()); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.