Skip to content

Commit

Permalink
Add comments to automated test files
Browse files Browse the repository at this point in the history
  • Loading branch information
denizariyan committed May 5, 2022
1 parent 3926ea3 commit b3f5436
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/config.test.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,39 @@
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;
})
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();
});
9 changes: 9 additions & 0 deletions tests/scan.test.js
Original file line number Diff line number Diff line change
@@ -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");
Expand Down

0 comments on commit b3f5436

Please sign in to comment.