Skip to content

Commit

Permalink
test: ci/cd fixing (#77)
Browse files Browse the repository at this point in the history
* ci: test fixing

* ci: test fixing

* ci: test fixing
  • Loading branch information
porcellus authored Jul 27, 2024
1 parent cd7d72c commit 2f385b4
Show file tree
Hide file tree
Showing 6 changed files with 472 additions and 187 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ workflows:
tags:
only: /dev-v[0-9]+(\.[0-9]+)*/
branches:
ignore: /.*/
only: /test-cicd\/.*/
- update-docs:
context:
- slack-notification
Expand Down
21 changes: 16 additions & 5 deletions .circleci/config_continue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,17 @@ jobs:
docker:
- image: rishabhpoddar/supertokens_website_sdk_testing_node_16
steps:
- run: git config --global url."https://github.com/".insteadOf ssh://[email protected]/ # This makes npm use http instead of ssh (required for node 16)
- checkout
- run: (cd .circleci/ && ./markDevTagAsTestNotPassed.sh)
- run: echo "Testing branch << pipeline.git.branch >>"
- when:
condition:
not:
matches:
pattern: "^test-cicd/.*$"
value: << pipeline.git.branch >>
steps:
- run: git config --global url."https://github.com/".insteadOf ssh://[email protected]/ # This makes npm use http instead of ssh (required for node 16)
- checkout
- run: (cd .circleci/ && ./markDevTagAsTestNotPassed.sh)
test-unit:
docker:
- image: rishabhpoddar/supertokens_android_sdk_testing
Expand Down Expand Up @@ -51,6 +59,9 @@ jobs:
echo 'export NVM_DIR="$HOME/.nvm"' >> $BASH_ENV
echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> $BASH_ENV
- run: (cd .circleci/ && ./doTests.sh << parameters.fdi-version >>)
- store_artifacts:
path: ../supertokens-root/logs
destination: logfiles
test-success:
docker:
- image: rishabhpoddar/supertokens_website_sdk_testing_node_16
Expand All @@ -69,7 +80,7 @@ workflows:
tags:
only: /dev-v[0-9]+(\.[0-9]+)*/
branches:
ignore: /.*/
only: /test-cicd\/.*/
- test-unit:
requires:
- test-dev-tag-as-not-passed
Expand All @@ -79,7 +90,7 @@ workflows:
tags:
only: /dev-v[0-9]+(\.[0-9]+)*/
branches:
ignore: /.*/
only: /test-cicd\/.*/
matrix:
parameters:
fdi-version: placeholder
Expand Down
26 changes: 16 additions & 10 deletions testHelpers/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ let { startST, stopST, killAllST, setupST, cleanST, setKeyValueInConfig, maxVers
let { middleware, errorHandler } = require("supertokens-node/framework/express");
let { verifySession } = require("supertokens-node/recipe/session/framework/express");
const { spawnSync } = require("child_process");
const morgan = require("morgan");
let noOfTimesRefreshCalledDuringTest = 0;
let noOfTimesGetSessionCalledDuringTest = 0;
let noOfTimesRefreshAttemptedDuringTest = 0;
Expand All @@ -35,9 +36,10 @@ let NormalisedURLPath = require("supertokens-node/lib/build/normalisedURLPath").
let Multitenancy, MultitenancyRaw, multitenancySupported;
try {
MultitenancyRaw = require("supertokens-node/lib/build/recipe/multitenancy/recipe").default;
Multitenancy = require("supertokens-node/lib/build/recipe/multitenancy");
Multitenancy = require("supertokens-node/lib/build/recipe/multitenancy/index");
multitenancySupported = true;
} catch {
} catch (ex) {
console.log({ex});
multitenancySupported = false;
}

Expand All @@ -55,6 +57,8 @@ let app = express();
app.use(urlencodedParser);
app.use(jsonParser);
app.use(cookieParser());
app.use(morgan(`:date[iso] - :method :url`, { immediate: true }));
app.use(morgan(`:date[iso] - :method :url :status :response-time ms - :res[content-length]`));

let lastSetEnableAntiCSRF = false;
let lastSetEnableJWT = false;
Expand Down Expand Up @@ -151,10 +155,10 @@ function getConfig(enableAntiCsrf, enableJWT, jwtPropertyName) {
refreshPOST: undefined
};
},
functions: function(oI) {
functions: function (oI) {
return {
...oI,
createNewSession: async function({ res, userId, accessTokenPayload, sessionData }) {
createNewSession: async function ({ res, userId, accessTokenPayload, sessionData }) {
accessTokenPayload = {
...accessTokenPayload,
customClaim: "customValue"
Expand Down Expand Up @@ -211,6 +215,7 @@ app.use(
credentials: true
})
);
app.disable('etag');

app.use(middleware());

Expand Down Expand Up @@ -255,8 +260,8 @@ app.post("/startst", async (req, res) => {

SuperTokens.init(getConfig(enableAntiCsrf, enableJWT));
}
let pid = await startST();
res.send(pid + "");
await startST();
res.send("");
});

app.get("/featureFlags", async (req, res) => {
Expand Down Expand Up @@ -509,7 +514,7 @@ app.get("/testError", (req, res) => {

app.get("/throw-401", (req, res) => {
res.status(401).send("Unauthorised");
})
});

app.get("/stop", async (req, res) => {
process.exit();
Expand Down Expand Up @@ -570,9 +575,9 @@ app.post("/logout-alt", async (req, res) => {
app.get("/base-custom-auth", async (req, res) => {
let header = req.headers["authorization"];
if (header === "Bearer myOwnHeHe") {
return res.status(200).json({message: "OK"});
return res.status(200).json({ message: "OK" });
} else {
return res.status(500).json({message: "Bad auth header"});
return res.status(500).json({ message: "Bad auth header" });
}
})

Expand All @@ -583,7 +588,8 @@ app.use("*", async (req, res, next) => {
app.use(errorHandler());

app.use(async (err, req, res, next) => {
res.send(500).send(err);
console.log({err, stack: new Error().stack });
res.status(500).send(err);
});

let server = http.createServer(app);
Expand Down
Loading

0 comments on commit 2f385b4

Please sign in to comment.