From 5ff068d128c65caf7fc332823c8f4f1da4bd21c8 Mon Sep 17 00:00:00 2001 From: Kadi Gasanguseynov Date: Wed, 22 Nov 2023 23:17:39 +0300 Subject: [PATCH] add test disableRedirect.test.ts on the JS side; --- tests/disableRedirect.test.ts | 46 +++++++++++++++++++++++++++++++++++ tests/tls13.test.ts | 2 ++ 2 files changed, 48 insertions(+) diff --git a/tests/disableRedirect.test.ts b/tests/disableRedirect.test.ts index bc0703fd..d46ffd8f 100644 --- a/tests/disableRedirect.test.ts +++ b/tests/disableRedirect.test.ts @@ -1,4 +1,5 @@ import initCycleTLS from "../dist/index.js"; +jest.setTimeout(30000); let ja3 = "771,4865-4867-4866-49195-49199-52393-52392-49196-49200-49162-49161-49171-49172-51-57-47-53-10,0-23-65281-10-11-35-16-5-51-43-13-45-28-21,29-23-24-25-256-257,0"; @@ -19,6 +20,11 @@ test("Should return a 301 redirect", async () => { "get" ); expect(redirectResponse.status).toBe(301); + await cycleTLS.exit(); +}); + +test("Should return a 200 redirect", async () => { + const cycleTLS = await initCycleTLS({ port: 9121 }); const normalResponse = await cycleTLS( "https://google.com", @@ -35,3 +41,43 @@ test("Should return a 301 redirect", async () => { cycleTLS.exit(); }); + +test("Should return final url a 301 redirect", async () => { + const cycleTLS = await initCycleTLS({ port: 9122 }); + const url = "https://rb.gy/3hwz5h"; + const redirectResponse = await cycleTLS( + url, + { + body: "", + ja3: ja3, + userAgent: userAgent, + disableRedirect: true, + }, + "get" + ); + expect(redirectResponse.status).toBe(301); + expect(redirectResponse.finalUrl).toBe(url) + + cycleTLS.exit(); +}); + +test("Should return final url a 200 redirect", async () => { + const cycleTLS = await initCycleTLS({ port: 9124 }); + const url = "https://rb.gy/3hwz5h"; + + const normalResponse = await cycleTLS( + url, + { + body: "", + ja3: ja3, + userAgent: userAgent, + disableRedirect: false, + }, + "get" + ); + + expect(normalResponse.status).toBe(200); + expect(normalResponse.finalUrl).toBe("https://www.google.com/"); + + cycleTLS.exit(); +}); \ No newline at end of file diff --git a/tests/tls13.test.ts b/tests/tls13.test.ts index bc5f4dc6..706a3517 100644 --- a/tests/tls13.test.ts +++ b/tests/tls13.test.ts @@ -1,4 +1,5 @@ import initCycleTLS from "../dist/index.js"; +jest.setTimeout(10000); test("Should return a 200 response from tls 1.3", async () => { const cycleTLS = await initCycleTLS({ port: 9111 }); @@ -14,6 +15,7 @@ test("Should return a 200 response from tls 1.3", async () => { body: "", ja3: ja3, userAgent: userAgent, + insecureSkipVerify: true, }, "get" );