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

Function TestBuildAWFConfigJSON_DomainDeduplication

pkg/workflow/awf_config_test.go:1033–1063  ·  view source on GitHub ↗

TestBuildAWFConfigJSON_DomainDeduplication verifies that duplicate domain entries in the comma-separated allowed domains list are removed.

(t *testing.T)

Source from the content-addressed store, hash-verified

1031// TestBuildAWFConfigJSON_DomainDeduplication verifies that duplicate domain entries
1032// in the comma-separated allowed domains list are removed.
1033func TestBuildAWFConfigJSON_DomainDeduplication(t *testing.T) {
1034 config := AWFCommandConfig{
1035 EngineName: "copilot",
1036 AllowedDomains: "github.com,api.github.com,github.com", // github.com duplicated
1037 WorkflowData: &WorkflowData{
1038 EngineConfig: &EngineConfig{ID: "copilot"},
1039 NetworkPermissions: &NetworkPermissions{
1040 Firewall: &FirewallConfig{Enabled: true},
1041 },
1042 },
1043 }
1044
1045 jsonStr, err := BuildAWFConfigJSON(config)
1046 require.NoError(t, err)
1047
1048 var parsed struct {
1049 Network struct {
1050 AllowDomains []string `json:"allowDomains"`
1051 } `json:"network"`
1052 }
1053 require.NoError(t, json.Unmarshal([]byte(jsonStr), &parsed))
1054
1055 // github.com should appear exactly once
1056 count := 0
1057 for _, d := range parsed.Network.AllowDomains {
1058 if d == "github.com" {
1059 count++
1060 }
1061 }
1062 assert.Equal(t, 1, count, "github.com should appear exactly once after deduplication")
1063}
1064
1065// TestBuildAWFConfigJSON_SchemaCompliance validates that BuildAWFConfigJSON always produces
1066// JSON that conforms to the embedded AWF config schema. This test provides coverage for the

Callers

nothing calls this directly

Calls 1

BuildAWFConfigJSONFunction · 0.85

Tested by

no test coverage detected