hoppscotch-backend-git/tests/os-user.test.ts
tlemesle 19bab4f3c9 Identify local user from macOS dscl
Resolve RecordName, EMailAddress & RealName via dscl at startup and use that account for all requests without interactive login.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-24 15:24:57 +02:00

22 lines
772 B
TypeScript

import { describe, expect, test } from 'bun:test';
import {
readOsIdentity,
userFromOsIdentity,
} from '../src/os-user.ts';
describe('os-user (dscl)', () => {
test('reads RecordName and EMailAddress from dscl', async () => {
const identity = await readOsIdentity();
expect(identity.recordName.length).toBeGreaterThan(0);
expect(identity.email).toContain('@');
expect(identity.displayName.length).toBeGreaterThan(0);
const user = await userFromOsIdentity(identity);
expect(user.uid).toMatch(
/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/,
);
expect(user.email).toBe(identity.email);
expect(user.displayName).toBe(identity.displayName);
});
});