Assistant: codex Assistant-Model: gpt-6-astra Assistant-Session: 01a06ecb-456a-71c2-b41e-0755d336e883
15 lines
1 KiB
Python
15 lines
1 KiB
Python
import runpy
|
|
from pathlib import Path
|
|
import unittest
|
|
from urllib.parse import urlencode
|
|
allowed=runpy.run_path(str(Path(__file__).resolve().parents[1]/'scripts/operator-browser/xdg-open'))['allowed']
|
|
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'))
|