mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-11-10 15:59:57 +00:00
test: migrate login config to playwright (#17740)
(cherry picked from commit 59d2b1e717f167ed7c860058062c3d0bc60c61b4)
This commit is contained in:
parent
8ebdd7ae01
commit
83079606e4
@ -1,59 +0,0 @@
|
|||||||
import { GlobalSettingOptions } from '../../constants/settings.constant';
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright 2023 Collate.
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
describe('Login configuration', { tags: 'Settings' }, () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
cy.login();
|
|
||||||
|
|
||||||
cy.settingClick(GlobalSettingOptions.LOGIN_CONFIGURATION);
|
|
||||||
});
|
|
||||||
|
|
||||||
/* ==== Test Created with Cypress Studio ==== */
|
|
||||||
it('update login configuration should work', function () {
|
|
||||||
/* ==== Generated with Cypress Studio ==== */
|
|
||||||
cy.get('[data-testid="edit-button"]').click();
|
|
||||||
cy.get('[data-testid="jwtTokenExpiryTime"]').clear('3600');
|
|
||||||
cy.get('[data-testid="jwtTokenExpiryTime"]').type('5000');
|
|
||||||
cy.get('[data-testid="accessBlockTime"]').clear('600');
|
|
||||||
cy.get('[data-testid="accessBlockTime"]').type('500');
|
|
||||||
cy.get('[data-testid="maxLoginFailAttempts"]').clear('3');
|
|
||||||
cy.get('[data-testid="maxLoginFailAttempts"]').type('5');
|
|
||||||
cy.get('[data-testid="save-button"] > span').click();
|
|
||||||
cy.get('[data-testid="max-login-fail-attampts"]').should('have.text', '5');
|
|
||||||
cy.get('[data-testid="access-block-time"]').should('have.text', '500');
|
|
||||||
cy.get('[data-testid="jwt-token-expiry-time"]').should(
|
|
||||||
'have.text',
|
|
||||||
'5000 Seconds'
|
|
||||||
);
|
|
||||||
/* ==== End Cypress Studio ==== */
|
|
||||||
});
|
|
||||||
|
|
||||||
/* ==== Test Created with Cypress Studio ==== */
|
|
||||||
it('reset login configuration', function () {
|
|
||||||
/* ==== Generated with Cypress Studio ==== */
|
|
||||||
cy.get('[data-testid="edit-button"] > :nth-child(2)').click();
|
|
||||||
cy.get('[data-testid="maxLoginFailAttempts"]').clear('53');
|
|
||||||
cy.get('[data-testid="maxLoginFailAttempts"]').type('3');
|
|
||||||
cy.get('[data-testid="accessBlockTime"]').clear('500');
|
|
||||||
cy.get('[data-testid="accessBlockTime"]').type('300');
|
|
||||||
cy.get('[data-testid="jwtTokenExpiryTime"]').clear('5000');
|
|
||||||
cy.get('[data-testid="jwtTokenExpiryTime"]').type('3600');
|
|
||||||
cy.get('[data-testid="save-button"]').click();
|
|
||||||
cy.get('.Toastify__toast-body > :nth-child(2)').should(
|
|
||||||
'have.text',
|
|
||||||
'Login Configuration updated successfully.'
|
|
||||||
);
|
|
||||||
/* ==== End Cypress Studio ==== */
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@ -0,0 +1,84 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2024 Collate.
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
import { expect, test } from '@playwright/test';
|
||||||
|
import { GlobalSettingOptions } from '../../constant/settings';
|
||||||
|
import { redirectToHomePage, toastNotification } from '../../utils/common';
|
||||||
|
import { settingClick } from '../../utils/sidebar';
|
||||||
|
|
||||||
|
// use the admin user to login
|
||||||
|
test.use({ storageState: 'playwright/.auth/admin.json' });
|
||||||
|
|
||||||
|
test.describe('Login configuration', () => {
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
|
await redirectToHomePage(page);
|
||||||
|
await settingClick(page, GlobalSettingOptions.LOGIN_CONFIGURATION);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('update login configuration should work', async ({ page }) => {
|
||||||
|
// Click the edit button
|
||||||
|
await page.click('[data-testid="edit-button"]');
|
||||||
|
|
||||||
|
// Update JWT Token Expiry Time
|
||||||
|
await page.fill('[data-testid="jwtTokenExpiryTime"]', '5000');
|
||||||
|
|
||||||
|
// Update Access Block Time
|
||||||
|
await page.fill('[data-testid="accessBlockTime"]', '500');
|
||||||
|
|
||||||
|
// Update Max Login Fail Attempts
|
||||||
|
await page.fill('[data-testid="maxLoginFailAttempts"]', '5');
|
||||||
|
|
||||||
|
// Click the save button
|
||||||
|
await page.click('[data-testid="save-button"]');
|
||||||
|
|
||||||
|
// Assert the updated values
|
||||||
|
await expect(
|
||||||
|
page.locator('[data-testid="max-login-fail-attampts"]')
|
||||||
|
).toHaveText('5');
|
||||||
|
await expect(page.locator('[data-testid="access-block-time"]')).toHaveText(
|
||||||
|
'500'
|
||||||
|
);
|
||||||
|
await expect(
|
||||||
|
page.locator('[data-testid="jwt-token-expiry-time"]')
|
||||||
|
).toHaveText('5000 Seconds');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('reset login configuration should work', async ({ page }) => {
|
||||||
|
// Click the edit button
|
||||||
|
await page.click('[data-testid="edit-button"]');
|
||||||
|
|
||||||
|
// Reset JWT Token Expiry Time
|
||||||
|
await page.fill('[data-testid="jwtTokenExpiryTime"]', '3600');
|
||||||
|
|
||||||
|
// Reset Access Block Time
|
||||||
|
await page.fill('[data-testid="accessBlockTime"]', '600');
|
||||||
|
|
||||||
|
// Reset Max Login Fail Attempts
|
||||||
|
await page.fill('[data-testid="maxLoginFailAttempts"]', '3');
|
||||||
|
|
||||||
|
// Click the save button
|
||||||
|
await page.click('[data-testid="save-button"]');
|
||||||
|
|
||||||
|
await toastNotification(page, 'Login Configuration updated successfully.');
|
||||||
|
|
||||||
|
// Assert the updated values
|
||||||
|
await expect(
|
||||||
|
page.locator('[data-testid="max-login-fail-attampts"]')
|
||||||
|
).toHaveText('3');
|
||||||
|
await expect(page.locator('[data-testid="access-block-time"]')).toHaveText(
|
||||||
|
'600'
|
||||||
|
);
|
||||||
|
await expect(
|
||||||
|
page.locator('[data-testid="jwt-token-expiry-time"]')
|
||||||
|
).toHaveText('3600 Seconds');
|
||||||
|
});
|
||||||
|
});
|
||||||
Loading…
x
Reference in New Issue
Block a user