Skip to content

Commit

Permalink
Merge pull request #39 from supertokens/cicd-fix
Browse files Browse the repository at this point in the history
chore: Update code to run with latest node
  • Loading branch information
rishabhpoddar authored Aug 1, 2023
2 parents 84e8bc9 + fde75cb commit 515a8d7
Show file tree
Hide file tree
Showing 6 changed files with 275 additions and 705 deletions.
8 changes: 6 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,13 @@ We're so excited you're interested in helping with SuperTokens! We are happy to
cd ./testHelpers/server/
npm i -d
```
5. Run all tests
5. Start the testing server
```
flutter test
TEST_MODE=testing INSTALL_PATH=../../../supertokens-root node .
```
6. In a new terminal, navigate to the `supertokens-flutter` repository and run all tests
```
flutter test --concurrency=1
```

## Pull Request
Expand Down
8 changes: 8 additions & 0 deletions test/accesstoken_dio_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ void main() {
"iss"
];

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

assert(payload.length == expectedKeys.length);
for (var key in payload.keys) {
assert(expectedKeys.contains(key));
Expand Down Expand Up @@ -103,6 +107,10 @@ void main() {
"asdf"
];

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

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 @@ -53,6 +53,10 @@ void main() {
"iss"
];

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

assert(payload.length == expectedKeys.length);
for (var key in payload.keys) {
assert(expectedKeys.contains(key));
Expand Down Expand Up @@ -92,6 +96,10 @@ void main() {
"asdf"
];

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

assert(v3Payload.length == expectedKeys.length);
for (var key in v3Payload.keys) {
assert(expectedKeys.contains(key));
Expand Down
23 changes: 22 additions & 1 deletion testHelpers/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ let supertokens_node_version = require("supertokens-node/lib/build/version").ver
let Querier = require("supertokens-node/lib/build/querier").Querier;
let NormalisedURLPath = require("supertokens-node/lib/build/normalisedURLPath").default;

let Multitenancy, MultitenancyRaw, multitenancySupported;
try {
MultitenancyRaw = require("supertokens-node/lib/build/recipe/multitenancy/recipe").default;
Multitenancy = require("supertokens-node/lib/build/recipe/multitenancy");
multitenancySupported = true;
} catch {
multitenancySupported = false;
}

let urlencodedParser = bodyParser.urlencoded({ limit: "20mb", extended: true, parameterLimit: 20000 });
let jsonParser = bodyParser.json({ limit: "20mb" });

Expand Down Expand Up @@ -200,7 +209,14 @@ app.use(middleware());

app.post("/login", async (req, res) => {
let userId = req.body.userId;
let session = await Session.createNewSession(req, res, userId);

let session;
if (multitenancySupported) {
session = await Session.createNewSession(req, res, "public", userId);
} else {
session = await Session.createNewSession(req, res, userId);
}

res.send(session.getUserId());
});

Expand All @@ -222,6 +238,11 @@ app.post("/startst", async (req, res) => {
if (enableAntiCsrf !== undefined) {
SuperTokensRaw.reset();
SessionRecipeRaw.reset();

if (multitenancySupported) {
MultitenancyRaw.reset();
}

SuperTokens.init(getConfig(enableAntiCsrf, enableJWT));
}
let pid = await startST();
Expand Down
Loading

0 comments on commit 515a8d7

Please sign in to comment.