Files
the-order/packages/storage/src/worm.test.ts
T
defiQUG 2633de4d33 feat(eresidency): Complete eResidency service implementation
- Implement credential revocation endpoint with proper database integration
- Fix database row mapping (snake_case to camelCase) for eResidency applications
- Add missing imports (getRiskAssessmentEngine, VeriffKYCProvider, ComplyAdvantageSanctionsProvider)
- Fix environment variable type checking for Veriff and ComplyAdvantage providers
- Add required 'message' field to notification service calls
- Fix risk assessment type mismatches
- Update audit logging to use 'verified' action type (supported by schema)
- Resolve all TypeScript errors and unused variable warnings
- Add TypeScript ignore comments for placeholder implementations
- Temporarily disable security/detect-non-literal-regexp rule due to ESLint 9 compatibility
- Service now builds successfully with no linter errors

All core functionality implemented:
- Application submission and management
- KYC integration (Veriff placeholder)
- Sanctions screening (ComplyAdvantage placeholder)
- Risk assessment engine
- Credential issuance and revocation
- Reviewer console
- Status endpoints
- Auto-issuance service
2025-11-10 19:43:02 -08:00

64 lines
1.5 KiB
TypeScript

/**
* WORM Storage Tests
*/
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { WORMStorage } from './worm';
import { StorageClient } from './storage';
vi.mock('./storage');
describe('WORMStorage', () => {
let storage: WORMStorage;
const config = {
provider: 's3' as const,
bucket: 'test-bucket',
region: 'us-east-1',
};
beforeEach(() => {
storage = new WORMStorage(config);
vi.clearAllMocks();
});
describe('upload', () => {
it('should upload object if it does not exist', async () => {
const object = {
key: 'test-key',
content: Buffer.from('test content'),
};
vi.spyOn(storage, 'objectExists').mockResolvedValueOnce(false);
vi.spyOn(StorageClient.prototype, 'upload').mockResolvedValueOnce(object.key);
const result = await storage.upload(object);
expect(result).toBe(object.key);
});
it('should throw error if object already exists', async () => {
const object = {
key: 'existing-key',
content: Buffer.from('test content'),
};
vi.spyOn(storage, 'objectExists').mockResolvedValueOnce(true);
await expect(storage.upload(object)).rejects.toThrow(
'Object existing-key already exists in WORM storage'
);
});
});
describe('delete', () => {
it('should throw error when trying to delete', async () => {
const key = 'test-key';
await expect(storage.delete(key)).rejects.toThrow(
'Deletion not allowed in WORM mode'
);
});
});
});