Skip to content

Commit

Permalink
Merge pull request #45 from supertokens/fix-tests
Browse files Browse the repository at this point in the history
chore: update node server and tests for account linking
  • Loading branch information
rishabhpoddar authored Sep 22, 2023
2 parents 440e8d1 + 1765207 commit 291f30e
Show file tree
Hide file tree
Showing 5 changed files with 159 additions and 197 deletions.
8 changes: 8 additions & 0 deletions test/accesstoken_dio_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ void main() {
expectedKeys.add("tId");
}

if (payload["rsub"] != null) {
expectedKeys.add("rsub");
}

assert(payload.length == expectedKeys.length);
for (var key in payload.keys) {
assert(expectedKeys.contains(key));
Expand Down Expand Up @@ -111,6 +115,10 @@ void main() {
expectedKeys.add("tId");
}

if (v3Payload["rsub"] != null) {
expectedKeys.add("rsub");
}

assert(v3Payload.length == expectedKeys.length);
for (var key in v3Payload.keys) {
assert(expectedKeys.contains(key));
Expand Down
8 changes: 8 additions & 0 deletions test/accesstoken_http_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ void main() {
expectedKeys.add("tId");
}

if (payload["rsub"] != null) {
expectedKeys.add("rsub");
}

assert(payload.length == expectedKeys.length);
for (var key in payload.keys) {
assert(expectedKeys.contains(key));
Expand Down Expand Up @@ -100,6 +104,10 @@ void main() {
expectedKeys.add("tId");
}

if (v3Payload["rsub"] != null) {
expectedKeys.add("rsub");
}

assert(v3Payload.length == expectedKeys.length);
for (var key in v3Payload.keys) {
assert(expectedKeys.contains(key));
Expand Down
3 changes: 2 additions & 1 deletion testHelpers/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,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 (maxVersion(supertokens_node_version, "14.0") === supertokens_node_version && enableJWT) {
Expand Down Expand Up @@ -212,7 +213,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);
}
Expand Down
Loading

0 comments on commit 291f30e

Please sign in to comment.