railiance-platform/tests/test_operator_browser.py
codex c89ac18d24
All checks were successful
CCR intake gate / gate (push) Successful in 1m12s
CI Smoke / host-smoke (push) Successful in 0s
CI Smoke / container-smoke (push) Successful in 1s
Open the OpenBao login in an empty browser profile.
The default Windows session stayed signed in as another account, so the
attended launcher now starts Edge or Chrome with a fresh profile.

Assistant: grok
Assistant-Session: 01a198fa-fd27-7e41-a0a2-57355c3e4efd
2026-11-02 02:42:57 +01:00

24 lines
1.5 KiB
Python

import runpy
from pathlib import Path
import unittest
from urllib.parse import urlencode
launcher=runpy.run_path(str(Path(__file__).resolve().parents[1]/'scripts/operator-browser/xdg-open'))
allowed=launcher['allowed']
launch_argv=launcher['launch_argv']
class BrowserBoundary(unittest.TestCase):
def test_approved_flow(self):
self.assertTrue(allowed('https://kc.coulomb.social/authorize?'+urlencode({'redirect_uri':'http://localhost:8250/oidc/callback','state':'test'})))
def test_other_destination_rejected(self):
for host in ['evil.example','kc.coulomb.social.evil.example','user@kc.coulomb.social']:
self.assertFalse(allowed('https://'+host+'/?'+urlencode({'redirect_uri':'http://localhost:8250/oidc/callback'})))
def test_unapproved_callback_rejected(self):
self.assertFalse(allowed('https://kc.coulomb.social/?'+urlencode({'redirect_uri':'https://evil.example'})))
def test_duplicate_callback_rejected(self):
self.assertFalse(allowed('https://kc.coulomb.social/?redirect_uri=http://localhost:8250/oidc/callback&redirect_uri=https://evil.example'))
def test_launch_uses_empty_profile(self):
url='https://kc.coulomb.social/authorize?'+urlencode({'redirect_uri':'http://localhost:8250/oidc/callback'})
argv=launch_argv(r'C:\Edge\msedge.exe', r'C:\fresh\profile', url)
self.assertEqual(argv[0], r'C:\Edge\msedge.exe')
self.assertIn(r'--user-data-dir=C:\fresh\profile', argv)
self.assertEqual(argv[-1], url)
self.assertNotIn('explorer.exe', ' '.join(argv))