test: strengthen background shell output verification

This commit is contained in:
2026-10-18 20:23:43 +01:00
parent ded7927778
commit f5f682a990
6 changed files with 344 additions and 27 deletions
+17 -1
View File
@@ -15,6 +15,9 @@ const LargeChatFixtureSessionID = "ses_large_chat_fixture"
const LargeChatFixturePassword = "large-chat-fixture"
const LargeChatFixtureShellID = "sh_large_chat_fixture"
const LargeChatFixtureShellOutput = "fixture shell output marker\n"
const LargeChatFixtureForeignSessionID = "ses_foreign_fixture"
const LargeChatFixtureForeignShellID = "sh_foreign_fixture"
const LargeChatFixtureForeignShellOutput = "FOREIGN SHELL MARKER MUST NOT LEAK\n"
const (
LargeChatFixtureNewestAnswer = "Controlled newest answer: large history fixture"
@@ -80,7 +83,7 @@ func LargeChatFixtureHandlerWithShell(workspace string, exited bool) http.Handle
if !largeChatFixtureAuthenticated(w, r) {
return
}
writeLargeChatFixtureJSON(w, fmt.Sprintf(`{"data":[{"id":%q,"status":%q,"command":"printf fixture","metadata":{"sessionID":%q}}]}`, LargeChatFixtureShellID, status, LargeChatFixtureSessionID))
writeLargeChatFixtureJSON(w, fmt.Sprintf(`{"data":[{"id":%q,"status":%q,"command":"printf fixture","metadata":{"sessionID":%q}},{"id":%q,"status":"running","command":"printf foreign","metadata":{"sessionID":%q}}]}`, LargeChatFixtureShellID, status, LargeChatFixtureSessionID, LargeChatFixtureForeignShellID, LargeChatFixtureForeignSessionID))
})
mux.HandleFunc("GET /api/shell/"+LargeChatFixtureShellID, func(w http.ResponseWriter, r *http.Request) {
if !largeChatFixtureAuthenticated(w, r) {
@@ -92,6 +95,12 @@ func LargeChatFixtureHandlerWithShell(workspace string, exited bool) http.Handle
}
writeLargeChatFixtureJSON(w, fmt.Sprintf(`{"data":{"id":%q,"status":%q,"command":"printf fixture","exit":%s,"metadata":{"sessionID":%q}}}`, LargeChatFixtureShellID, status, exit, LargeChatFixtureSessionID))
})
mux.HandleFunc("GET /api/shell/"+LargeChatFixtureForeignShellID, func(w http.ResponseWriter, r *http.Request) {
if !largeChatFixtureAuthenticated(w, r) {
return
}
writeLargeChatFixtureJSON(w, fmt.Sprintf(`{"data":{"id":%q,"status":"running","command":"printf foreign","metadata":{"sessionID":%q}}}`, LargeChatFixtureForeignShellID, LargeChatFixtureForeignSessionID))
})
mux.HandleFunc("GET /api/shell/"+LargeChatFixtureShellID+"/output", func(w http.ResponseWriter, r *http.Request) {
if !largeChatFixtureAuthenticated(w, r) {
return
@@ -99,6 +108,13 @@ func LargeChatFixtureHandlerWithShell(workspace string, exited bool) http.Handle
cursor := int64(len(LargeChatFixtureShellOutput))
writeLargeChatFixtureJSON(w, fmt.Sprintf(`{"data":{"output":%q,"cursor":%d,"size":%d,"truncated":false}}`, LargeChatFixtureShellOutput, cursor, cursor))
})
mux.HandleFunc("GET /api/shell/"+LargeChatFixtureForeignShellID+"/output", func(w http.ResponseWriter, r *http.Request) {
if !largeChatFixtureAuthenticated(w, r) {
return
}
cursor := int64(len(LargeChatFixtureForeignShellOutput))
writeLargeChatFixtureJSON(w, fmt.Sprintf(`{"data":{"output":%q,"cursor":%d,"size":%d,"truncated":false}}`, LargeChatFixtureForeignShellOutput, cursor, cursor))
})
return mux
}