MCPcopy Create free account
hub / github.com/github/gh-aw / TestCodexEngineMCPScriptsSecrets

Function TestCodexEngineMCPScriptsSecrets

pkg/workflow/codex_engine_test.go:889–938  ·  view source on GitHub ↗

TestCodexEngineMCPScriptsSecrets verifies that mcp-scripts secrets are passed to the execution step

(t *testing.T)

Source from the content-addressed store, hash-verified

887
888// TestCodexEngineMCPScriptsSecrets verifies that mcp-scripts secrets are passed to the execution step
889func TestCodexEngineMCPScriptsSecrets(t *testing.T) {
890 engine := NewCodexEngine()
891
892 // Create workflow data with mcp-scripts that have env secrets
893 workflowData := &WorkflowData{
894 Name: "test-workflow-with-mcp-scripts",
895 Features: map[string]any{
896 "mcp-scripts": true, // Feature flag is optional now
897 },
898 MCPScripts: &MCPScriptsConfig{
899 Tools: map[string]*MCPScriptToolConfig{
900 "gh": {
901 Name: "gh",
902 Description: "Execute gh CLI command",
903 Run: "gh $INPUT_ARGS",
904 Env: map[string]string{
905 "GH_TOKEN": "${{ github.token }}",
906 },
907 },
908 "api-call": {
909 Name: "api-call",
910 Description: "Call an API",
911 Script: "return fetch(url);",
912 Env: map[string]string{
913 "API_KEY": "${{ secrets.API_KEY }}",
914 },
915 },
916 },
917 },
918 }
919
920 // Get execution steps
921 execSteps := engine.GetExecutionSteps(workflowData, "/tmp/test.log")
922 if len(execSteps) == 0 {
923 t.Fatal("Expected at least one execution step")
924 }
925
926 // Join all step lines to check content
927 stepContent := strings.Join(execSteps[0], "\n")
928
929 // Verify GH_TOKEN is in the env section
930 if !strings.Contains(stepContent, "GH_TOKEN: ${{ github.token }}") {
931 t.Errorf("Expected GH_TOKEN environment variable in step content:\n%s", stepContent)
932 }
933
934 // Verify API_KEY is in the env section
935 if !strings.Contains(stepContent, "API_KEY: ${{ secrets.API_KEY }}") {
936 t.Errorf("Expected API_KEY environment variable in step content:\n%s", stepContent)
937 }
938}
939
940// TestCodexEngineHttpMCPServerRendered verifies that HTTP MCP servers
941// are properly rendered in TOML format for Codex

Callers

nothing calls this directly

Calls 3

GetExecutionStepsMethod · 0.95
NewCodexEngineFunction · 0.85
ErrorfMethod · 0.45

Tested by

no test coverage detected