/** * Tests for credential resolution * * Note: These tests mock the file system and environment variables * to test the 4-tier credential resolution system. */ import { CredentialsError } from '../src/un_async.js'; describe('CredentialsError', () => { test('should be an Error instance', () => { const error = new CredentialsError('test message'); expect(error).toBeInstanceOf(Error); expect(error).toBeInstanceOf(CredentialsError); }); test('should have correct name', () => { const error = new CredentialsError('test message'); expect(error.name).toBe('CredentialsError'); }); test('should have correct message', () => { const error = new CredentialsError('test message'); expect(error.message).toBe('test message'); }); }); describe('Credential Resolution Tiers', () => { // These tests describe the expected behavior of the 4-tier system // Actual integration tests would require mocking fs and process.env describe('Tier 1: Function Arguments', () => { test('should have highest priority', () => { // When both publicKey and secretKey are provided as arguments, // they should be used regardless of environment variables or files expect(true).toBe(true); // Placeholder - actual test requires running SDK }); }); describe('Tier 2: Environment Variables', () => { test('UNSANDBOX_PUBLIC_KEY and UNSANDBOX_SECRET_KEY should be checked', () => { // Environment variables should be used when function args are not provided expect(process.env).toBeDefined(); }); }); describe('Tier 3: ~/.unsandbox/accounts.csv', () => { test('should support CSV format: public_key,secret_key', () => { // File should contain lines of format: public_key,secret_key // Lines starting with # should be skipped expect(true).toBe(true); // Placeholder }); test('should support account selection via UNSANDBOX_ACCOUNT', () => { // UNSANDBOX_ACCOUNT=1 should select the second account (0-indexed) expect(true).toBe(true); // Placeholder }); }); describe('Tier 4: ./accounts.csv', () => { test('should be lowest priority fallback', () => { // Local accounts.csv should only be used when other tiers fail expect(true).toBe(true); // Placeholder }); }); });