-
Notifications
You must be signed in to change notification settings - Fork 803
feat(web): relay --auth-file with robot keys, viewer tokens, and the … #3953
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
Merged
Changes from all commits
Commits
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
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
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,103 @@ | ||
| # Copyright 2026 Dimensional Inc. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| """Relay auth browser e2e (the T12d cockpit login, in CI). | ||
|
|
||
| A hand-started relay with --auth-file and one RelayBridgeModule attached | ||
| through relay_url with the robot's key: the hosted-relay shape, on loopback. | ||
| Nothing publishes data: the panel renders in its "waiting for data" state, | ||
| enough to prove that the token-bearing session adopted the manifest. The | ||
| page must show the token form (no token stored), connect and render the | ||
| panel once the token is typed, and return to the form on "log out". | ||
|
|
||
| Marked web_browser: excluded from the default suite (needs the | ||
| `browser-tests` dependency group, Playwright browsers, and built web dists). | ||
| Locally: | ||
| `uv run --group browser-tests pytest -m web_browser dimos/e2e_tests/test_relay_auth_browser.py`. | ||
| """ | ||
|
|
||
| from collections.abc import Iterator | ||
| import json | ||
|
|
||
| import pytest | ||
|
|
||
| from dimos.web.cockpit import Video, cockpit | ||
| from dimos.web.relay_bridge.e2e_support import stop_module | ||
| from dimos.web.relay_bridge.locate import find_web_dir | ||
| from dimos.web.relay_bridge.relay_process import RelayProcess, ensure_web_dist | ||
|
|
||
| pytest.importorskip("playwright") | ||
|
|
||
| from playwright.sync_api import Page, expect, sync_playwright | ||
|
|
||
| pytestmark = pytest.mark.web_browser | ||
|
|
||
| ROBOT_KEY = "robot-key-e2e-0123456789abcdef" | ||
| VIEWER_TOKEN = "viewer-token-e2e-0123456789abcdef" | ||
|
|
||
|
|
||
| @pytest.fixture(scope="module") | ||
| def auth_relay_url(tmp_path_factory: pytest.TempPathFactory) -> Iterator[str]: | ||
| ensure_web_dist(find_web_dir()) | ||
| auth_file = tmp_path_factory.mktemp("auth") / "auth.json" | ||
| auth_file.write_text( | ||
| json.dumps({"robots": {"go2-lab": ROBOT_KEY}, "viewers": {"tester": VIEWER_TOKEN}}) | ||
| ) | ||
| with RelayProcess(auth_file=auth_file) as ready: | ||
| (atom,) = cockpit(layout=Video("color_image")).blueprints | ||
| module = atom.module( | ||
| relay_url=ready.open_url, | ||
| relay_key=ROBOT_KEY, | ||
| open_browser=False, | ||
| web_build=False, | ||
| robot_id="go2-lab", | ||
| **atom.kwargs, | ||
| ) | ||
| module.start() # returns only after hello/welcome: the key was accepted | ||
| try: | ||
| yield ready.open_url | ||
| finally: | ||
| stop_module(module) | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def chromium_page() -> Iterator[Page]: | ||
| with sync_playwright() as p: | ||
| browser = p.chromium.launch() | ||
| try: | ||
| yield browser.new_page() | ||
| finally: | ||
| browser.close() | ||
|
|
||
|
|
||
| def test_token_form_connects_and_logs_out(auth_relay_url: str, chromium_page: Page) -> None: | ||
| page = chromium_page | ||
| page.goto(auth_relay_url) | ||
| # No token stored: the relay rejects the session and the form shows why. | ||
| expect(page.get_by_test_id("token-message")).to_have_text( | ||
| "missing viewer token", timeout=120_000 | ||
| ) | ||
| expect(page.get_by_test_id("log-out")).to_have_count(0) | ||
|
|
||
| page.get_by_test_id("token-input").fill(VIEWER_TOKEN) | ||
| page.get_by_test_id("token-connect").click() | ||
| expect(page.get_by_test_id("status")).to_have_attribute( | ||
| "data-phase", "connected", timeout=60_000 | ||
| ) | ||
| expect(page.get_by_test_id("panel-p0")).to_be_visible(timeout=30_000) | ||
|
|
||
| page.get_by_test_id("log-out").click() | ||
| expect(page.get_by_test_id("token-message")).to_have_text( | ||
| "missing viewer token", timeout=60_000 | ||
| ) |
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
Oops, something went wrong.
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.