41 lines
1.3 KiB
TypeScript
Raw Normal View History

import { tap, expect } from '@push.rocks/tapbundle';
2025-01-10 03:09:32 +01:00
import * as smartantivirus from '../ts/index.js';
import { setupClamAV, cleanupClamAV } from './helpers/clamav.helper.js';
2025-01-10 03:09:32 +01:00
const EICAR_TEST_STRING = 'X5O!P%@AP[4\\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*';
2025-01-10 03:09:32 +01:00
let clamService: smartantivirus.ClamAvService;
tap.test('setup', async () => {
await setupClamAV();
});
tap.test('should create a ClamAvService instance and initialize ClamAV', async () => {
2025-01-10 03:09:32 +01:00
clamService = new smartantivirus.ClamAvService();
expect(clamService).toBeTruthy();
// The manager will start the container and wait for initialization
await clamService.verifyConnection();
2025-01-10 03:09:32 +01:00
});
tap.test('should detect EICAR test string', async () => {
const scanResult = await clamService.scanString(EICAR_TEST_STRING);
2025-01-10 03:09:32 +01:00
console.log('Scan Result:', scanResult);
expect(scanResult.isInfected).toEqual(true);
expect(scanResult.reason).toBeTruthy();
2025-01-10 03:09:32 +01:00
});
tap.test('should not detect clean string', async () => {
const scanResult = await clamService.scanString('This is a clean string with no virus signature');
console.log('Clean Scan Result:', scanResult);
expect(scanResult.isInfected).toEqual(false);
expect(scanResult.reason).toBeUndefined();
});
2025-01-10 03:09:32 +01:00
tap.test('cleanup', async () => {
await cleanupClamAV();
});
2025-01-10 03:09:32 +01:00
tap.start();
2025-01-10 03:09:32 +01:00