Skip to content

Commit c5dabc7

Browse files
committed
test: switch to mock provider (#866)
* test: switch most thirdparty test to use mock provider * test: fix test errors
1 parent 41bbaae commit c5dabc7

File tree

11 files changed

+120
-97
lines changed

11 files changed

+120
-97
lines changed

examples/for-tests-react-16/src/App.js

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -270,30 +270,32 @@ if (enabledRecipes.includes("thirdpartypasswordless")) {
270270
if (emailVerificationMode !== "OFF") {
271271
recipeList.push(getEmailVerificationConfigs(testContext));
272272
}
273-
SuperTokens.init({
274-
usesDynamicLoginMethods: testContext.usesDynamicLoginMethods,
275-
clientType: testContext.clientType,
276-
appInfo: {
277-
appName: "SuperTokens",
278-
websiteDomain: getWebsiteDomain(),
279-
apiDomain: getApiDomain(),
280-
websiteBasePath,
281-
},
282-
languageTranslations: {
283-
translations: {
284-
en: {
285-
PWLESS_SIGN_IN_UP_FOOTER_TOS: "TOS",
286-
},
287-
hu: {
288-
PWLESS_SIGN_IN_UP_FOOTER_TOS: "ÁSZF",
273+
if (!window.location.pathname.startsWith("/mockProvider")) {
274+
SuperTokens.init({
275+
usesDynamicLoginMethods: testContext.usesDynamicLoginMethods,
276+
clientType: testContext.clientType,
277+
appInfo: {
278+
appName: "SuperTokens",
279+
websiteDomain: getWebsiteDomain(),
280+
apiDomain: getApiDomain(),
281+
websiteBasePath,
282+
},
283+
languageTranslations: {
284+
translations: {
285+
en: {
286+
PWLESS_SIGN_IN_UP_FOOTER_TOS: "TOS",
287+
},
288+
hu: {
289+
PWLESS_SIGN_IN_UP_FOOTER_TOS: "ÁSZF",
290+
},
289291
},
290292
},
291-
},
292-
getRedirectionURL: (context) => {
293-
console.log(`ST_LOGS SUPERTOKENS GET_REDIRECTION_URL ${context.action}`);
294-
},
295-
recipeList,
296-
});
293+
getRedirectionURL: (context) => {
294+
console.log(`ST_LOGS SUPERTOKENS GET_REDIRECTION_URL ${context.action}`);
295+
},
296+
recipeList,
297+
});
298+
}
297299

298300
/* App */
299301
function App() {

examples/for-tests/src/App.js

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -438,30 +438,32 @@ if (emailVerificationMode !== "OFF") {
438438
recipeList.push(getEmailVerificationConfigs(testContext));
439439
}
440440

441-
SuperTokens.init({
442-
usesDynamicLoginMethods: testContext.usesDynamicLoginMethods,
443-
clientType: testContext.clientType,
444-
appInfo: {
445-
appName: "SuperTokens",
446-
websiteDomain: getWebsiteDomain(),
447-
apiDomain: getApiDomain(),
448-
websiteBasePath,
449-
},
450-
languageTranslations: {
451-
translations: {
452-
en: {
453-
PWLESS_SIGN_IN_UP_FOOTER_TOS: "TOS",
454-
},
455-
hu: {
456-
PWLESS_SIGN_IN_UP_FOOTER_TOS: "ÁSZF",
441+
if (!window.location.pathname.startsWith("/mockProvider")) {
442+
SuperTokens.init({
443+
usesDynamicLoginMethods: testContext.usesDynamicLoginMethods,
444+
clientType: testContext.clientType,
445+
appInfo: {
446+
appName: "SuperTokens",
447+
websiteDomain: getWebsiteDomain(),
448+
apiDomain: getApiDomain(),
449+
websiteBasePath,
450+
},
451+
languageTranslations: {
452+
translations: {
453+
en: {
454+
PWLESS_SIGN_IN_UP_FOOTER_TOS: "TOS",
455+
},
456+
hu: {
457+
PWLESS_SIGN_IN_UP_FOOTER_TOS: "ÁSZF",
458+
},
457459
},
458460
},
459-
},
460-
getRedirectionURL: (context) => {
461-
console.log(`ST_LOGS SUPERTOKENS GET_REDIRECTION_URL ${context.action}`);
462-
},
463-
recipeList,
464-
});
461+
getRedirectionURL: (context) => {
462+
console.log(`ST_LOGS SUPERTOKENS GET_REDIRECTION_URL ${context.action}`);
463+
},
464+
recipeList,
465+
});
466+
}
465467

466468
/* App */
467469
function App() {

test/end-to-end/generalerror.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import {
3737
assertProviders,
3838
clickOnProviderButton,
3939
clickOnProviderButtonWithoutWaiting,
40-
loginWithAuth0,
40+
loginWithMockProvider,
4141
isGeneralErrorSupported,
4242
setGeneralErrorToLocalStorage,
4343
backendBeforeEach,
@@ -412,7 +412,7 @@ function getThirdPartyTests(rid, ridForStorage) {
412412
await assertProviders(page);
413413

414414
let [_, response1] = await Promise.all([
415-
clickOnProviderButtonWithoutWaiting(page, "Auth0"),
415+
clickOnProviderButtonWithoutWaiting(page, "Mock Provider"),
416416
page.waitForResponse(
417417
(response) =>
418418
response.url().includes(GET_AUTH_URL_API) &&
@@ -437,10 +437,10 @@ function getThirdPartyTests(rid, ridForStorage) {
437437

438438
await page.goto(`${TEST_CLIENT_BASE_URL}/auth`);
439439
await assertProviders(page);
440-
await clickOnProviderButton(page, "Auth0");
440+
await clickOnProviderButton(page, "Mock Provider");
441441

442442
let [_, response1] = await Promise.all([
443-
loginWithAuth0(page),
443+
loginWithMockProvider(page),
444444
page.waitForResponse((response) => response.url() === SIGN_IN_UP_API && response.status() === 200),
445445
]);
446446

test/end-to-end/getRedirectionURL.test.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
screenshotOnFailure,
88
assertProviders,
99
clickOnProviderButton,
10-
loginWithAuth0,
10+
loginWithMockProvider,
1111
setPasswordlessFlowType,
1212
waitForSTElement,
1313
getPasswordlessDevice,
@@ -119,9 +119,9 @@ describe("getRedirectionURL Tests", function () {
119119
page.waitForNavigation({ waitUntil: "networkidle0" }),
120120
]);
121121
await assertProviders(page);
122-
await clickOnProviderButton(page, "Auth0");
122+
await clickOnProviderButton(page, "Mock Provider");
123123
await Promise.all([
124-
loginWithAuth0(page),
124+
loginWithMockProvider(page),
125125
page.waitForResponse((response) => response.url() === SIGN_IN_UP_API && response.status() === 200),
126126
]);
127127
const newUserCheck = await page.evaluate(() => localStorage.getItem("isNewUserCheck"));
@@ -178,9 +178,9 @@ describe("getRedirectionURL Tests", function () {
178178

179179
it("Test that isNewRecipeUser works correctly when signing up with auth 0", async function () {
180180
await assertProviders(page);
181-
await clickOnProviderButton(page, "Auth0");
181+
await clickOnProviderButton(page, "Mock Provider");
182182
await Promise.all([
183-
loginWithAuth0(page),
183+
loginWithMockProvider(page),
184184
page.waitForResponse((response) => response.url() === SIGN_IN_UP_API && response.status() === 200),
185185
]);
186186
const newUserCheck = await page.evaluate(() => localStorage.getItem("isNewUserCheck"));
@@ -368,9 +368,9 @@ describe("getRedirectionURL Tests", function () {
368368
page.waitForNavigation({ waitUntil: "networkidle0" }),
369369
]);
370370
await assertProviders(page);
371-
await clickOnProviderButton(page, "Auth0");
371+
await clickOnProviderButton(page, "Mock Provider");
372372
await Promise.all([
373-
loginWithAuth0(page),
373+
loginWithMockProvider(page),
374374
page.waitForResponse((response) => response.url() === SIGN_IN_UP_API && response.status() === 200),
375375
]);
376376
const newUserCheck = await page.evaluate(() => localStorage.getItem("isNewUserCheck"));
@@ -668,10 +668,10 @@ describe("getRedirectionURL Tests", function () {
668668
]);
669669

670670
await assertProviders(page);
671-
await clickOnProviderButton(page, "Auth0");
671+
await clickOnProviderButton(page, "Mock Provider");
672672

673673
await Promise.all([
674-
loginWithAuth0(page),
674+
loginWithMockProvider(page),
675675
page.waitForResponse(
676676
(response) => response.url() === SIGN_IN_UP_API && response.status() === 200
677677
),
@@ -680,7 +680,7 @@ describe("getRedirectionURL Tests", function () {
680680
const urlAfterSignUp = await page.url();
681681
const newUserCheck = await page.evaluate(() => localStorage.getItem("isNewUserCheck"));
682682
assert.equal(newUserCheck, "thirdparty-true");
683-
assert(urlAfterSignUp.includes("/auth/callback/auth0"));
683+
assert(urlAfterSignUp.includes("/auth/callback/mock-provider"));
684684
});
685685
});
686686
});

test/end-to-end/multitenancy.dynamic_login_methods.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,13 @@ import {
3434
loginWithGoogle,
3535
clearBrowserCookiesWithoutAffectingConsole,
3636
clickOnProviderButton,
37-
loginWithAuth0,
37+
loginWithMockProvider,
3838
isMultitenancySupported,
3939
isMultitenancyManagementEndpointsSupported,
4040
setupTenant,
4141
backendBeforeEach,
4242
getTextByDataSupertokens,
43+
loginWithAuth0,
4344
} from "../helpers";
4445
import {
4546
TEST_CLIENT_BASE_URL,

test/end-to-end/thirdparty.test.js

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@ import {
2626
assertNoSTComponents,
2727
generateState,
2828
clickOnProviderButton,
29-
loginWithAuth0,
29+
loginWithMockProvider,
3030
getGeneralError,
3131
waitFor,
3232
screenshotOnFailure,
3333
clickOnProviderButtonWithoutWaiting,
3434
backendBeforeEach,
35+
loginWithAuth0,
3536
} from "../helpers";
3637

3738
import { TEST_CLIENT_BASE_URL, TEST_SERVER_BASE_URL, SIGN_IN_UP_API, GET_AUTH_URL_API } from "../constants";
@@ -136,37 +137,37 @@ export function getThirdPartyTestCases({ authRecipe, rid, logId, signInUpPageLoa
136137
]);
137138
});
138139

139-
it("Successful sign in with Auth0 with redirectToPath (w/ leading slash) keeping query params", async function () {
140+
it("Successful sign in with redirectToPath (w/ leading slash) keeping query params", async function () {
140141
await Promise.all([
141142
page.goto(`${TEST_CLIENT_BASE_URL}/auth?redirectToPath=%2Fredirect-here%3Ffoo%3Dbar`),
142143
page.waitForNavigation({ waitUntil: "networkidle0" }),
143144
]);
144145
await assertProviders(page);
145-
await clickOnProviderButton(page, "Auth0");
146+
await clickOnProviderButton(page, "Mock Provider");
146147
await Promise.all([
147-
loginWithAuth0(page),
148+
loginWithMockProvider(page),
148149
page.waitForResponse((response) => response.url() === SIGN_IN_UP_API && response.status() === 200),
149150
]);
150151
const { pathname, search } = await page.evaluate(() => window.location);
151152
assert.deepStrictEqual(pathname + search, "/redirect-here?foo=bar");
152153
});
153154

154-
it("Successful sign in with Auth0 with redirectToPath (w/o leading slash) keeping query params", async function () {
155+
it("Successful sign in with SSO with redirectToPath (w/o leading slash) keeping query params", async function () {
155156
await Promise.all([
156157
page.goto(`${TEST_CLIENT_BASE_URL}/auth?redirectToPath=%3Ffoo%3Dbar`),
157158
page.waitForNavigation({ waitUntil: "networkidle0" }),
158159
]);
159160
await assertProviders(page);
160-
await clickOnProviderButton(page, "Auth0");
161+
await clickOnProviderButton(page, "Mock Provider");
161162
await Promise.all([
162-
loginWithAuth0(page),
163+
loginWithMockProvider(page),
163164
page.waitForResponse((response) => response.url() === SIGN_IN_UP_API && response.status() === 200),
164165
]);
165166
const { pathname, search } = await page.evaluate(() => window.location);
166167
assert.deepStrictEqual(pathname + search, "/?foo=bar");
167168
});
168169

169-
it("Successful sign in with Auth0 with redirectToPath (query params + fragment)", async function () {
170+
it("Successful sign in with SSO with redirectToPath (query params + fragment)", async function () {
170171
await Promise.all([
171172
page.goto(
172173
`${TEST_CLIENT_BASE_URL}/auth?redirectToPath=${encodeURIComponent(
@@ -176,39 +177,39 @@ export function getThirdPartyTestCases({ authRecipe, rid, logId, signInUpPageLoa
176177
page.waitForNavigation({ waitUntil: "networkidle0" }),
177178
]);
178179
await assertProviders(page);
179-
await clickOnProviderButton(page, "Auth0");
180+
await clickOnProviderButton(page, "Mock Provider");
180181
await Promise.all([
181-
loginWithAuth0(page),
182+
loginWithMockProvider(page),
182183
page.waitForResponse((response) => response.url() === SIGN_IN_UP_API && response.status() === 200),
183184
]);
184185
const { pathname, search, hash } = await page.evaluate(() => window.location);
185186
assert.deepStrictEqual(pathname + search + hash, "/redirect-here?foo=bar#cell=4,1-6,2");
186187
});
187188

188-
it("Successful sign in with Auth0 with redirectToPath (only fragment)", async function () {
189+
it("Successful sign in with SSO with redirectToPath (only fragment)", async function () {
189190
await Promise.all([
190191
page.goto(`${TEST_CLIENT_BASE_URL}/auth?redirectToPath=${encodeURIComponent("#cell=4,1-6,2")}`),
191192
page.waitForNavigation({ waitUntil: "networkidle0" }),
192193
]);
193194
await assertProviders(page);
194-
await clickOnProviderButton(page, "Auth0");
195+
await clickOnProviderButton(page, "Mock Provider");
195196
await Promise.all([
196-
loginWithAuth0(page),
197+
loginWithMockProvider(page),
197198
page.waitForResponse((response) => response.url() === SIGN_IN_UP_API && response.status() === 200),
198199
]);
199200
const { pathname, search, hash } = await page.evaluate(() => window.location);
200201
assert.deepStrictEqual(pathname + search + hash, "/#cell=4,1-6,2");
201202
});
202203

203-
it("Successful signin with Auth0 and email verification", async function () {
204+
it("Successful signin with SSO and email verification", async function () {
204205
await Promise.all([
205206
page.goto(`${TEST_CLIENT_BASE_URL}/auth?mode=REQUIRED`),
206207
page.waitForNavigation({ waitUntil: "networkidle0" }),
207208
]);
208209
await assertProviders(page);
209-
await clickOnProviderButton(page, "Auth0");
210+
await clickOnProviderButton(page, "Mock Provider");
210211
await Promise.all([
211-
loginWithAuth0(page),
212+
loginWithMockProvider(page),
212213
page.waitForResponse((response) => response.url() === SIGN_IN_UP_API && response.status() === 200),
213214
]);
214215
const pathname = await page.evaluate(() => window.location.pathname);
@@ -241,30 +242,30 @@ export function getThirdPartyTestCases({ authRecipe, rid, logId, signInUpPageLoa
241242
]);
242243
});
243244

244-
it("Successful signin with auth0 and redirectToPath", async function () {
245+
it("Successful signin with SSO and redirectToPath", async function () {
245246
await Promise.all([
246247
page.goto(`${TEST_CLIENT_BASE_URL}/auth?redirectToPath=/hello`),
247248
page.waitForNavigation({ waitUntil: "networkidle0" }),
248249
]);
249250
await assertProviders(page);
250-
await clickOnProviderButton(page, "Auth0");
251+
await clickOnProviderButton(page, "Mock Provider");
251252
await Promise.all([
252-
loginWithAuth0(page),
253+
loginWithMockProvider(page),
253254
page.waitForResponse((response) => response.url() === SIGN_IN_UP_API && response.status() === 200),
254255
]);
255256
const pathname = await page.evaluate(() => window.location.pathname);
256257
assert.deepStrictEqual(pathname, "/hello");
257258
});
258259

259-
it("Successful signin with auth0 and redirectToPath case sensitive", async function () {
260+
it("Successful signin with SSO and redirectToPath case sensitive", async function () {
260261
await Promise.all([
261262
page.goto(`${TEST_CLIENT_BASE_URL}/auth?redirectToPath=%2FCasE%2FCase-SensItive1-PAth`),
262263
page.waitForNavigation({ waitUntil: "networkidle0" }),
263264
]);
264265
await assertProviders(page);
265-
await clickOnProviderButton(page, "Auth0");
266+
await clickOnProviderButton(page, "Mock Provider");
266267
await Promise.all([
267-
loginWithAuth0(page),
268+
loginWithMockProvider(page),
268269
page.waitForResponse((response) => response.url() === SIGN_IN_UP_API && response.status() === 200),
269270
]);
270271
const pathname = await page.evaluate(() => window.location.pathname);
@@ -359,8 +360,8 @@ export function getThirdPartyTestCases({ authRecipe, rid, logId, signInUpPageLoa
359360
}
360361
};
361362
page.on("request", requestHandler);
362-
await clickOnProviderButton(page, "Auth0");
363-
await loginWithAuth0(page);
363+
await clickOnProviderButton(page, "Mock Provider");
364+
await loginWithMockProvider(page);
364365
const error = await getGeneralError(page);
365366
assert.deepStrictEqual(error, "Terms of Service");
366367
});
@@ -395,8 +396,8 @@ export function getThirdPartyTestCases({ authRecipe, rid, logId, signInUpPageLoa
395396
};
396397
page.on("request", requestHandler);
397398

398-
await clickOnProviderButton(page, "Auth0");
399-
await loginWithAuth0(page);
399+
await clickOnProviderButton(page, "Mock Provider");
400+
await loginWithMockProvider(page);
400401

401402
const error = await getGeneralError(page);
402403
assert.deepStrictEqual(error, "Test message!!!!");

0 commit comments

Comments
 (0)