Skip to content

Commit 709dc4b

Browse files
committed
Adapt SDK tests to Copilot 1.0.81-10 auth schema
Use the regenerated MCP OAuth discriminator, settable auth inputs, and public Rust option construction pattern. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: e98a14a6-7ad4-4cb6-b808-e56547701c19
1 parent e70cc82 commit 709dc4b

4 files changed

Lines changed: 24 additions & 21 deletions

File tree

dotnet/test/E2E/RpcSessionStateE2ETests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ public async Task Should_Set_Auth_Credentials()
451451
});
452452
var login = $"sdk-rpc-{Guid.NewGuid():N}";
453453

454-
var setCredentials = await session.Rpc.GitHubAuth.SetCredentialsAsync(new AuthInfoUser
454+
var setCredentials = await session.Rpc.GitHubAuth.SetCredentialsAsync(new SettableAuthInfoUser
455455
{
456456
CopilotUser = new CopilotUserResponse
457457
{

python/copilot/session.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@
3434
CanvasProviderOpenResult,
3535
ClientSessionApiHandlers,
3636
CommandsHandlePendingCommandRequest,
37+
GitHubTokenAcquireResultKind,
3738
HandlePendingToolCallRequest,
3839
LogRequest,
3940
MCPOauthHandlePendingRequest,
4041
MCPOauthPendingRequestResponse,
41-
MCPOauthPendingRequestResponseKind,
4242
ModelSwitchToRequest,
4343
PermissionDecision,
4444
PermissionDecisionApproveOnce,
@@ -2279,14 +2279,14 @@ async def _execute_mcp_auth_and_respond(
22792279

22802280
if result and result.get("kind", "token") == "token":
22812281
rpc_result = MCPOauthPendingRequestResponse(
2282-
kind=MCPOauthPendingRequestResponseKind.TOKEN,
2282+
kind=GitHubTokenAcquireResultKind.TOKEN,
22832283
access_token=result["accessToken"],
22842284
expires_in=result.get("expiresIn"),
22852285
token_type=result.get("tokenType"),
22862286
)
22872287
else:
22882288
rpc_result = MCPOauthPendingRequestResponse(
2289-
kind=MCPOauthPendingRequestResponseKind.CANCELLED
2289+
kind=GitHubTokenAcquireResultKind.CANCELLED
22902290
)
22912291
await self.rpc.mcp.oauth.handle_pending_request(
22922292
MCPOauthHandlePendingRequest(
@@ -2300,7 +2300,7 @@ async def _execute_mcp_auth_and_respond(
23002300
MCPOauthHandlePendingRequest(
23012301
request_id=request_id,
23022302
result=MCPOauthPendingRequestResponse(
2303-
kind=MCPOauthPendingRequestResponseKind.CANCELLED
2303+
kind=GitHubTokenAcquireResultKind.CANCELLED
23042304
),
23052305
)
23062306
)

python/e2e/test_mcp_oauth_e2e.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
import pytest
99

1010
from copilot.generated.rpc import (
11+
GitHubTokenAcquireResultKind,
1112
MCPAppsCallToolRequest,
1213
MCPListToolsRequest,
1314
MCPOauthHandlePendingRequest,
1415
MCPOauthPendingRequestResponse,
15-
MCPOauthPendingRequestResponseKind,
1616
)
1717
from copilot.session import MCPServerConfig, PermissionHandler
1818
from copilot.session_events import McpServerStatus
@@ -206,7 +206,7 @@ async def on_mcp_auth_request(request, _invocation):
206206
MCPOauthHandlePendingRequest(
207207
request_id=request["requestId"],
208208
result=MCPOauthPendingRequestResponse(
209-
kind=MCPOauthPendingRequestResponseKind.TOKEN,
209+
kind=GitHubTokenAcquireResultKind.TOKEN,
210210
access_token=EXPECTED_TOKEN,
211211
token_type="Bearer",
212212
expires_in=3600,

rust/tests/e2e/rpc_session_state.rs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -762,18 +762,18 @@ async fn should_update_options_and_initialize_session_services() {
762762
.await
763763
.expect("create session");
764764

765+
let mut update_options = SessionUpdateOptionsParams::default();
766+
update_options.ask_user_disabled = Some(true);
767+
update_options.available_tools = Some(vec!["view".to_string()]);
768+
update_options.client_name = Some("rust-rpc-e2e".to_string());
769+
update_options.enable_streaming = Some(true);
770+
update_options.model = Some(MODEL_ID.to_string());
771+
update_options.working_directory = Some(ctx.work_dir().display().to_string());
772+
765773
let options = session
766774
.rpc()
767775
.options()
768-
.update(SessionUpdateOptionsParams {
769-
ask_user_disabled: Some(true),
770-
available_tools: Some(vec!["view".to_string()]),
771-
client_name: Some("rust-rpc-e2e".to_string()),
772-
enable_streaming: Some(true),
773-
model: Some(MODEL_ID.to_string()),
774-
working_directory: Some(ctx.work_dir().display().to_string()),
775-
..SessionUpdateOptionsParams::default()
776-
})
776+
.update(update_options)
777777
.await
778778
.expect("update options");
779779
assert!(options.success);
@@ -893,11 +893,14 @@ async fn should_set_auth_credentials() {
893893
.rpc()
894894
.git_hub_auth()
895895
.set_credentials(SessionSetCredentialsParams {
896-
credentials: Some(AuthInfo::User(UserAuthInfo {
897-
host: "github.com".to_string(),
898-
login: "rpc-session-user".to_string(),
899-
..Default::default()
900-
})),
896+
credentials: Some(
897+
serde_json::to_value(AuthInfo::User(UserAuthInfo {
898+
host: "github.com".to_string(),
899+
login: "rpc-session-user".to_string(),
900+
..Default::default()
901+
}))
902+
.expect("serialize auth credentials"),
903+
),
901904
})
902905
.await
903906
.expect("set credentials");

0 commit comments

Comments
 (0)