fix(worker): preserve API base path in Online Inbox client
The API base URL is https://claudedo.kuns.dev/api — leading-slash request paths discarded the /api segment. Use relative paths so they nest under the base. Tests now use a /api/ base to guard the regression. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -30,7 +30,9 @@ public sealed class OnlineInboxApiClientTests
|
||||
private static (OnlineInboxApiClient Client, StubHandler Handler) Build(string? token = "test-token")
|
||||
{
|
||||
var handler = new StubHandler();
|
||||
var http = new HttpClient(handler) { BaseAddress = new Uri("https://inbox.example.com/") };
|
||||
// Base address carries a path segment (/api) — requests must nest under it,
|
||||
// so the client uses relative paths without a leading slash.
|
||||
var http = new HttpClient(handler) { BaseAddress = new Uri("https://inbox.example.com/api/") };
|
||||
var auth = new StaticTokenAuthProvider(token);
|
||||
return (new OnlineInboxApiClient(http, auth), handler);
|
||||
}
|
||||
@@ -45,7 +47,7 @@ public sealed class OnlineInboxApiClientTests
|
||||
|
||||
Assert.Single(handler.Requests);
|
||||
Assert.Equal(HttpMethod.Put, handler.Requests[0].Method);
|
||||
Assert.Equal("/lists", handler.Requests[0].RequestUri!.AbsolutePath);
|
||||
Assert.Equal("/api/lists", handler.Requests[0].RequestUri!.AbsolutePath);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -98,7 +100,7 @@ public sealed class OnlineInboxApiClientTests
|
||||
await client.MarkImportedAsync("task-id-123");
|
||||
|
||||
Assert.Equal(HttpMethod.Post, handler.Requests[0].Method);
|
||||
Assert.Equal("/tasks/task-id-123/imported", handler.Requests[0].RequestUri!.AbsolutePath);
|
||||
Assert.Equal("/api/tasks/task-id-123/imported", handler.Requests[0].RequestUri!.AbsolutePath);
|
||||
}
|
||||
|
||||
// ---- PutMirrorAsync ----
|
||||
@@ -110,7 +112,7 @@ public sealed class OnlineInboxApiClientTests
|
||||
await client.PutMirrorAsync([new MirrorTask("id1", "l1", "T", null)]);
|
||||
|
||||
Assert.Equal(HttpMethod.Put, handler.Requests[0].Method);
|
||||
Assert.Equal("/tasks/mirror", handler.Requests[0].RequestUri!.AbsolutePath);
|
||||
Assert.Equal("/api/tasks/mirror", handler.Requests[0].RequestUri!.AbsolutePath);
|
||||
}
|
||||
|
||||
// ---- 401 handling ----
|
||||
|
||||
Reference in New Issue
Block a user