Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Cicd fixes #682

Merged
merged 1 commit into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions test/auth-react-server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,14 @@ app.get("/sessioninfo", verifySession(), async (req, res) => {
}
});

app.post("/deleteUser", async (req, res) => {
if (req.body.rid !== "emailpassword") {
res.status(400).send({ message: "Not implemented" });
}
const user = await EmailPassword.getUserByEmail(req.body.email);
res.send(await SuperTokens.deleteUser(user.id));
});

app.get("/unverifyEmail", verifySession(), async (req, res) => {
let session = req.session;
await EmailVerification.unverifyEmail(session.getUserId());
Expand Down
36 changes: 36 additions & 0 deletions test/frontendIntegration/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ let noOfTimesRefreshAttemptedDuringTest = 0;
let { verifySession } = require("../../recipe/session/framework/express");
let { middleware, errorHandler } = require("../../framework/express");
let supertokens_node_version = require("../../lib/build/version").version;
const { Querier } = require("../../lib/build/querier");

let urlencodedParser = bodyParser.urlencoded({ limit: "20mb", extended: true, parameterLimit: 20000 });
let jsonParser = bodyParser.json({ limit: "20mb" });
Expand Down Expand Up @@ -223,6 +224,41 @@ app.post("/login", async (req, res) => {
res.send(session.getUserId());
});

app.post("/login-2.18", async (req, res) => {
// This CDI version is no longer supported by this SDK, but we want to ensure that sessions keep working after the upgrade
// We can hard-code the structure of the request&response, since this is a fixed CDI version and it's not going to change
Querier.apiVersion = "2.18";
const payload = req.body.payload || {};
const userId = req.body.userId;
const legacySessionResp = await Querier.getNewInstanceOrThrowError().sendPostRequest(
new NormalisedURLPath("/recipe/session"),
{
userId,
enableAntiCsrf: false,
userDataInJWT: payload,
userDataInDatabase: {},
}
);
Querier.apiVersion = undefined;

const legacyAccessToken = legacySessionResp.accessToken.token;
const legacyRefreshToken = legacySessionResp.refreshToken.token;

res.set("st-access-token", legacyAccessToken)
.set("st-refresh-token", legacyRefreshToken)
.set(
"front-token",
Buffer.from(
JSON.stringify({
uid: userId,
ate: Date.now() + 3600000,
up: payload,
})
).toString("base64")
)
.send();
});

app.post("/beforeeach", async (req, res) => {
noOfTimesRefreshCalledDuringTest = 0;
noOfTimesGetSessionCalledDuringTest = 0;
Expand Down
Loading