sso.test.ts47 lines · main
| 1 | import { describe, expect, test } from 'bun:test'; |
| 2 | |
| 3 | import { publicSsoConnection, type SsoConnection } from './sso.js'; |
| 4 | |
| 5 | describe('enterprise SSO helpers', () => { |
| 6 | test('publicSsoConnection strips secrets and flags productionReady', () => { |
| 7 | const conn: SsoConnection = { |
| 8 | id: 'bsc_x', |
| 9 | projectId: 'p_1', |
| 10 | tenantId: 'proj-p-1', |
| 11 | name: 'Okta', |
| 12 | providerType: 'oidc', |
| 13 | domains: ['acme.com'], |
| 14 | config: { |
| 15 | issuer: 'https://example.okta.com', |
| 16 | clientId: 'cid', |
| 17 | clientSecret: 'secret', |
| 18 | }, |
| 19 | jitEnabled: true, |
| 20 | deactivatedAt: null, |
| 21 | createdAt: new Date().toISOString(), |
| 22 | ready: true, |
| 23 | }; |
| 24 | const pub = publicSsoConnection(conn); |
| 25 | expect((pub as { config?: unknown }).config).toBeUndefined(); |
| 26 | expect(pub.productionReady).toBe(true); |
| 27 | expect(pub.configKeys).toContain('clientSecret'); |
| 28 | expect(pub.name).toBe('Okta'); |
| 29 | }); |
| 30 | |
| 31 | test('incomplete connection is not productionReady', () => { |
| 32 | const conn: SsoConnection = { |
| 33 | id: 'bsc_y', |
| 34 | projectId: 'p_1', |
| 35 | tenantId: 'proj-p-1', |
| 36 | name: 'Draft', |
| 37 | providerType: 'saml', |
| 38 | domains: [], |
| 39 | config: { idpSsoUrl: 'https://idp.example/sso' }, |
| 40 | jitEnabled: true, |
| 41 | deactivatedAt: null, |
| 42 | createdAt: new Date().toISOString(), |
| 43 | ready: false, |
| 44 | }; |
| 45 | expect(publicSsoConnection(conn).productionReady).toBe(false); |
| 46 | }); |
| 47 | }); |