Skip to content

Commit 640b00f

Browse files
leggetterclaude
andcommitted
test(outpost): cover event get, attempt get, tenant token and retry
Raises CLI-level acceptance coverage from 22/30 to 26/30 leaf commands. All four reuse data the existing tests already create, so they add coverage without adding setup. The tenant token assertion checks shape rather than contents — three JWT segments, and that the raw tenant id is not readable in it. The token is a real credential, so a test should not print or match on its payload. The four commands still uncovered are the tenant portal and its custom domain. They are not omitted casually: `custom-domain set` configures a real DNS-verified hostname on the shared project, and `tenant portal` returns 404 until one exists. Covering them safely needs a dedicated throwaway domain. They are the least proven surface and should be called out as such in beta release notes. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wajsob136PyRh6nc92w5L3
1 parent 1303023 commit 640b00f

1 file changed

Lines changed: 53 additions & 2 deletions

File tree

‎test/acceptance/outpost_test.go‎

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,13 @@ func TestOutpostTenantLifecycle(t *testing.T) {
104104
stdout = cli.RunExpectSuccess("outpost", "tenant", "list", "--id", tenantID, "--output", "json")
105105
assert.Contains(t, stdout, tenantID)
106106

107+
// The token is a real credential scoped to this tenant, so assert its shape
108+
// rather than its contents: three dot-separated JWT segments, nothing logged.
109+
stdout = cli.RunExpectSuccess("outpost", "tenant", "token", tenantID)
110+
token := strings.TrimSpace(stdout)
111+
assert.Len(t, strings.Split(token, "."), 3, "expected a JWT")
112+
assert.NotContains(t, token, tenantID, "the raw tenant id should not be readable in the token")
113+
107114
cli.RunExpectSuccess("outpost", "tenant", "delete", tenantID, "--force")
108115

109116
_, _, err := cli.Run("outpost", "tenant", "get", tenantID)
@@ -231,8 +238,52 @@ func TestOutpostPublishAndInspect(t *testing.T) {
231238
return json.Unmarshal([]byte(out), &events) == nil && len(events.Models) > 0
232239
}, 30*time.Second, 2*time.Second, "the published event never appeared")
233240

234-
stdout = cli.RunExpectSuccess("outpost", "attempt", "list", "--tenant-id", tenantID, "--limit", "5")
235-
assert.NotEmpty(t, stdout)
241+
// Fetch one event by id, using an id from the list above rather than
242+
// assuming the publish response id is queryable yet.
243+
listed := cli.RunExpectSuccess("outpost", "event", "list", "--tenant-id", tenantID, "--output", "json")
244+
var events struct {
245+
Models []struct {
246+
ID string `json:"id"`
247+
Topic string `json:"topic"`
248+
} `json:"models"`
249+
}
250+
require.NoError(t, json.Unmarshal([]byte(listed), &events))
251+
require.NotEmpty(t, events.Models)
252+
253+
stdout = cli.RunExpectSuccess("outpost", "event", "get", events.Models[0].ID, "--tenant-id", tenantID, "--output", "json")
254+
assert.Contains(t, stdout, events.Models[0].ID)
255+
assert.Contains(t, stdout, "acceptance", "the published payload should come back")
256+
257+
// Delivery to example.com fails, but a failed attempt still exercises the
258+
// read path, which is what is being checked here.
259+
var attempts struct {
260+
Models []struct {
261+
ID string `json:"id"`
262+
} `json:"models"`
263+
}
264+
require.Eventually(t, func() bool {
265+
out, _, err := cli.Run("outpost", "attempt", "list", "--tenant-id", tenantID, "--output", "json")
266+
if err != nil {
267+
return false
268+
}
269+
return json.Unmarshal([]byte(out), &attempts) == nil && len(attempts.Models) > 0
270+
}, 60*time.Second, 3*time.Second, "no delivery attempt was recorded")
271+
272+
stdout = cli.RunExpectSuccess("outpost", "attempt", "get", attempts.Models[0].ID, "--tenant-id", tenantID)
273+
assert.Contains(t, stdout, attempts.Models[0].ID)
274+
275+
t.Run("retry queues another attempt", func(t *testing.T) {
276+
destinations := cli.RunExpectSuccess("outpost", "destination", "list", "--tenant-id", tenantID, "--output", "json")
277+
var dests []struct {
278+
ID string `json:"id"`
279+
}
280+
require.NoError(t, json.Unmarshal([]byte(destinations), &dests))
281+
require.NotEmpty(t, dests)
282+
283+
out := cli.RunExpectSuccess("outpost", "event", "retry",
284+
"--event-id", events.Models[0].ID, "--destination-id", dests[0].ID)
285+
assert.Contains(t, out, "Retry accepted")
286+
})
236287
}
237288

238289
func TestOutpostPublishRequiresProjectAPIKey(t *testing.T) {

0 commit comments

Comments
 (0)