From 7d9939f7f8c514031cef4ff66cf720c6d4a97ea6 Mon Sep 17 00:00:00 2001 From: Nemi Shah Date: Fri, 22 Sep 2023 14:39:29 +0530 Subject: [PATCH] Fix tests --- TestingApp/test/accesstoken.axios.spec.js | 8 ++++++++ TestingApp/test/accesstoken.fetch.spec.js | 8 ++++++++ TestingApp/test/server/index.js | 4 +++- TestingApp/test/server/package.json | 2 +- 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/TestingApp/test/accesstoken.axios.spec.js b/TestingApp/test/accesstoken.axios.spec.js index f485d8c..24da1d3 100644 --- a/TestingApp/test/accesstoken.axios.spec.js +++ b/TestingApp/test/accesstoken.axios.spec.js @@ -145,6 +145,10 @@ describe("Axios AuthHttpRequest class tests", function() { expectedKeys.push("tId"); } + if (payload["rsub"]) { + expectedKeys.push("rsub"); + } + assertEqual(Object.keys(payload).length, expectedKeys.length); for (const key of Object.keys(payload)) { assert(expectedKeys.includes(key)); @@ -205,6 +209,10 @@ describe("Axios AuthHttpRequest class tests", function() { expectedKeys.push("tId"); } + if (v3Payload["rsub"]) { + expectedKeys.push("rsub"); + } + assert.strictEqual(Object.keys(v3Payload).length, expectedKeys.length); for (const key of Object.keys(v3Payload)) { assert(expectedKeys.includes(key)); diff --git a/TestingApp/test/accesstoken.fetch.spec.js b/TestingApp/test/accesstoken.fetch.spec.js index cd278ac..e2fe673 100644 --- a/TestingApp/test/accesstoken.fetch.spec.js +++ b/TestingApp/test/accesstoken.fetch.spec.js @@ -150,6 +150,10 @@ describe("Fetch AuthHttpRequest class tests", function() { expectedKeys.push("tId"); } + if (payload["rsub"]) { + expectedKeys.push("rsub"); + } + assertEqual(Object.keys(payload).length, expectedKeys.length); for (const key of Object.keys(payload)) { assert(expectedKeys.includes(key)); @@ -210,6 +214,10 @@ describe("Fetch AuthHttpRequest class tests", function() { expectedKeys.push("tId"); } + if (v3Payload["rsub"]) { + expectedKeys.push("rsub"); + } + assert.strictEqual(Object.keys(v3Payload).length, expectedKeys.length); for (const key of Object.keys(v3Payload)) { assert(expectedKeys.includes(key)); diff --git a/TestingApp/test/server/index.js b/TestingApp/test/server/index.js index 05f8929..5bd8e4e 100644 --- a/TestingApp/test/server/index.js +++ b/TestingApp/test/server/index.js @@ -58,6 +58,8 @@ if (maxVersion(nodeSDKVersion, "10.0.0") === nodeSDKVersion) { generalErrorSupported = false; } +let accountLinkingSupported = maxVersion(nodeSDKVersion, "15.0") === nodeSDKVersion; + let urlencodedParser = bodyParser.urlencoded({ limit: "20mb", extended: true, parameterLimit: 20000 }); let jsonParser = bodyParser.json({ limit: "20mb" }); @@ -249,7 +251,7 @@ app.post("/login", async (req, res) => { let session; if (multitenancySupported) { - session = await Session.createNewSession(req, res, "public", userId); + session = await Session.createNewSession(req, res, "public", accountLinkingSupported ? SuperTokens.convertToRecipeUserId(userId) : userId); } else { session = await Session.createNewSession(req, res, userId); } diff --git a/TestingApp/test/server/package.json b/TestingApp/test/server/package.json index df24cb7..4d5b3cd 100644 --- a/TestingApp/test/server/package.json +++ b/TestingApp/test/server/package.json @@ -12,6 +12,6 @@ "cookie-parser": "1.4.4", "cors": "^2.8.5", "express": "4.17.1", - "supertokens-node": "^15.0.2" + "supertokens-node": "github:supertokens/supertokens-node#16.0" } }