Skip to content

Commit 68e83fd

Browse files
committed
test(credentials): save on the proof a renewal returns, and record the keyless-subject usage fence
1 parent 6d01b28 commit 68e83fd

2 files changed

Lines changed: 25 additions & 8 deletions

File tree

‎apps/docs/scripts/fixtures/content-baseline.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3072,7 +3072,7 @@
30723072
{
30733073
"lang": "bash",
30743074
"meta": null,
3075-
"sha256": "57a7270a0eaa11ca8fe83eedaf7846ab9193ecbc2e2a1d2189f5a350d7881fdc",
3075+
"sha256": "866eaf5e25ac2d6471b52118f082a507d5300b7c80cd82ecbe3cfbce598c5f6a",
30763076
"bytes": 44,
30773077
"line": 351
30783078
},
@@ -11197,7 +11197,7 @@
1119711197
{
1119811198
"lang": "bash",
1119911199
"meta": null,
11200-
"sha256": "57a7270a0eaa11ca8fe83eedaf7846ab9193ecbc2e2a1d2189f5a350d7881fdc",
11200+
"sha256": "866eaf5e25ac2d6471b52118f082a507d5300b7c80cd82ecbe3cfbce598c5f6a",
1120111201
"bytes": 44,
1120211202
"line": 800
1120311203
},

‎apps/sim/lib/credentials/__integration__/workload-identity-pending-subject.integration.ts‎

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
workspace,
1515
} from '@sim/db/schema'
1616
import { deleteWorkspaceFixture, insertWorkspaceFixture } from '@sim/db/testing/workspace-fixtures'
17+
import { createSessionPrincipal } from '@sim/testing/factories/principal.factory'
1718
import { jsonResponse } from '@sim/testing/helpers/http'
1819
import { posthogServerMock } from '@sim/testing/mocks/posthog-server.mock'
1920
import { generateId } from '@sim/utils/id'
@@ -52,6 +53,7 @@ vi.mock('@/lib/core/security/input-validation.server', async (importOriginal) =>
5253
}
5354
})
5455

56+
import { prepareWorkloadIdentity } from '@/lib/credentials/application/prepare-workload-identity'
5557
import { updateCredentialRecord } from '@/lib/credentials/orchestration'
5658
import { createCredentialRecord } from '@/lib/credentials/orchestration/credential-create'
5759
import {
@@ -174,14 +176,29 @@ describe('holding an unsaved keyless subject', () => {
174176
const held = await resolvePendingWorkloadIdentitySubject(issuer, { kind: 'new' }, tenDaysAgo)
175177
pinnedSubjects.add(held.subject)
176178

177-
const renewed = await resolvePendingWorkloadIdentitySubject(issuer, {
178-
kind: 'renew',
179-
subject: held.subject,
179+
const renewed = await prepareWorkloadIdentity.execute({
180+
principal: createSessionPrincipal({ userId }),
181+
input: {
182+
workspaceId,
183+
provider: 'databricks',
184+
subjectRequest: { kind: 'renew', subject: held.subject },
185+
},
180186
})
181-
const saved = await create('Renewed lakehouse', keyless(renewed.subject))
187+
if (!renewed.available) throw new Error('Keyless signing should be available in this suite')
188+
const saved = await create(
189+
'Renewed lakehouse',
190+
JSON.stringify({
191+
authType: 'oidc_federation',
192+
host: HOST,
193+
clientId: CLIENT_ID,
194+
subject: renewed.subject,
195+
subjectProof: renewed.subjectProof,
196+
})
197+
)
182198

183-
expect(renewed.issuedAt.getTime()).toBe(tenDaysAgo.getTime())
184-
expect(renewed.heldUntil.getTime()).toBeGreaterThan(
199+
expect(renewed.subject).toBe(held.subject)
200+
expect(renewed.subjectIssuedAt).toBe(tenDaysAgo.toISOString())
201+
expect(Date.parse(renewed.subjectHeldUntil)).toBeGreaterThan(
185202
Date.now() + PENDING_SUBJECT_HOLD_MS - DAY_MS
186203
)
187204
expect(saved.success).toBe(true)

0 commit comments

Comments
 (0)