mirror of
https://github.com/simstudioai/sim.git
synced 2026-10-31 03:47:12 +08:00
* feat(secrets): let workspace secrets opt out of redaction * fix(secrets): certify no sandbox exemptions once the registry is incomplete * feat(secrets): carry visible secret values on the v2 list and document visibility * fix(secrets): read visible values by own property so prototype-named secrets cannot poison the list
49 lines
1.4 KiB
TypeScript
49 lines
1.4 KiB
TypeScript
/**
|
|
* @vitest-environment node
|
|
*/
|
|
import { describe, expect, it } from 'vitest'
|
|
import {
|
|
updateCredentialByIdBodySchema,
|
|
workspaceCredentialSchema,
|
|
} from '@/lib/api/contracts/credentials'
|
|
|
|
const credential = {
|
|
id: 'credential-1',
|
|
workspaceId: 'workspace-1',
|
|
type: 'env_workspace' as const,
|
|
displayName: 'STRIPE_API_KEY',
|
|
description: null,
|
|
providerId: null,
|
|
accountId: null,
|
|
envKey: 'STRIPE_API_KEY',
|
|
envOwnerUserId: null,
|
|
createdBy: 'user-1',
|
|
createdAt: '2026-01-01T00:00:00.000Z',
|
|
updatedAt: '2026-01-02T00:00:00.000Z',
|
|
}
|
|
|
|
describe('updateCredentialByIdBodySchema unredacted', () => {
|
|
it('accepts unredacted alone as the one updated field', () => {
|
|
const parsed = updateCredentialByIdBodySchema.safeParse({ unredacted: true })
|
|
|
|
expect(parsed.success).toBe(true)
|
|
if (parsed.success) expect(parsed.data).toEqual({ unredacted: true })
|
|
})
|
|
|
|
it('still rejects an empty update body', () => {
|
|
expect(updateCredentialByIdBodySchema.safeParse({}).success).toBe(false)
|
|
})
|
|
})
|
|
|
|
describe('workspaceCredentialSchema unredacted', () => {
|
|
it('accepts a credential carrying unredacted: false', () => {
|
|
const parsed = workspaceCredentialSchema.parse({ ...credential, unredacted: false })
|
|
|
|
expect(parsed.unredacted).toBe(false)
|
|
})
|
|
|
|
it('requires the field so a response cannot silently drop it', () => {
|
|
expect(workspaceCredentialSchema.safeParse(credential).success).toBe(false)
|
|
})
|
|
})
|