Skip to content

Commit

Permalink
test: stability fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
porcellus committed Sep 26, 2024
1 parent 7b68081 commit d02c522
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
9 changes: 9 additions & 0 deletions test/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,15 @@ export async function isMFASupported() {
return true;
}

export async function isOauth2Supported() {
const features = await getFeatureFlags();
if (!features.includes("oauth2")) {
return false;
}

return true;
}

/**
* For example setGeneralErrorToLocalStorage("EMAIL_PASSWORD", "EMAIL_PASSWORD_SIGN_UP", page) to
* set for signUp in email password
Expand Down
29 changes: 22 additions & 7 deletions test/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,14 @@ const MultiFactorAuth = require("supertokens-node/recipe/multifactorauth");
const TOTPRaw = require("supertokens-node/lib/build/recipe/totp/recipe").default;
const TOTP = require("supertokens-node/recipe/totp");

const OAuth2ProviderRaw = require("supertokens-node/lib/build/recipe/oauth2provider/recipe").default;
const OAuth2Provider = require("supertokens-node/recipe/oauth2provider");
let OAuth2ProviderRaw = undefined;
let OAuth2Provider = undefined;
try {
OAuth2ProviderRaw = require("supertokens-node/lib/build/recipe/oauth2provider/recipe").default;
OAuth2Provider = require("supertokens-node/recipe/oauth2provider");
} catch {
// OAuth2Provider is not supported by the tested version of the node SDK
}

const OTPAuth = require("otpauth");

Expand Down Expand Up @@ -498,15 +504,20 @@ app.get("/test/featureFlags", (req, res) => {
available.push("accountlinking");
available.push("mfa");
available.push("recipeConfig");
available.push("oauth2");

res.send({
available,
});
});

app.post("/test/create-oauth2-client", async (req, res) => {
const { client } = await OAuth2Provider.createOAuth2Client(req.body);
res.send({ client });
app.post("/test/create-oauth2-client", async (req, res, next) => {
try {
const { client } = await OAuth2Provider.createOAuth2Client(req.body);
res.send({ client });
} catch (e) {
next(e);
}
});

app.use(errorHandler());
Expand Down Expand Up @@ -552,7 +563,9 @@ function initST() {
UserMetadataRaw.reset();
MultiFactorAuthRaw.reset();
TOTPRaw.reset();
OAuth2ProviderRaw.reset();
if (OAuth2ProviderRaw) {
OAuth2ProviderRaw.reset();
}

EmailVerificationRaw.reset();
EmailPasswordRaw.reset();
Expand Down Expand Up @@ -751,8 +764,10 @@ function initST() {
},
}),
],
["oauth2provider", OAuth2Provider.init()],
];
if (OAuth2Provider) {
recipeList.push(["oauth2provider", OAuth2Provider.init()]);
}

passwordlessConfig = {
contactMethod: "EMAIL_OR_PHONE",
Expand Down

0 comments on commit d02c522

Please sign in to comment.