forked from github/copilot-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRpcTasksAndHandlersE2ETest.java
More file actions
72 lines (59 loc) · 3.1 KB
/
Copy pathRpcTasksAndHandlersE2ETest.java
File metadata and controls
72 lines (59 loc) · 3.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------------------------------------------*/
package com.github.copilot;
import static org.junit.jupiter.api.Assertions.*;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import com.github.copilot.generated.rpc.SessionMcpHeadersHandlePendingHeadersRefreshRequestParams;
import com.github.copilot.generated.rpc.SessionUiHandlePendingSessionLimitsExhaustedParams;
import com.github.copilot.generated.rpc.UISessionLimitsExhaustedResponse;
import com.github.copilot.generated.rpc.UISessionLimitsExhaustedResponseAction;
import com.github.copilot.rpc.PermissionHandler;
import com.github.copilot.rpc.SessionConfig;
class RpcTasksAndHandlersE2ETest {
private static E2ETestContext ctx;
@BeforeAll
static void setup() throws Exception {
ctx = E2ETestContext.create();
}
@AfterAll
static void teardown() throws Exception {
if (ctx != null) {
ctx.close();
}
}
@Test
void testShouldReturnExpectedResultsForMissingPendingHandlerRequestIds() throws Exception {
ctx.initializeProxy();
try (var client = ctx.createClient()) {
try (var session = client
.createSession(new SessionConfig().setOnPermissionRequest(PermissionHandler.APPROVE_ALL)).get()) {
var sessionLimits = session.getRpc().ui
.handlePendingSessionLimitsExhausted(
new SessionUiHandlePendingSessionLimitsExhaustedParams(null,
"missing-session-limits-request",
new UISessionLimitsExhaustedResponse(
UISessionLimitsExhaustedResponseAction.UNSET, null, null)))
.get(30, TimeUnit.SECONDS);
assertFalse(sessionLimits.success());
var headersRefresh = session.getRpc().mcp.headers
.handlePendingHeadersRefreshRequest(
new SessionMcpHeadersHandlePendingHeadersRefreshRequestParams(null,
"missing-headers-refresh-request",
Map.of("kind", "headers", "headers", Map.of("x-refresh", "missing"))))
.get(30, TimeUnit.SECONDS);
assertFalse(headersRefresh.success());
var noHeadersRefresh = session.getRpc().mcp.headers
.handlePendingHeadersRefreshRequest(
new SessionMcpHeadersHandlePendingHeadersRefreshRequestParams(null,
"missing-headers-refresh-none-request", Map.of("kind", "none")))
.get(30, TimeUnit.SECONDS);
assertFalse(noHeadersRefresh.success());
}
}
}
}