@@ -16,33 +16,54 @@ func TestGitHubLockdownAutodetection(t *testing.T) {
1616 description string
1717 }{
1818 {
19- name : "Auto-detection enabled when lockdown not specified" ,
19+ name : "Auto-determination enabled when lockdown not specified and custom token defined " ,
2020 workflow : `---
2121on: issues
2222engine: copilot
2323tools:
2424 github:
2525 mode: local
26+ github-token: ${{ secrets.CUSTOM_TOKEN }}
2627 toolsets: [default]
2728---
2829
2930# Test Workflow
3031
31- Test automatic lockdown detection .
32+ Test automatic lockdown determination with custom token .
3233` ,
3334 expectedDetectStep : true ,
3435 expectedLockdown : "auto" ,
35- description : "When lockdown is not specified, detection step should be added and lockdown should use step output " ,
36+ description : "When lockdown is not specified and custom token is defined, determination step should be added " ,
3637 },
3738 {
38- name : "No auto-detection when lockdown explicitly set to true" ,
39+ name : "No auto-determination when no custom token" ,
40+ workflow : `---
41+ on: issues
42+ engine: copilot
43+ tools:
44+ github:
45+ mode: local
46+ toolsets: [default]
47+ ---
48+
49+ # Test Workflow
50+
51+ Test without custom token - should not add determination step.
52+ ` ,
53+ expectedDetectStep : false ,
54+ expectedLockdown : "false" ,
55+ description : "When no custom token is defined, no determination step should be added" ,
56+ },
57+ {
58+ name : "No auto-determination when lockdown explicitly set to true" ,
3959 workflow : `---
4060on: issues
4161engine: copilot
4262tools:
4363 github:
4464 mode: local
4565 lockdown: true
66+ github-token: ${{ secrets.CUSTOM_TOKEN }}
4667 toolsets: [default]
4768---
4869
@@ -52,17 +73,18 @@ Test with explicit lockdown enabled.
5273` ,
5374 expectedDetectStep : false ,
5475 expectedLockdown : "true" ,
55- description : "When lockdown is explicitly true, no detection step and lockdown should be hardcoded" ,
76+ description : "When lockdown is explicitly true, no determination step and lockdown should be hardcoded" ,
5677 },
5778 {
58- name : "No auto-detection when lockdown explicitly set to false" ,
79+ name : "No auto-determination when lockdown explicitly set to false" ,
5980 workflow : `---
6081on: issues
6182engine: copilot
6283tools:
6384 github:
6485 mode: local
6586 lockdown: false
87+ github-token: ${{ secrets.CUSTOM_TOKEN }}
6688 toolsets: [default]
6789---
6890
@@ -72,26 +94,27 @@ Test with explicit lockdown disabled.
7294` ,
7395 expectedDetectStep : false ,
7496 expectedLockdown : "false" ,
75- description : "When lockdown is explicitly false, no detection step and no lockdown setting" ,
97+ description : "When lockdown is explicitly false, no determination step and no lockdown setting" ,
7698 },
7799 {
78- name : "Auto-detection with remote mode" ,
100+ name : "Auto-determination with remote mode and custom token " ,
79101 workflow : `---
80102on: issues
81103engine: copilot
82104tools:
83105 github:
84106 mode: remote
107+ github-token: ${{ secrets.CUSTOM_TOKEN }}
85108 toolsets: [default]
86109---
87110
88111# Test Workflow
89112
90- Test auto-detection with remote GitHub MCP.
113+ Test auto-determination with remote GitHub MCP and custom token .
91114` ,
92115 expectedDetectStep : true ,
93116 expectedLockdown : "auto" ,
94- description : "Auto-detection should work with remote mode too " ,
117+ description : "Auto-determination should work with remote mode when custom token is defined " ,
95118 },
96119 }
97120
@@ -125,9 +148,9 @@ Test auto-detection with remote GitHub MCP.
125148 yaml := string (lockContent )
126149
127150 // Check if detection step is present
128- detectStepPresent := strings .Contains (yaml , "Detect repository visibility for GitHub MCP lockdown " ) &&
129- strings .Contains (yaml , "detect-repo-visibility " ) &&
130- strings .Contains (yaml , "detect_repo_visibility .cjs" )
151+ detectStepPresent := strings .Contains (yaml , "Determine automatic lockdown mode for GitHub MCP server " ) &&
152+ strings .Contains (yaml , "determine-automatic-lockdown " ) &&
153+ strings .Contains (yaml , "determine_automatic_lockdown .cjs" )
131154
132155 if detectStepPresent != tt .expectedDetectStep {
133156 t .Errorf ("%s: Detection step presence = %v, want %v" , tt .description , detectStepPresent , tt .expectedDetectStep )
@@ -137,7 +160,7 @@ Test auto-detection with remote GitHub MCP.
137160 switch tt .expectedLockdown {
138161 case "auto" :
139162 // Should use step output expression
140- if ! strings .Contains (yaml , "steps.detect-repo-visibility .outputs.lockdown" ) {
163+ if ! strings .Contains (yaml , "steps.determine-automatic-lockdown .outputs.lockdown" ) {
141164 t .Errorf ("%s: Expected lockdown to use step output expression" , tt .description )
142165 }
143166 case "true" :
@@ -164,12 +187,13 @@ engine: claude
164187tools:
165188 github:
166189 mode: local
190+ github-token: ${{ secrets.CUSTOM_TOKEN }}
167191 toolsets: [default]
168192---
169193
170194# Test Workflow
171195
172- Test automatic lockdown detection with Claude.
196+ Test automatic lockdown determination with Claude and custom token .
173197`
174198
175199 // Create temporary directory for test
@@ -200,15 +224,15 @@ Test automatic lockdown detection with Claude.
200224 yaml := string (lockContent )
201225
202226 // Check if detection step is present
203- detectStepPresent := strings .Contains (yaml , "Detect repository visibility for GitHub MCP lockdown " ) &&
204- strings .Contains (yaml , "detect-repo-visibility " )
227+ detectStepPresent := strings .Contains (yaml , "Determine automatic lockdown mode for GitHub MCP server " ) &&
228+ strings .Contains (yaml , "determine-automatic-lockdown " )
205229
206230 if ! detectStepPresent {
207- t .Error ("Detection step should be present for Claude engine" )
231+ t .Error ("Determination step should be present for Claude engine with custom token " )
208232 }
209233
210234 // Check if lockdown uses step output expression
211- if ! strings .Contains (yaml , "steps.detect-repo-visibility .outputs.lockdown" ) {
235+ if ! strings .Contains (yaml , "steps.determine-automatic-lockdown .outputs.lockdown" ) {
212236 t .Error ("Expected lockdown to use step output expression for Claude engine" )
213237 }
214238}
0 commit comments