Files
CLIProxyAPI/internal/runtime/executor/helps/gemini_interactions_test.go
Luis Pater 6e6afab99a refactor: migrate gjson, sjson, and base64 to MoeForge/moego
- Replace tidwall/gjson and tidwall/sjson with github.com/MoeForge/moego/ojson
  and encoding/base64 with github.com/MoeForge/moego/base64 across the main
  module and examples
- Introduce cross-method *ojson.Doc request rewriting pipelines across
  thinking, signature, client/codex, runtime/executor/helps, pluginhost, and
  all provider executors with FinalizePayloadDoc as the final semantic barrier
- Convert all consecutive JSON mutations (>= 2 Set/SetRaw/Delete operations)
  to batch edits on ojson.Doc
- Upgrade read-only byte paths to ojson.GetBytesNoCopy,
  ojson.GetManyBytesNoCopy, and util.ParseGJSONBytesNoCopy with explicit
  strings.Clone ownership protection across streaming and persistent state
- Use base64.StdEncoding.ValidateString for zero-allocation signature checks
  and base64.EncodeDataURL for single-allocation data URL construction
2026-11-03 03:05:04 +08:00

32 lines
1.1 KiB
Go

package helps
import (
"github.com/MoeForge/moego/base64"
"testing"
"github.com/MoeForge/moego/ojson"
)
func testVertexBareTinkInteractionsSignature() string {
payload := []byte{0x01, 0x8f, 0x3d, 0x6b, 0x5f}
for len(payload) < 405 {
payload = append(payload, byte(0xA0+len(payload)%0x20))
}
return base64.StdEncoding.EncodeToString(payload)
}
func TestSanitizeGeminiInteractionsUnsupportedInputIDs_ScopesVertexBareTink(t *testing.T) {
sig := testVertexBareTinkInteractionsSignature()
body := []byte(`{"input":[{"type":"user_input","content":[{"type":"text","text":"hi"}]},{"type":"thought","signature":"` + sig + `"}]}`)
public := SanitizeGeminiInteractionsUnsupportedInputIDs(body, false)
if ojson.GetBytes(public, `input.#(type=="thought")`).Exists() {
t.Fatalf("public Interactions endpoint must drop the Vertex bare-Tink thought: %s", public)
}
vertex := SanitizeGeminiInteractionsUnsupportedInputIDs(body, true)
if got := ojson.GetBytes(vertex, `input.#(type=="thought").signature`).String(); got != sig {
t.Fatalf("Vertex Interactions endpoint must keep the bare-Tink signature, got %q", got)
}
}