c42529e3fd
Co-authored-by: Cursor <cursoragent@cursor.com>
33 lines
917 B
Python
33 lines
917 B
Python
"""中控 Bridge SSO / Token 冒烟."""
|
|
from __future__ import annotations
|
|
|
|
import unittest
|
|
|
|
from lib.hub.hub_bridge_auth import (
|
|
make_sso_token,
|
|
verify_sso_token,
|
|
build_embed_open_url,
|
|
)
|
|
|
|
|
|
class HubBridgeAuthTests(unittest.TestCase):
|
|
def test_sso_roundtrip(self):
|
|
tok = make_sso_token("secret-token", ttl_sec=60)
|
|
self.assertTrue(verify_sso_token(tok, "secret-token"))
|
|
self.assertFalse(verify_sso_token(tok, "other"))
|
|
self.assertFalse(verify_sso_token("bad", "secret-token"))
|
|
|
|
def test_embed_open_url(self):
|
|
url = build_embed_open_url(
|
|
"https://okx.example.com",
|
|
bridge_token="abc",
|
|
embed_path="/embed",
|
|
)
|
|
self.assertTrue(url.startswith("https://okx.example.com/hub_sso?"))
|
|
self.assertIn("token=", url)
|
|
self.assertIn("next=%2Fembed", url)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|