Skip to content

Commit

Permalink
test: update node server and tests for account linking (#234)
Browse files Browse the repository at this point in the history
  • Loading branch information
porcellus authored Sep 20, 2023
1 parent 99bbf1b commit 3384d4f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
6 changes: 6 additions & 0 deletions test/accessToken.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ describe("access token update", function () {
if (payload["tId"]) {
expectedKeys.push("tId");
}
if (payload["rsub"]) {
expectedKeys.push("rsub");
}

assert.strictEqual(Object.keys(payload).length, expectedKeys.length);
for (const key of Object.keys(payload)) {
Expand Down Expand Up @@ -176,6 +179,9 @@ describe("access token update", function () {
if (v3Payload["tId"]) {
expectedKeys.push("tId");
}
if (v3Payload["rsub"]) {
expectedKeys.push("rsub");
}

assert.strictEqual(Object.keys(v3Payload).length, expectedKeys.length);
for (const key of Object.keys(v3Payload)) {
Expand Down
2 changes: 1 addition & 1 deletion test/interception.basic1.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ addTestCases((name, transferMethod, setupFunc, setupArgs = []) => {

assert.strictEqual(
Object.keys(data).length,
v3AccessTokenSupported ? (data["tId"] !== undefined ? 9 : 8) : 0
v3AccessTokenSupported ? (data["rsub"] !== undefined ? 10 : data["tId"] !== undefined ? 9 : 8) : 0
);

// update jwt data
Expand Down
8 changes: 7 additions & 1 deletion test/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ app.use(cookieParser());

let lastSetEnableAntiCSRF = false;
let lastSetEnableJWT = false;
let accountLinkingSupported = maxVersion(supertokens_node_version, "15.0") === supertokens_node_version;

function getConfig(enableAntiCsrf, enableJWT, jwtPropertyName) {
if (enableJWT && maxVersion(supertokens_node_version, "14.0") === supertokens_node_version) {
Expand Down Expand Up @@ -207,7 +208,12 @@ app.post("/login", async (req, res) => {
let userId = req.body.userId;
let session =
MultiTenancyRecipeRaw !== undefined
? await Session.createNewSession(req, res, "public", userId)
? await Session.createNewSession(
req,
res,
"public",
accountLinkingSupported ? SuperTokens.convertToRecipeUserId(userId) : userId
)
: await Session.createNewSession(req, res, userId);
res.send(session.getUserId());
});
Expand Down
2 changes: 1 addition & 1 deletion test/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
"cookie-parser": "1.4.4",
"cors": "^2.8.5",
"express": "4.17.1",
"supertokens-node": "github:supertokens/supertokens-node#15.0"
"supertokens-node": "github:supertokens/supertokens-node#16.0"
}
}

0 comments on commit 3384d4f

Please sign in to comment.