@@ -195,6 +195,25 @@ func TestBuildAWFConfigJSON(t *testing.T) {
195195 assert .NotContains (t , jsonStr , "\n " , "JSON output should not contain newlines (must be compact)" )
196196 assert .NotContains (t , jsonStr , " " , "JSON output should not contain indentation" )
197197 })
198+
199+ t .Run ("github actions expressions preserve && operators in allowDomains" , func (t * testing.T ) {
200+ config := AWFCommandConfig {
201+ EngineName : "copilot" ,
202+ AllowedDomains : "${{ env.MCP_ENV == 'staging' && env.MCP_URL_STAGING || env.MCP_URL_PROD }}" ,
203+ WorkflowData : & WorkflowData {
204+ EngineConfig : & EngineConfig {ID : "copilot" },
205+ NetworkPermissions : & NetworkPermissions {
206+ Firewall : & FirewallConfig {Enabled : true },
207+ },
208+ },
209+ }
210+
211+ jsonStr , err := BuildAWFConfigJSON (config )
212+ require .NoError (t , err , "BuildAWFConfigJSON should not return an error" )
213+
214+ assert .Contains (t , jsonStr , "&&" , "JSON output should preserve && in GitHub Actions expressions" )
215+ assert .NotContains (t , jsonStr , "\\ u0026" , "JSON output should not HTML-escape '&' characters" )
216+ })
198217}
199218
200219// TestBuildAWFConfigSchemaURL verifies that buildAWFConfigSchemaURL returns a release-pinned
@@ -416,6 +435,27 @@ func TestBuildAWFCommand_UsesConfigFile(t *testing.T) {
416435 assert .Contains (t , command , `"enabled":true` , "config JSON should have apiProxy enabled" )
417436}
418437
438+ func TestBuildAWFCommand_PreservesGitHubExpressionOperatorsInConfigJSON (t * testing.T ) {
439+ config := AWFCommandConfig {
440+ EngineName : "copilot" ,
441+ EngineCommand : "copilot --prompt-file /tmp/prompt.txt" ,
442+ LogFile : "/tmp/gh-aw/agent-stdio.log" ,
443+ AllowedDomains : "${{ env.MCP_ENV == 'staging' && env.MCP_URL_STAGING || env.MCP_URL_PROD }}" ,
444+ WorkflowData : & WorkflowData {
445+ EngineConfig : & EngineConfig {ID : "copilot" },
446+ NetworkPermissions : & NetworkPermissions {
447+ Firewall : & FirewallConfig {Enabled : true },
448+ },
449+ },
450+ }
451+
452+ command := BuildAWFCommand (config )
453+
454+ assert .Contains (t , command , "env.MCP_ENV == 'staging'" , "expected full GitHub Actions expression to be preserved" )
455+ assert .Contains (t , command , "&&" , "expected AWF config JSON in command to preserve &&" )
456+ assert .NotContains (t , command , "\\ u0026" , "expected AWF config JSON in command to not HTML-escape '&'" )
457+ }
458+
419459// TestBuildAWFCommand_ConfigFileWithPathSetup verifies that the config file write command
420460// is correctly integrated with the path setup section.
421461func TestBuildAWFCommand_ConfigFileWithPathSetup (t * testing.T ) {
0 commit comments