Skip to content

Commit f028658

Browse files
committed
Verify HTTPS collect under an Agent path prefix
1 parent c03aac0 commit f028658

3 files changed

Lines changed: 10 additions & 6 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ Configuration is object-based via `OpenCliProperties`:
181181
| `maxConcurrentExecutions` | `0` | Max concurrent subprocesses (0 = unlimited) |
182182
| `startupProbeTimeoutMillis` | `30000` | Availability-probe timeout |
183183
| `environment` | `{}` | Extra environment variables (e.g. `OPENCLI_CDP_ENDPOINT`) |
184-
| `remoteAgentBaseUrl` | — | Remote agent base URL |
184+
| `remoteAgentBaseUrl` | — | Remote Agent HTTP(S) base URL. Keep any deployment path prefix and omit user info, queries and fragments. |
185185
| `remoteCollectMode` | `cdp` | `bridge` or `cdp` (must match the agent side) |
186186
| `remoteOutputFormat` | `json` | Output format requested from the agent |
187187
| `remoteCdpEndpoint` | — | Optional CDP endpoint overriding the agent default |

‎README.zh-CN.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ cli.gemini().deepResearch("topic",
180180
| `maxConcurrentExecutions` | `0` | 最大并发子进程数(0 = 不限) |
181181
| `startupProbeTimeoutMillis` | `30000` | 可用性探测超时 |
182182
| `environment` | `{}` | 额外环境变量(如 `OPENCLI_CDP_ENDPOINT`) |
183-
| `remoteAgentBaseUrl` | — | 远程 Agent 根地址 |
183+
| `remoteAgentBaseUrl` | — | 远程 Agent 的 HTTP(S) 基址,可以保留部署路径前缀。省略用户信息、查询参数和片段。 |
184184
| `remoteCollectMode` | `cdp` | `bridge` 或 `cdp`(须与 Agent 侧一致) |
185185
| `remoteOutputFormat` | `json` | 向 Agent 请求的输出格式 |
186186
| `remoteCdpEndpoint` | — | 可选,覆盖 Agent 默认 CDP 端点 |

‎src/test/java/io/github/easy4j/opencli/remote/OpenCliRemoteAgentHttpClientTest.java‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ void authenticationHeaderIsSentOnlyOverVerifiedTls(@TempDir Path temporary) thro
373373
AtomicReference<String> receivedUri = new AtomicReference<>();
374374
OpenCliTlsFixture tls = OpenCliTlsFixture.create(temporary);
375375
SSLContext previous = SSLContext.getDefault();
376-
try (JsonCollectStub stub = JsonCollectStub.start(tls.getServer(), exchange -> {
376+
try (JsonCollectStub stub = JsonCollectStub.start(tls.getServer(), "/agent/collect", exchange -> {
377377
receivedCredential.set(exchange.getRequestHeaders().getFirst(header));
378378
receivedUri.set(exchange.getRequestURI().toASCIIString());
379379
// The synthetic fixture supports only this explicit header.
@@ -389,7 +389,7 @@ void authenticationHeaderIsSentOnlyOverVerifiedTls(@TempDir Path temporary) thro
389389
}
390390
})) {
391391
OpenCliProperties props = baseProps(stub.port());
392-
props.setRemoteAgentBaseUrl("https://127.0.0.1:" + stub.port());
392+
props.setRemoteAgentBaseUrl("https://127.0.0.1:" + stub.port() + "/agent///");
393393
props.setRemoteAuthentication(new OpenCliRemoteAuthentication(header, credential));
394394
Assertions.assertFalse(props.toString().contains(credential));
395395
Assertions.assertNull(props.copyForLocalCliExecution().getRemoteAuthentication());
@@ -405,7 +405,7 @@ void authenticationHeaderIsSentOnlyOverVerifiedTls(@TempDir Path temporary) thro
405405
try (OpenCliRemoteAgentHttpClient client = new OpenCliRemoteAgentHttpClient(props)) {
406406
Assertions.assertTrue(client.collect(request).isSuccess());
407407
Assertions.assertEquals(credential, receivedCredential.get());
408-
Assertions.assertEquals("/collect", receivedUri.get());
408+
Assertions.assertEquals("/agent/collect", receivedUri.get());
409409
Assertions.assertFalse(stub.requestBody.contains(credential));
410410
props.setRemoteAuthentication(new OpenCliRemoteAuthentication(header, "rejected-" + credential));
411411
ByteArrayOutputStream diagnostics = new ByteArrayOutputStream();
@@ -719,6 +719,10 @@ static JsonCollectStub start(HttpHandler response) throws IOException {
719719
}
720720

721721
static JsonCollectStub start(SSLContext tls, HttpHandler response) throws IOException {
722+
return start(tls, "/collect", response);
723+
}
724+
725+
static JsonCollectStub start(SSLContext tls, String path, HttpHandler response) throws IOException {
722726
InetSocketAddress address = new InetSocketAddress("127.0.0.1", 0);
723727
HttpServer server;
724728
if (Objects.isNull(tls)) {
@@ -730,7 +734,7 @@ static JsonCollectStub start(SSLContext tls, HttpHandler response) throws IOExce
730734
}
731735
JsonCollectStub stub = new JsonCollectStub(server, server.getAddress().getPort());
732736
server.createContext(
733-
"/collect",
737+
path,
734738
new HttpHandler() {
735739
@Override
736740
public void handle(HttpExchange exchange) throws IOException {

0 commit comments

Comments
 (0)