From ef54a6afeddf72be137fd1b1cf42deb37a5afd6d Mon Sep 17 00:00:00 2001 From: Kevin Heise Date: Fri, 16 Feb 2024 16:00:26 +0000 Subject: [PATCH] add test for handling web stream --- typescript/tests/test.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/typescript/tests/test.ts b/typescript/tests/test.ts index e66f5ada..792720fd 100644 --- a/typescript/tests/test.ts +++ b/typescript/tests/test.ts @@ -14,7 +14,7 @@ import { import ClientCredentialsGrantAuthenticator from "../src/ClientCredentialsGrantAuthenticator"; import ResourceOwnerPasswordGrantAuthenticator from "../src/ResourceOwnerPasswordGrantAuthenticator"; import { Readable } from "stream"; -import axios from "axios"; +import axios, { AxiosResponse } from "axios"; const chai = require("chai"); const chaiAsPromised = require("chai-as-promised"); @@ -205,7 +205,7 @@ describe("Test verdict requests", function () { expect(verdict2.verdict).to.equal("Clean"); expect(verdict2.sha256.toUpperCase()).to.equal("3A78F382E8E2968EC201B33178102E06DB72E4F2D1505E058A4613C1E977825C"); }); - + https://www.virustotal.com/gui/file/edb6991d68ba5c7ed43f198c3d2593c770f2634beeb8c83afe3138279e5e81f3 xit("keeps connection alive", async () => { const vaas = await createVaasWithClientCredentialsGrantAuthenticator(); const sha256 = @@ -252,11 +252,18 @@ describe("Test verdict requests", function () { const vaas = await createVaasWithClientCredentialsGrantAuthenticator(); const stream = new Readable(); stream._read = () => {}; - stream.push("X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*"); + stream.push(`X5O!P%@AP[4\\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*`); stream.push(null); const verdict = await vaas.forStream(stream); expect(verdict.verdict).to.equal("Malicious"); }); + + it('if a EICAR stream from an url is submitted, a verdict "malicious" is expected', async () => { + const vaas = await createVaasWithClientCredentialsGrantAuthenticator(); + const response = await axios.get("https://secure.eicar.org/eicar.com.txt", { responseType: "stream" }); + const verdict = await vaas.forStream(response.data); + expect(verdict.verdict).to.equal("Malicious"); + }); }); describe("Vaas", async () => {