From b3f5436de21ec632270860cb1c19a83d5f02ee51 Mon Sep 17 00:00:00 2001 From: Deniz Ariyan Date: Thu, 5 May 2022 20:39:42 +0300 Subject: [PATCH] Add comments to automated test files --- tests/config.test.js | 16 ++++++++++++++++ tests/scan.test.js | 9 +++++++++ 2 files changed, 25 insertions(+) diff --git a/tests/config.test.js b/tests/config.test.js index a17f1f9..cf1ca60 100644 --- a/tests/config.test.js +++ b/tests/config.test.js @@ -1,16 +1,28 @@ const config = require('../scripts/config'); const { tcpPingPort } = require("tcp-ping-port") +/** + * Test enabling the quarantine mode using the configuration manager + * This tests both launching the configuration server and the configuration changer function + */ test('Enable quarantine mode', async () => { let testReturn = await config.changeParam("quarantineInfected", "/usr/VSterilizer/infected/", "./tests/sources/.test.env") expect(testReturn).toBe("quarantineInfected mode enabled"); }); +/** + * Test enabling the removal mode using the configuration manager + * This tests both launching the configuration server and the configuration changer function + */ test('Enable remove mode', async () => { let testReturn = await config.changeParam("removeInfected", "True", "./tests/sources/.test.env") expect(testReturn).toBe("removeInfected mode enabled"); }); +/** + * Test the reachability of the configuration changing API endpoint + * This tests both launching the configuration server and the reachability of it + */ test('Check server reachability', async () => { let res = await tcpPingPort("0.0.0.0", 8080).then(status => { return status.online; @@ -18,6 +30,10 @@ test('Check server reachability', async () => { expect(res).toBe(true); }); +/** + * Close the configuration server after all tests are complete + * This tests exiting from the server and creates a graceful exit opportunity + */ afterAll(() => { config.server.close(); }); diff --git a/tests/scan.test.js b/tests/scan.test.js index ac2a95a..f23dbac 100644 --- a/tests/scan.test.js +++ b/tests/scan.test.js @@ -1,10 +1,19 @@ const scan = require('../scripts/scan'); +/** + * Parse the test log file to try getting the name of the infected file + * This tests both the parser function and the generation of the scan results + */ test('Parse log file to test getting file name of infected file', async () => { let parseTest = await scan.parseLog("/home/deari/Downloads/", "./tests/sources/test.log") expect(parseTest[0].filename).toBe("eicar.com"); }); +/** + * Parse the test log file to try getting the name of the virus + * that the test file is infected with. This tests both the parser function + * and the generation of the scan results + */ test('Parse log file to test getting virus name', async () => { let parseTest = await scan.parseLog("/home/deari/Downloads/", "./tests/sources/test.log") expect(parseTest[0].virus).toBe("Win.Test.EICAR_HDB-1");