From 251d80cacf8530ec76b5d8c9a556a5d73e9f39ab Mon Sep 17 00:00:00 2001 From: Sattvik Chakravarthy Date: Tue, 16 Jul 2024 15:07:02 +0530 Subject: [PATCH] fix: cicd tests (#887) --- test/session.test.js | 11 ++++++++ ...sessionAccessTokenSigningKeyUpdate.test.js | 26 ++++++++++++++++--- test/sessionExpress.test.js | 2 +- test/thirdparty/tpConfigsForVerification.js | 3 ++- 4 files changed, 37 insertions(+), 5 deletions(-) diff --git a/test/session.test.js b/test/session.test.js index 97fdfad8c..0fecb5048 100644 --- a/test/session.test.js +++ b/test/session.test.js @@ -752,6 +752,7 @@ describe(`session: ${printPath("[test/session.test.js]")}`, function () { response2.antiCsrfToken, true, false, + SessionRecipe.getInstanceOrThrowError().config, {} ); @@ -812,6 +813,7 @@ describe(`session: ${printPath("[test/session.test.js]")}`, function () { response2.antiCsrfToken, true, false, + SessionRecipe.getInstanceOrThrowError().config, {} ); @@ -897,6 +899,7 @@ describe(`session: ${printPath("[test/session.test.js]")}`, function () { response.antiCsrfToken, true, false, + SessionRecipe.getInstanceOrThrowError().config, {} ); let verifyState3 = await ProcessState.getInstance().waitForEvent(PROCESS_STATE.CALLING_SERVICE_IN_VERIFY, 1500); @@ -922,6 +925,7 @@ describe(`session: ${printPath("[test/session.test.js]")}`, function () { response2.antiCsrfToken, true, false, + SessionRecipe.getInstanceOrThrowError().config, {} ); let verifyState = await ProcessState.getInstance().waitForEvent(PROCESS_STATE.CALLING_SERVICE_IN_VERIFY); @@ -938,6 +942,7 @@ describe(`session: ${printPath("[test/session.test.js]")}`, function () { response2.antiCsrfToken, true, false, + SessionRecipe.getInstanceOrThrowError().config, {} ); let verifyState2 = await ProcessState.getInstance().waitForEvent(PROCESS_STATE.CALLING_SERVICE_IN_VERIFY, 1000); @@ -987,6 +992,7 @@ describe(`session: ${printPath("[test/session.test.js]")}`, function () { response.antiCsrfToken, true, true, + SessionRecipe.getInstanceOrThrowError().config, {} ); assert(response2.session != undefined); @@ -998,6 +1004,7 @@ describe(`session: ${printPath("[test/session.test.js]")}`, function () { response.antiCsrfToken, false, true, + SessionRecipe.getInstanceOrThrowError().config, {} ); assert(response3.session != undefined); @@ -1038,6 +1045,7 @@ describe(`session: ${printPath("[test/session.test.js]")}`, function () { undefined, false, false, + SessionRecipe.getInstanceOrThrowError().config, {} ); @@ -1052,6 +1060,7 @@ describe(`session: ${printPath("[test/session.test.js]")}`, function () { undefined, true, false, + SessionRecipe.getInstanceOrThrowError().config, {} ); throw new Error("should not have come here"); @@ -1579,6 +1588,7 @@ describe(`session: ${printPath("[test/session.test.js]")}`, function () { undefined, false, true, + SessionRecipe.getInstanceOrThrowError().config, {} ); assert(response2.session != undefined); @@ -1591,6 +1601,7 @@ describe(`session: ${printPath("[test/session.test.js]")}`, function () { undefined, true, true, + SessionRecipe.getInstanceOrThrowError().config, {} ); assert(response3.session != undefined); diff --git a/test/sessionAccessTokenSigningKeyUpdate.test.js b/test/sessionAccessTokenSigningKeyUpdate.test.js index 52fd10671..f237fbc67 100644 --- a/test/sessionAccessTokenSigningKeyUpdate.test.js +++ b/test/sessionAccessTokenSigningKeyUpdate.test.js @@ -102,6 +102,7 @@ describe(`sessionAccessTokenSigningKeyUpdate: ${printPath( response.antiCsrfToken, true, false, + SessionRecipe.getInstanceOrThrowError().config, {} ); @@ -125,6 +126,7 @@ describe(`sessionAccessTokenSigningKeyUpdate: ${printPath( response.antiCsrfToken, true, false, + SessionRecipe.getInstanceOrThrowError().config, {} ); } catch (err) { @@ -169,6 +171,7 @@ describe(`sessionAccessTokenSigningKeyUpdate: ${printPath( response2.antiCsrfToken, true, false, + SessionRecipe.getInstanceOrThrowError().config, {} ); @@ -192,7 +195,9 @@ describe(`sessionAccessTokenSigningKeyUpdate: ${printPath( parseJWTWithoutSignatureVerification(response3.accessToken.token), response2.antiCsrfToken, true, - false + false, + SessionRecipe.getInstanceOrThrowError().config, + {} ); assert.strictEqual(response4.accessToken, undefined); @@ -263,6 +268,7 @@ describe(`sessionAccessTokenSigningKeyUpdate: ${printPath( newSession.antiCsrfToken, true, false, + SessionRecipe.getInstanceOrThrowError().config, {} ); @@ -284,7 +290,9 @@ describe(`sessionAccessTokenSigningKeyUpdate: ${printPath( parseJWTWithoutSignatureVerification(oldSession.accessToken.token), oldSession.antiCsrfToken, true, - false + false, + SessionRecipe.getInstanceOrThrowError().config, + {} ); let verifyState = await ProcessState.getInstance().waitForEvent( @@ -341,6 +349,7 @@ describe(`sessionAccessTokenSigningKeyUpdate: ${printPath( response.antiCsrfToken, true, false, + SessionRecipe.getInstanceOrThrowError().config, {} ); @@ -361,6 +370,7 @@ describe(`sessionAccessTokenSigningKeyUpdate: ${printPath( response2.antiCsrfToken, true, false, + SessionRecipe.getInstanceOrThrowError().config, {} ); // Old core versions should throw here because the signing key was updated @@ -429,6 +439,7 @@ describe(`sessionAccessTokenSigningKeyUpdate: ${printPath( response.antiCsrfToken, true, false, + SessionRecipe.getInstanceOrThrowError().config, {} ); @@ -450,7 +461,9 @@ describe(`sessionAccessTokenSigningKeyUpdate: ${printPath( parseJWTWithoutSignatureVerification(response2.accessToken.token), response2.antiCsrfToken, true, - false + false, + SessionRecipe.getInstanceOrThrowError().config, + {} ); } catch (err) { if (err.type !== Session.Error.TRY_REFRESH_TOKEN) { @@ -507,6 +520,7 @@ describe(`sessionAccessTokenSigningKeyUpdate: ${printPath( session.antiCsrfToken, true, false, + SessionRecipe.getInstanceOrThrowError().config, {} ); @@ -536,6 +550,7 @@ describe(`sessionAccessTokenSigningKeyUpdate: ${printPath( session.antiCsrfToken, true, false, + SessionRecipe.getInstanceOrThrowError().config, {} ); @@ -565,6 +580,7 @@ describe(`sessionAccessTokenSigningKeyUpdate: ${printPath( session2.antiCsrfToken, true, false, + SessionRecipe.getInstanceOrThrowError().config, {} ); @@ -589,6 +605,7 @@ describe(`sessionAccessTokenSigningKeyUpdate: ${printPath( session2.antiCsrfToken, true, false, + SessionRecipe.getInstanceOrThrowError().config, {} ); @@ -610,6 +627,7 @@ describe(`sessionAccessTokenSigningKeyUpdate: ${printPath( session.antiCsrfToken, true, false, + SessionRecipe.getInstanceOrThrowError().config, {} ); fail(); @@ -673,6 +691,7 @@ describe(`sessionAccessTokenSigningKeyUpdate: ${printPath( session.antiCsrfToken, true, false, + SessionRecipe.getInstanceOrThrowError().config, {} ); @@ -694,6 +713,7 @@ describe(`sessionAccessTokenSigningKeyUpdate: ${printPath( session.antiCsrfToken, true, false, + SessionRecipe.getInstanceOrThrowError().config, {} ); diff --git a/test/sessionExpress.test.js b/test/sessionExpress.test.js index 6a3ed3558..a931dd2cf 100644 --- a/test/sessionExpress.test.js +++ b/test/sessionExpress.test.js @@ -3263,7 +3263,7 @@ describe(`sessionExpress: ${printPath("[test/sessionExpress.test.js]")}`, functi apiDomain: "api.supertokens.io", appName: "SuperTokens", origin: ({ request }) => { - if (request.getHeaderValue("origin") !== undefined) { + if (request !== undefined && request.getHeaderValue("origin") !== undefined) { return request.getHeaderValue("origin"); } diff --git a/test/thirdparty/tpConfigsForVerification.js b/test/thirdparty/tpConfigsForVerification.js index a6d94900d..72e8bb6cc 100644 --- a/test/thirdparty/tpConfigsForVerification.js +++ b/test/thirdparty/tpConfigsForVerification.js @@ -4,7 +4,8 @@ const privateKey = "-----BEGIN PRIVATE KEY-----\nMIGTAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBHkwdwIBAQQgu8gXs+XYkqXD6Ala9Sf/iJXzhbwcoG5dMh1OonpdJUmgCgYIKoZIzj0DAQehRANCAASfrvlFbFCYqn3I2zeknYXLwtH30JuOKestDbSfZYxZNMqhF/OzdZFTV0zc5u5s3eN+oCWbnvl0hM+9IW0UlkdA\n-----END PRIVATE KEY-----"; const configsForVerification = { "active-directory": { - oidcDiscoveryEndpoint: "https://login.microsoftonline.com/97f9a564-fcee-4b88-ae34-a1fbc4656593/v2.0/", + oidcDiscoveryEndpoint: + "https://login.microsoftonline.com/97f9a564-fcee-4b88-ae34-a1fbc4656593/v2.0/.well-known/openid-configuration", scope: ["openid", "email"], authorizationEndpoint: "https://login.microsoftonline.com/97f9a564-fcee-4b88-ae34-a1fbc4656593/oauth2/v2.0/authorize",