Skip to content

Commit f98dc99

Browse files
committed
Port snapshot directory name changes and CI token from upstream
- Change ask-user to ask_user snapshot directory name - Change mcp-and-agents to mcp_and_agents snapshot directory name - Add fake token for CI environment to avoid auth issues in E2E tests
1 parent f690eac commit f98dc99

3 files changed

Lines changed: 24 additions & 16 deletions

File tree

src/test/java/com/github/copilot/sdk/AskUserTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
*
2626
* <p>
2727
* These tests use the shared CapiProxy infrastructure for deterministic API
28-
* response replay. Snapshots are stored in test/snapshots/ask-user/.
28+
* response replay. Snapshots are stored in test/snapshots/ask_user/.
2929
* </p>
3030
*/
3131
public class AskUserTest {
@@ -46,7 +46,7 @@ static void teardown() throws Exception {
4646

4747
@Test
4848
void testUserInputHandlerInvokedWhenModelUsesAskUserTool() throws Exception {
49-
ctx.configureForTest("ask-user", "should_invoke_user_input_handler_when_model_uses_ask_user_tool");
49+
ctx.configureForTest("ask_user", "should_invoke_user_input_handler_when_model_uses_ask_user_tool");
5050

5151
List<UserInputRequest> userInputRequests = new ArrayList<>();
5252
final String[] sessionIdHolder = new String[1];
@@ -84,7 +84,7 @@ void testUserInputHandlerInvokedWhenModelUsesAskUserTool() throws Exception {
8484

8585
@Test
8686
void testUserInputRequestWithChoices() throws Exception {
87-
ctx.configureForTest("ask-user", "should_receive_choices_in_user_input_request");
87+
ctx.configureForTest("ask_user", "should_receive_choices_in_user_input_request");
8888

8989
List<UserInputRequest> userInputRequests = new ArrayList<>();
9090

@@ -120,7 +120,7 @@ void testUserInputRequestWithChoices() throws Exception {
120120
*/
121121
@Test
122122
void testFreeformUserInputResponse() throws Exception {
123-
ctx.configureForTest("ask-user", "should_handle_freeform_user_input_response");
123+
ctx.configureForTest("ask_user", "should_handle_freeform_user_input_response");
124124

125125
final List<UserInputRequest> userInputRequests = new ArrayList<>();
126126
String freeformAnswer = "This is my custom freeform answer that was not in the choices";

src/test/java/com/github/copilot/sdk/E2ETestContext.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,16 @@ public Map<String, String> getEnvironment() {
173173
* @return a new CopilotClient
174174
*/
175175
public CopilotClient createClient() {
176-
return new CopilotClient(new CopilotClientOptions().setCliPath(cliPath).setCwd(workDir.toString())
177-
.setEnvironment(getEnvironment()));
176+
CopilotClientOptions options = new CopilotClientOptions().setCliPath(cliPath).setCwd(workDir.toString())
177+
.setEnvironment(getEnvironment());
178+
179+
// In CI, use a fake token to avoid auth issues
180+
String ci = System.getenv("CI");
181+
if (ci != null && !ci.isEmpty()) {
182+
options.setGithubToken("fake-token-for-e2e-tests");
183+
}
184+
185+
return new CopilotClient(options);
178186
}
179187

180188
@Override

src/test/java/com/github/copilot/sdk/McpAndAgentsTest.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*
2727
* <p>
2828
* These tests use the shared CapiProxy infrastructure for deterministic API
29-
* response replay. Snapshots are stored in test/snapshots/mcp-and-agents/.
29+
* response replay. Snapshots are stored in test/snapshots/mcp_and_agents/.
3030
* </p>
3131
*/
3232
public class McpAndAgentsTest {
@@ -59,7 +59,7 @@ private Map<String, Object> createLocalMcpServer(String command, List<String> ar
5959

6060
@Test
6161
void testAcceptMcpServerConfigurationOnSessionCreate() throws Exception {
62-
ctx.configureForTest("mcp-and-agents", "should_accept_mcp_server_configuration_on_session_create");
62+
ctx.configureForTest("mcp_and_agents", "should_accept_mcp_server_configuration_on_session_create");
6363

6464
Map<String, Object> mcpServers = new HashMap<>();
6565
mcpServers.put("test-server", createLocalMcpServer("echo", List.of("hello")));
@@ -83,7 +83,7 @@ void testAcceptMcpServerConfigurationOnSessionCreate() throws Exception {
8383

8484
@Test
8585
void testAcceptMcpServerConfigurationOnSessionResume() throws Exception {
86-
ctx.configureForTest("mcp-and-agents", "should_accept_mcp_server_configuration_on_session_resume");
86+
ctx.configureForTest("mcp_and_agents", "should_accept_mcp_server_configuration_on_session_resume");
8787

8888
try (CopilotClient client = ctx.createClient()) {
8989
// Create a session first
@@ -115,7 +115,7 @@ void testAcceptMcpServerConfigurationOnSessionResume() throws Exception {
115115
void testHandleMultipleMcpServers() throws Exception {
116116
// Use same snapshot as single MCP server test since it doesn't depend on server
117117
// count
118-
ctx.configureForTest("mcp-and-agents", "should_accept_mcp_server_configuration_on_session_create");
118+
ctx.configureForTest("mcp_and_agents", "should_accept_mcp_server_configuration_on_session_create");
119119

120120
Map<String, Object> mcpServers = new HashMap<>();
121121
mcpServers.put("server1", createLocalMcpServer("echo", List.of("server1")));
@@ -133,7 +133,7 @@ void testHandleMultipleMcpServers() throws Exception {
133133

134134
@Test
135135
void testAcceptCustomAgentConfigurationOnSessionCreate() throws Exception {
136-
ctx.configureForTest("mcp-and-agents", "should_accept_custom_agent_configuration_on_session_create");
136+
ctx.configureForTest("mcp_and_agents", "should_accept_custom_agent_configuration_on_session_create");
137137

138138
List<CustomAgentConfig> customAgents = List.of(new CustomAgentConfig().setName("test-agent")
139139
.setDisplayName("Test Agent").setDescription("A test agent for SDK testing")
@@ -158,7 +158,7 @@ void testAcceptCustomAgentConfigurationOnSessionCreate() throws Exception {
158158

159159
@Test
160160
void testAcceptCustomAgentConfigurationOnSessionResume() throws Exception {
161-
ctx.configureForTest("mcp-and-agents", "should_accept_custom_agent_configuration_on_session_resume");
161+
ctx.configureForTest("mcp_and_agents", "should_accept_custom_agent_configuration_on_session_resume");
162162

163163
try (CopilotClient client = ctx.createClient()) {
164164
// Create a session first
@@ -191,7 +191,7 @@ void testAcceptCustomAgentConfigurationOnSessionResume() throws Exception {
191191
void testCustomAgentWithToolsConfiguration() throws Exception {
192192
// Use same snapshot as create test since this just verifies configuration
193193
// acceptance
194-
ctx.configureForTest("mcp-and-agents", "should_accept_custom_agent_configuration_on_session_create");
194+
ctx.configureForTest("mcp_and_agents", "should_accept_custom_agent_configuration_on_session_create");
195195

196196
List<CustomAgentConfig> customAgents = List.of(new CustomAgentConfig().setName("tool-agent")
197197
.setDisplayName("Tool Agent").setDescription("An agent with specific tools")
@@ -208,7 +208,7 @@ void testCustomAgentWithToolsConfiguration() throws Exception {
208208
@Test
209209
void testCustomAgentWithMcpServers() throws Exception {
210210
// Use combined snapshot since this uses both MCP servers and custom agents
211-
ctx.configureForTest("mcp-and-agents", "should_accept_both_mcp_servers_and_custom_agents");
211+
ctx.configureForTest("mcp_and_agents", "should_accept_both_mcp_servers_and_custom_agents");
212212

213213
Map<String, Object> agentMcpServers = new HashMap<>();
214214
agentMcpServers.put("agent-server", createLocalMcpServer("echo", List.of("agent-mcp")));
@@ -228,7 +228,7 @@ void testCustomAgentWithMcpServers() throws Exception {
228228
@Test
229229
void testMultipleCustomAgents() throws Exception {
230230
// Use same snapshot as create test
231-
ctx.configureForTest("mcp-and-agents", "should_accept_custom_agent_configuration_on_session_create");
231+
ctx.configureForTest("mcp_and_agents", "should_accept_custom_agent_configuration_on_session_create");
232232

233233
List<CustomAgentConfig> customAgents = List.of(
234234
new CustomAgentConfig().setName("agent1").setDisplayName("Agent One").setDescription("First agent")
@@ -248,7 +248,7 @@ void testMultipleCustomAgents() throws Exception {
248248

249249
@Test
250250
void testAcceptBothMcpServersAndCustomAgents() throws Exception {
251-
ctx.configureForTest("mcp-and-agents", "should_accept_both_mcp_servers_and_custom_agents");
251+
ctx.configureForTest("mcp_and_agents", "should_accept_both_mcp_servers_and_custom_agents");
252252

253253
Map<String, Object> mcpServers = new HashMap<>();
254254
mcpServers.put("shared-server", createLocalMcpServer("echo", List.of("shared")));

0 commit comments

Comments
 (0)