@@ -126,7 +126,6 @@ test_api_file_ops() {
126126AUTH_CASES=(
127127 " no token|/status||401"
128128 " wrong token|/status|Bearer wrong|401"
129- " correct token|/status|Bearer secret|200"
130129 " health no auth|/health||200"
131130)
132131
@@ -145,7 +144,12 @@ test_api_auth() {
145144 assert_eq " $code " " $expected_code " " auth: $label " || { _api_stop " ${API_CONTAINER} -auth" ; return 1; }
146145 done
147146
148- echo " OK: api_auth (${# AUTH_CASES[@]} cases)"
147+ # correct token — verify response body has actual data
148+ local out
149+ out=$( curl -sf -H " Authorization: Bearer secret" " $API_BASE /status" )
150+ assert_contains " $out " " busy_workspaces" " auth: correct token returns status body" || { _api_stop " ${API_CONTAINER} -auth" ; return 1; }
151+
152+ echo " OK: api_auth ($(( ${# AUTH_CASES[@]} + 1 )) cases)"
149153 _api_stop " ${API_CONTAINER} -auth"
150154}
151155
@@ -274,11 +278,11 @@ test_api_large_output() {
274278 curl -sf -X PUT " $API_BASE /files/bigtest.txt" --data-binary @" $big_file " > /dev/null
275279 rm -f " $big_file "
276280
277- local out code
278- code =$( curl -s -o /dev/null -w " %{http_code} " -X POST " $API_BASE /run" \
279- -H " Content-Type: application/json " \
280- -d " { \" prompt \" : \" read the file /workspaces/bigtest.txt and tell me how many characters it has \" , \" model \" : \" $TEST_MODEL \" , \" noContinue \" : true} " )
281- assert_eq " $code " " 200 " " large output does not crash (no 500) " || { _api_stop " ${API_CONTAINER} -large" ; return 1; }
281+ local out
282+ out =$( post " $API_BASE /run" \
283+ " { \" prompt \" : \" read the file /workspaces/bigtest.txt and tell me how many characters it has \" , \" model \" : \" $TEST_MODEL \" , \" noContinue \" : true} " )
284+ assert_contains " $out " " result " " large output returns valid json with result " || { _api_stop " ${API_CONTAINER} -large " ; return 1 ; }
285+ assert_contains " $out " " 70 " " large output mentions character count " || { _api_stop " ${API_CONTAINER} -large" ; return 1; }
282286
283287 echo " OK: api_large_output"
284288 _api_stop " ${API_CONTAINER} -large"
@@ -344,15 +348,16 @@ test_api_openai_chat_stream() {
344348test_api_openai_workspace_header () {
345349 _api_start " ${API_CONTAINER} -oai-ws" || return 1
346350
347- # create a named workspace
348- curl -sf -X PUT " $API_BASE /files/oaiws/hint .txt" -d " workspace hint file " > /dev/null
351+ # create a file in a named workspace with a unique marker
352+ curl -sf -X PUT " $API_BASE /files/oaiws/marker .txt" -d " WSMARKER7742 " > /dev/null
349353
354+ # ask claude to read that file — proves it's running in the oaiws workspace
350355 local out
351356 out=$( curl -sf -X POST " $API_BASE /openai/v1/chat/completions" \
352357 -H " Content-Type: application/json" \
353358 -H " X-Claude-Workspace: oaiws" \
354- -d " {\" model\" :\" $TEST_MODEL \" ,\" messages\" :[{\" role\" :\" user\" ,\" content\" :\" respond with exactly WSHEADER \" }]}" )
355- assert_contains " $out " " WSHEADER " " openai X-Claude-Workspace header works " || { _api_stop " ${API_CONTAINER} -oai-ws" ; return 1; }
359+ -d " {\" model\" :\" $TEST_MODEL \" ,\" messages\" :[{\" role\" :\" user\" ,\" content\" :\" read marker.txt in the current directory and respond with its exact contents \" }]}" )
360+ assert_contains " $out " " WSMARKER7742 " " openai workspace header routes to correct dir " || { _api_stop " ${API_CONTAINER} -oai-ws" ; return 1; }
356361
357362 echo " OK: api_openai_workspace_header"
358363 _api_stop " ${API_CONTAINER} -oai-ws"
@@ -364,14 +369,15 @@ test_api_openai_continue_header() {
364369 # first call to establish session
365370 post " $API_BASE /openai/v1/chat/completions" \
366371 " {\" model\" :\" $TEST_MODEL \" ,\" messages\" :[{\" role\" :\" user\" ,\" content\" :\" remember the word CONTTEST\" }]}" > /dev/null
372+ sleep 2
367373
368- # second call with continue — should not 500 (continue may fail gracefully on fresh session)
369- local code
370- code =$( curl -s -o /dev/null -w " %{http_code} " -X POST " $API_BASE /openai/v1/chat/completions" \
374+ # second call with continue — should recall context from first call
375+ local out
376+ out =$( curl -sf -X POST " $API_BASE /openai/v1/chat/completions" \
371377 -H " Content-Type: application/json" \
372378 -H " X-Claude-Continue: true" \
373- -d " {\" model\" :\" $TEST_MODEL \" ,\" messages\" :[{\" role\" :\" user\" ,\" content\" :\" what word did I ask you to remember?\" }]}" )
374- assert_eq " $code " " 200 " " openai X-Claude-Continue header does not crash " || { _api_stop " ${API_CONTAINER} -oai-cont" ; return 1; }
379+ -d " {\" model\" :\" $TEST_MODEL \" ,\" messages\" :[{\" role\" :\" user\" ,\" content\" :\" what word did I ask you to remember? reply with just the word \" }]}" )
380+ assert_contains " $out " " CONTTEST " " openai X-Claude-Continue recalls context " || { _api_stop " ${API_CONTAINER} -oai-cont" ; return 1; }
375381
376382 echo " OK: api_openai_continue_header"
377383 _api_stop " ${API_CONTAINER} -oai-cont"
@@ -414,11 +420,13 @@ _mcp_call() {
414420test_api_mcp_init () {
415421 _api_start " ${API_CONTAINER} -mcp" || return 1
416422
417- local code
418- code =$( curl -s -o /dev/null -w " %{http_code} " -X POST " $API_BASE /mcp/" \
423+ local out
424+ out =$( curl -s -D - -X POST " $API_BASE /mcp/" \
419425 -H " Content-Type: application/json" -H " $_MCP_ACCEPT " \
420426 -d " $_MCP_INIT " )
421- assert_eq " $code " " 200" " mcp initialize returns 200" || { _api_stop " ${API_CONTAINER} -mcp" ; return 1; }
427+ assert_contains " $out " " mcp-session-id" " mcp initialize returns session id header" || { _api_stop " ${API_CONTAINER} -mcp" ; return 1; }
428+ assert_contains " $out " " protocolVersion" " mcp initialize returns protocol version" || { _api_stop " ${API_CONTAINER} -mcp" ; return 1; }
429+ assert_contains " $out " " claude-code" " mcp initialize returns server name" || { _api_stop " ${API_CONTAINER} -mcp" ; return 1; }
422430
423431 echo " OK: api_mcp_init"
424432 _api_stop " ${API_CONTAINER} -mcp"
@@ -497,18 +505,19 @@ test_api_mcp_auth() {
497505 -d " $_MCP_INIT " )
498506 assert_eq " $code " " 401" " mcp no token returns 401" || { _api_stop " ${API_CONTAINER} -mcp-auth" ; return 1; }
499507
500- # correct token via header → 200
501- code=$( curl -s -o /dev/null -w " %{http_code}" -X POST " $API_BASE /mcp/" \
508+ # correct token via header — verify response has protocol data
509+ local out
510+ out=$( curl -s -D - -X POST " $API_BASE /mcp/" \
502511 -H " Content-Type: application/json" -H " $_MCP_ACCEPT " \
503512 -H " Authorization: Bearer mcpsecret" \
504513 -d " $_MCP_INIT " )
505- assert_eq " $code " " 200 " " mcp correct token via header returns 200 " || { _api_stop " ${API_CONTAINER} -mcp-auth" ; return 1; }
514+ assert_contains " $out " " protocolVersion " " mcp auth header returns protocol data " || { _api_stop " ${API_CONTAINER} -mcp-auth" ; return 1; }
506515
507- # correct token via query param → 200
508- code =$( curl -s -o /dev/null -w " %{http_code} " -X POST " $API_BASE /mcp/?apiToken=mcpsecret" \
516+ # correct token via query param — verify response has protocol data
517+ out =$( curl -s -D - -X POST " $API_BASE /mcp/?apiToken=mcpsecret" \
509518 -H " Content-Type: application/json" -H " $_MCP_ACCEPT " \
510519 -d " $_MCP_INIT " )
511- assert_eq " $code " " 200 " " mcp correct token via query param returns 200 " || { _api_stop " ${API_CONTAINER} -mcp-auth" ; return 1; }
520+ assert_contains " $out " " protocolVersion " " mcp auth query param returns protocol data " || { _api_stop " ${API_CONTAINER} -mcp-auth" ; return 1; }
512521
513522 echo " OK: api_mcp_auth"
514523 _api_stop " ${API_CONTAINER} -mcp-auth"
@@ -531,4 +540,12 @@ ALL_TESTS+=(
531540 test_api_openai_chat
532541 test_api_openai_chat_system
533542 test_api_openai_chat_stream
543+ test_api_openai_workspace_header
544+ test_api_openai_continue_header
545+ test_api_openai_reasoning_effort
546+ test_api_mcp_init
547+ test_api_mcp_tools_list
548+ test_api_mcp_claude_run
549+ test_api_mcp_file_ops
550+ test_api_mcp_auth
534551)
0 commit comments