Test case for wrong redirect url

This commit is contained in:
Aswin V 2024-04-30 17:55:37 +05:30
parent 279563bf16
commit 04731b2c66
1 changed files with 30 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import { Portal, SSOPage } from 'e2e/support/fixtures';
type MyFixtures = {
ssoPage: SSOPage;
portal: Portal;
ssoPageWithoutDelete: SSOPage;
};
export const test = baseTest.extend<MyFixtures>({
@ -19,6 +20,13 @@ export const test = baseTest.extend<MyFixtures>({
const portal = new Portal(page);
await use(portal);
},
ssoPageWithoutDelete: async ({ page, baseURL }, use, testInfo) => {
const ssoPage = new SSOPage(page);
const ssoName = `saml-${testInfo.workerIndex}`;
await ssoPage.goto();
await ssoPage.addSSOConnection({ name: ssoName, type: 'saml', baseURL: baseURL! });
await use(ssoPage);
},
});
test('OAuth2 wrapper + SAML provider', async ({ ssoPage, portal, page, baseURL }, testInfo) => {
@ -35,6 +43,28 @@ test('OAuth2 wrapper + SAML provider', async ({ ssoPage, portal, page, baseURL }
await portal.isLoggedIn();
});
test('OAuth2 wrapper + SAML provider + wrong redirectUrl', async ({
ssoPageWithoutDelete,
page,
baseURL,
}, testInfo) => {
// check if the first added connection appears in the connection list
await expect(page.getByText(`saml-${testInfo.workerIndex}-1`)).toBeVisible();
await ssoPageWithoutDelete.updateSSOConnection({
name: `saml-${testInfo.workerIndex}-1`,
url: 'https://invalid-url.com',
});
// Logout of magic link login
await ssoPageWithoutDelete.logout();
await ssoPageWithoutDelete.signInWithSSO();
// // Login using MockSAML
// await ssoPage.signInWithMockSAML();
// Wait for browser to redirect to error page
await page.waitForURL((url) => url.origin === baseURL && url.pathname === '/error');
// Assert error text
await expect(page.getByText(`SSO error: Redirect URL is not allowed.`)).toBeVisible();
});
test('OAuth2 wrapper + 2 SAML providers', async ({ ssoPage, portal, page, baseURL }, testInfo) => {
const ssoName = `saml-${testInfo.workerIndex}`;
// check if the first added connection appears in the connection list