phase-enterprise-sso-proof.ts56 lines · main
| 1 | /** |
| 2 | * Local proof: SSO connection CRUD + productionReady flag on Doltgres. |
| 3 | */ |
| 4 | import { initAuthCoreSdk, isAuthCoreInitialized } from '../src/services/auth-core/engine.js'; |
| 5 | import { |
| 6 | createEngineSsoConnection, |
| 7 | deactivateEngineSsoConnection, |
| 8 | listEngineSsoConnections, |
| 9 | publicSsoConnection, |
| 10 | } from '../src/services/auth-core/sso.js'; |
| 11 | |
| 12 | async function main() { |
| 13 | await initAuthCoreSdk(); |
| 14 | if (!isAuthCoreInitialized()) { |
| 15 | console.error('FAIL engine not ready'); |
| 16 | process.exit(1); |
| 17 | } |
| 18 | const projectId = `p_sso_proof_${Date.now().toString(36)}`; |
| 19 | const incomplete = await createEngineSsoConnection({ |
| 20 | projectId, |
| 21 | name: 'draft-oidc', |
| 22 | providerType: 'oidc', |
| 23 | config: { issuer: 'https://example.com' }, |
| 24 | }); |
| 25 | console.log('incomplete ready', incomplete.ready, publicSsoConnection(incomplete).productionReady); |
| 26 | if (incomplete.ready) process.exit(1); |
| 27 | |
| 28 | const ready = await createEngineSsoConnection({ |
| 29 | projectId, |
| 30 | name: 'okta-ready', |
| 31 | providerType: 'oidc', |
| 32 | domains: ['example.com'], |
| 33 | config: { |
| 34 | issuer: 'https://dev-example.okta.com', |
| 35 | clientId: 'client', |
| 36 | clientSecret: 'secret', |
| 37 | authorizationUrl: 'https://dev-example.okta.com/oauth2/v1/authorize', |
| 38 | tokenUrl: 'https://dev-example.okta.com/oauth2/v1/token', |
| 39 | }, |
| 40 | }); |
| 41 | console.log('ready', ready.ready, publicSsoConnection(ready).productionReady); |
| 42 | if (!ready.ready) process.exit(1); |
| 43 | |
| 44 | const listed = await listEngineSsoConnections(projectId); |
| 45 | console.log('listed', listed.length); |
| 46 | if (listed.length < 2) process.exit(1); |
| 47 | |
| 48 | await deactivateEngineSsoConnection(incomplete.id); |
| 49 | await deactivateEngineSsoConnection(ready.id); |
| 50 | console.log('ENTERPRISE_SSO_PROOF_OK', { projectId }); |
| 51 | } |
| 52 | |
| 53 | main().catch((e) => { |
| 54 | console.error(e); |
| 55 | process.exit(1); |
| 56 | }); |