Skip to content

Commit

Permalink
test: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
porcellus committed Sep 14, 2023
1 parent e365725 commit 501ead5
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 9 deletions.
9 changes: 5 additions & 4 deletions test/end-to-end/multitenancy.tenant_interactions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -689,8 +689,7 @@ describe("SuperTokens Multitenancy tenant interactions", function () {
}
});

it.skip("should revoke magic links on removed tenants", async function () {
// TODO: validate that this should pass
it("should revoke magic links on removed tenants", async function () {
await setPasswordlessFlowType("EMAIL_OR_PHONE", "USER_INPUT_CODE_AND_MAGIC_LINK");
await setEnabledRecipes(page, ["passwordless"]);
await setupTenant("customer1", {
Expand Down Expand Up @@ -723,10 +722,12 @@ describe("SuperTokens Multitenancy tenant interactions", function () {
await removeTenant("customer1");
await setTenantId(page, "public");

await page.goto(device.codes[0].urlWithLinkCode);
await Promise.all([
page.goto(device.codes[0].urlWithLinkCode),
page.waitForNavigation({ waitUntil: "networkidle0" }),
]);

assert.strictEqual(await getGeneralError(page), SOMETHING_WENT_WRONG_ERROR);
await waitForSTElement(page, "[data-supertokens~=input][name=emailOrPhone]");
});
});

Expand Down
81 changes: 76 additions & 5 deletions test/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -877,14 +877,22 @@ export async function getTestEmail() {
return `john.doe+${Date.now()}@supertokens.io`;
}

export async function setupTenant(tenantId, mockLoginMethods) {
export async function setupTenant(tenantId, loginMethods) {
const body = {
tenantId,
loginMethods,
};
if (loginMethods.thirdParty?.providers) {
body.loginMethods.thirdParty.providers = loginMethods.thirdParty.providers.map((provider) => ({
...testProviderConfigs[provider.id.split("-")[0]],
thirdPartyId: provider.id,
name: provider.name,
}));
}
let coreResp = await fetch(`${TEST_APPLICATION_SERVER_BASE_URL}/setupTenant`, {
method: "POST",
headers: new Headers([["content-type", "application/json"]]),
body: JSON.stringify({
tenantId,
mockLoginMethods,
}),
body: JSON.stringify(body),
});
assert.strictEqual(coreResp.status, 200);
}
Expand Down Expand Up @@ -923,3 +931,66 @@ export async function removeTenant(tenantId) {
});
assert.strictEqual(coreResp.status, 200);
}

const testProviderConfigs = {
apple: {
clients: [
{
clientId: "4398792-io.supertokens.example.service",
additionalConfig: {
keyId: "7M48Y4RYDL",
privateKey:
"-----BEGIN PRIVATE KEY-----\nMIGTAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBHkwdwIBAQQgu8gXs+XYkqXD6Ala9Sf/iJXzhbwcoG5dMh1OonpdJUmgCgYIKoZIzj0DAQehRANCAASfrvlFbFCYqn3I2zeknYXLwtH30JuOKestDbSfZYxZNMqhF/OzdZFTV0zc5u5s3eN+oCWbnvl0hM+9IW0UlkdA\n-----END PRIVATE KEY-----",
teamId: "YWQCXGJRJL",
},
},
],
},
github: {
clients: [
{
clientSecret: "e97051221f4b6426e8fe8d51486396703012f5bd",
clientId: "467101b197249757c71f",
},
],
},
google: {
clients: [
{
clientId: "1060725074195-kmeum4crr01uirfl2op9kd5acmi9jutn.apps.googleusercontent.com",
clientSecret: "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",
},
],
},
auth0: {
// this contains info about forming the authorisation redirect URL without the state params and without the redirect_uri param
authorizationEndpoint: `https://${process.env.AUTH0_DOMAIN}/authorize`,
authorizationEndpointQueryParams: {
scope: "openid profile email email_verified",
},
jwksURI: `https://${process.env.AUTH0_DOMAIN}/.well-known/jwks.json`,
tokenEndpoint: `https://${process.env.AUTH0_DOMAIN}/oauth/token`,
clients: [
{
clientId: process.env.AUTH0_CLIENT_ID,
clientSecret: process.env.AUTH0_CLIENT_SECRET,
},
],
userInfoMap: {
fromIdTokenPayload: {
userId: "sub",
email: "email",
emailVerified: "email_verified",
},
},
},
test: {
// We add a client since it's required
clients: [
{
clientId: "1060725074195-kmeum4crr01uirfl2op9kd5acmi9jutn.apps.googleusercontent.com",
clientSecret: "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",
},
],
},
};

0 comments on commit 501ead5

Please sign in to comment.