Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 96 additions & 0 deletions pkg/workflow/mcp_http_url_validation_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
package workflow

import (
"os"
"path/filepath"
"strings"
"testing"
)

// TestHTTPMCPServerRequiresURL tests that HTTP MCP servers require a url field
func TestHTTPMCPServerRequiresURL(t *testing.T) {
tests := []struct {
name string
workflow string
expectError bool
errorText string
}{
{
name: "HTTP MCP server without url should fail",
workflow: `---
on: issues
permissions:
contents: read
engine: copilot
mcp-servers:
test-http:
type: http
---

# Test workflow
`,
expectError: true,
errorText: "missing property 'url'",
},
{
name: "HTTP MCP server with url should pass",
workflow: `---
on: issues
permissions:
contents: read
engine: copilot
mcp-servers:
test-http:
type: http
url: "https://example.com"
---

# Test workflow
`,
expectError: false,
},
{
name: "HTTP MCP server with url only (inferred type) should pass",
workflow: `---
on: issues
permissions:
contents: read
engine: copilot
mcp-servers:
test-http:
url: "https://example.com"
---

# Test workflow
`,
expectError: false,
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
// Create temporary workflow file
tmpDir := t.TempDir()
workflowPath := filepath.Join(tmpDir, "test.md")
if err := os.WriteFile(workflowPath, []byte(tt.workflow), 0644); err != nil {
t.Fatalf("Failed to write workflow file: %v", err)
}

// Create compiler and try to compile the workflow
compiler := NewCompiler(false, "", "test")
err := compiler.CompileWorkflow(workflowPath)

if tt.expectError {
if err == nil {
t.Errorf("Expected error but got none")
} else if tt.errorText != "" && !strings.Contains(err.Error(), tt.errorText) {
t.Errorf("Expected error to contain %q, got: %v", tt.errorText, err)
}
} else {
if err != nil {
t.Errorf("Unexpected error: %v", err)
}
}
})
}
}
Loading