| 1 | import { describe, expect, it } from 'vitest';
|
| 2 | import {
|
| 3 | createProviderConnectionInput,
|
| 4 | hashProviderConnectionCode,
|
| 5 | publicProviderConnection,
|
| 6 | } from '../packages/persistence/src/provider-connection.js';
|
| 7 |
|
| 8 | describe('provider connections', () => {
|
| 9 | it('creates an expiring Botpress pairing code without exposing its hash', () => {
|
| 10 | const { connection, code } = createProviderConnectionInput(
|
| 11 | 'owner-a',
|
| 12 | 'botpress',
|
| 13 | 'Purchasing agent',
|
| 14 | );
|
| 15 | expect(code).toMatch(/^oc_bp_/);
|
| 16 | expect(connection.codeHash).toBe(hashProviderConnectionCode(code));
|
| 17 | expect(connection.status).toBe('pending');
|
| 18 | expect(Date.parse(connection.expiresAt)).toBeGreaterThan(Date.now());
|
| 19 | expect(publicProviderConnection(connection)).not.toHaveProperty('operatorId');
|
| 20 | expect(publicProviderConnection(connection)).not.toHaveProperty('codeHash');
|
| 21 | });
|
| 22 | });
|