test: harden remote api chat fixture for SSRF validation
This commit is contained in:
@@ -12,19 +12,22 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newTestRemoteChat() *RemoteAPIChat {
|
func newTestRemoteChat(t *testing.T) *RemoteAPIChat {
|
||||||
chat, _ := NewRemoteAPIChat(&ChatConfig{
|
t.Helper()
|
||||||
|
|
||||||
|
chat, err := NewRemoteAPIChat(&ChatConfig{
|
||||||
Source: types.ModelSourceRemote,
|
Source: types.ModelSourceRemote,
|
||||||
BaseURL: "https://api.example.com/v1",
|
BaseURL: "https://example.com/v1",
|
||||||
ModelName: "test-model",
|
ModelName: "test-model",
|
||||||
APIKey: "test-key",
|
APIKey: "test-key",
|
||||||
ModelID: "test-model",
|
ModelID: "test-model",
|
||||||
})
|
})
|
||||||
|
require.NoError(t, err)
|
||||||
return chat
|
return chat
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBuildChatCompletionRequest_ParallelToolCalls(t *testing.T) {
|
func TestBuildChatCompletionRequest_ParallelToolCalls(t *testing.T) {
|
||||||
chat := newTestRemoteChat()
|
chat := newTestRemoteChat(t)
|
||||||
messages := []Message{{Role: "user", Content: "hello"}}
|
messages := []Message{{Role: "user", Content: "hello"}}
|
||||||
|
|
||||||
t.Run("nil ParallelToolCalls leaves default", func(t *testing.T) {
|
t.Run("nil ParallelToolCalls leaves default", func(t *testing.T) {
|
||||||
@@ -65,7 +68,7 @@ func TestBuildChatCompletionRequest_ParallelToolCalls(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestBuildChatCompletionRequest_MCPToolsFormat(t *testing.T) {
|
func TestBuildChatCompletionRequest_MCPToolsFormat(t *testing.T) {
|
||||||
chat := newTestRemoteChat()
|
chat := newTestRemoteChat(t)
|
||||||
messages := []Message{{Role: "user", Content: "查询乙醇的理化性质"}}
|
messages := []Message{{Role: "user", Content: "查询乙醇的理化性质"}}
|
||||||
|
|
||||||
mcpTools := []Tool{
|
mcpTools := []Tool{
|
||||||
@@ -111,7 +114,7 @@ func TestBuildChatCompletionRequest_MCPToolsFormat(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestBuildChatCompletionRequest_ToolChoice(t *testing.T) {
|
func TestBuildChatCompletionRequest_ToolChoice(t *testing.T) {
|
||||||
chat := newTestRemoteChat()
|
chat := newTestRemoteChat(t)
|
||||||
messages := []Message{{Role: "user", Content: "test"}}
|
messages := []Message{{Role: "user", Content: "test"}}
|
||||||
|
|
||||||
t.Run("auto tool choice", func(t *testing.T) {
|
t.Run("auto tool choice", func(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user