@@ -3,7 +3,10 @@ import fs from "fs/promises"
33import path from "path"
44import { ServerAuth } from "../../../src/server/auth"
55import { cspForHtml , upstreamURL } from "../../../src/server/shared/ui"
6- import { hasPtyConnectTicketURL , isPtyConnectPath } from "../../../src/server/shared/pty-ticket"
6+ // altimate_change start — upstream_fix: authorize PTY ticket bypass from the matched route (anomalyco/opencode#58258)
7+ import { PTY_CONNECT_PATH } from "../../../src/server/shared/pty-ticket"
8+ import { PtyPaths } from "../../../src/server/routes/instance/httpapi/groups/pty"
9+ // altimate_change end
710import { isPublicUIPath } from "../../../src/server/shared/public-ui"
811
912const repoRoot = path . resolve ( import . meta. dir , ".." , ".." , ".." , ".." , ".." )
@@ -36,13 +39,12 @@ describe("UPI-29 authorization and PTY-ticket boundaries", () => {
3639 }
3740 } )
3841
39- test ( "PTY connect ticket bypass is path-specific and still requires the ticket query" , ( ) => {
40- expect ( isPtyConnectPath ( "/pty/abc/connect" ) ) . toBe ( true )
41- expect ( isPtyConnectPath ( "/pty/abc/other" ) ) . toBe ( false )
42- expect ( hasPtyConnectTicketURL ( new URL ( "http://localhost/pty/abc/connect?ticket=one" ) ) ) . toBe ( true )
43- expect ( hasPtyConnectTicketURL ( new URL ( "http://localhost/pty/abc/connect" ) ) ) . toBe ( false )
44- expect ( hasPtyConnectTicketURL ( new URL ( "http://localhost/session?ticket=one" ) ) ) . toBe ( false )
42+ // altimate_change start — upstream_fix: authorize PTY ticket bypass from the matched route (anomalyco/opencode#58258)
43+ test ( "PTY connect ticket bypass is keyed to the routed connect path" , ( ) => {
44+ expect ( PTY_CONNECT_PATH ) . toBe ( "/pty/:ptyID/connect" )
45+ expect ( PtyPaths . connect ) . toBe ( PTY_CONNECT_PATH )
4546 } )
47+ // altimate_change end
4648
4749 test ( "public UI auth bypass is limited to GET asset paths" , ( ) => {
4850 expect ( isPublicUIPath ( "GET" , "/site.webmanifest" ) ) . toBe ( true )
@@ -66,8 +68,10 @@ describe("UPI-29 authorization and PTY-ticket boundaries", () => {
6668 const ptyBody = source . slice ( source . indexOf ( "export const ptyConnectAuthorizationLayer" ) )
6769 const regularBody = source . slice ( source . indexOf ( "export const authorizationLayer" ) , source . indexOf ( "export const ptyConnectAuthorizationLayer" ) )
6870
69- expect ( ptyBody ) . toContain ( "if (hasPtyConnectTicketURL(url)) return yield* effect" )
70- expect ( regularBody ) . not . toContain ( "hasPtyConnectTicketURL" )
71+ // altimate_change start — upstream_fix: authorize PTY ticket bypass from the matched route (anomalyco/opencode#58258)
72+ expect ( ptyBody ) . toContain ( "route.route.path === PTY_CONNECT_PATH && !!url.searchParams.get(PTY_CONNECT_TICKET_QUERY)" )
73+ expect ( regularBody ) . not . toContain ( "PTY_CONNECT_TICKET_QUERY" )
74+ // altimate_change end
7175 } )
7276} )
7377
0 commit comments