diff --git a/openmetadata-ui/src/main/resources/ui/cypress/common/Utils/Login.ts b/openmetadata-ui/src/main/resources/ui/cypress/common/Utils/Login.ts index 44112e5ef53..61852490125 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/common/Utils/Login.ts +++ b/openmetadata-ui/src/main/resources/ui/cypress/common/Utils/Login.ts @@ -11,6 +11,7 @@ * limitations under the License. */ import { interceptURL } from '../common'; +import { getToken } from './LocalStorage'; /** * Try Performing login with the given username and password. @@ -46,3 +47,25 @@ export const performLogin = (username, password) => { cy.get('.ant-btn').contains('Login').should('be.visible').click(); cy.wait('@loginUser'); }; + +export const updateJWTTokenExpiryTime = (expiryTime: number) => { + cy.getAllLocalStorage().then((data) => { + const token = getToken(data); + + cy.request({ + method: 'PUT', + url: `/api/v1/system/settings`, + headers: { Authorization: `Bearer ${token}` }, + body: { + config_type: 'loginConfiguration', + config_value: { + maxLoginFailAttempts: 3, + accessBlockTime: 600, + jwtTokenExpiryTime: expiryTime, + }, + }, + }).then((response) => { + expect(response.status).to.eq(200); + }); + }); +}; diff --git a/openmetadata-ui/src/main/resources/ui/cypress/constants/constants.ts b/openmetadata-ui/src/main/resources/ui/cypress/constants/constants.ts index 1a87b37bfbe..1547f6cbc9f 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/constants/constants.ts +++ b/openmetadata-ui/src/main/resources/ui/cypress/constants/constants.ts @@ -831,3 +831,8 @@ export const ID: Record< api: '/api/v1/services/storageServices?*', }, }; + +export const JWT_EXPIRY_TIME_MAP = { + '1 hour': 3600, + '2 hours': 7200, +}; diff --git a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Customproperties.spec.ts b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Customproperties.spec.ts index 961f4069ddd..effc8fd6f7e 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Customproperties.spec.ts +++ b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Customproperties.spec.ts @@ -37,7 +37,8 @@ import { visitEntityDetailsPage, } from '../../common/Utils/Entity'; import { getToken } from '../../common/Utils/LocalStorage'; -import { ENTITIES, uuid } from '../../constants/constants'; +import { updateJWTTokenExpiryTime } from '../../common/Utils/Login'; +import { ENTITIES, JWT_EXPIRY_TIME_MAP, uuid } from '../../constants/constants'; import { EntityType, SidebarItem } from '../../constants/Entity.interface'; import { DATABASE_SERVICE } from '../../constants/EntityConstant'; import { GLOSSARY_1 } from '../../constants/glossary.constant'; @@ -75,6 +76,15 @@ const customPropertyValue = { }; describe('Custom Properties should work properly', { tags: 'Settings' }, () => { + before(() => { + cy.login(); + updateJWTTokenExpiryTime(JWT_EXPIRY_TIME_MAP['2 hours']); + }); + + after(() => { + updateJWTTokenExpiryTime(JWT_EXPIRY_TIME_MAP['1 hour']); + }); + beforeEach(() => { cy.login(); }); diff --git a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Database.spec.ts b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Database.spec.ts index e0835903224..8558e52c91c 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Database.spec.ts +++ b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Database.spec.ts @@ -13,6 +13,8 @@ import EntityClass from '../../common/Entities/EntityClass'; import { CustomPropertyTypeByName } from '../../common/Utils/CustomProperty'; +import { updateJWTTokenExpiryTime } from '../../common/Utils/Login'; +import { JWT_EXPIRY_TIME_MAP } from '../../constants/constants'; import DatabaseClass from './../../common/Entities/DatabaseClass'; import DatabaseSchemaClass from './../../common/Entities/DatabaseSchemaClass'; import StoreProcedureClass from './../../common/Entities/StoredProcedureClass'; @@ -35,12 +37,14 @@ describe('Database hierarchy details page', { tags: 'DataAssets' }, () => { before(() => { cy.login(); + updateJWTTokenExpiryTime(JWT_EXPIRY_TIME_MAP['2 hours']); EntityClass.preRequisitesForTests(); }); after(() => { cy.login(); + updateJWTTokenExpiryTime(JWT_EXPIRY_TIME_MAP['1 hour']); EntityClass.postRequisitesForTests(); }); diff --git a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Entity.spec.ts b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Entity.spec.ts index 871e2ed3237..61f40202a38 100644 --- a/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Entity.spec.ts +++ b/openmetadata-ui/src/main/resources/ui/cypress/e2e/Pages/Entity.spec.ts @@ -18,6 +18,8 @@ import MlModelClass from '../../common/Entities/MlModelClass'; import PipelineClass from '../../common/Entities/PipelineClass'; import SearchIndexClass from '../../common/Entities/SearchIndexClass'; import TopicClass from '../../common/Entities/TopicClass'; +import { updateJWTTokenExpiryTime } from '../../common/Utils/Login'; +import { JWT_EXPIRY_TIME_MAP } from '../../constants/constants'; import { CustomPropertySupportedEntityList } from '../../constants/CustomProperty.constant'; import DashboardClass from './../../common/Entities/DashboardClass'; import { CustomPropertyTypeByName } from './../../common/Utils/CustomProperty'; @@ -44,12 +46,14 @@ describe('Entity detail page', { tags: 'DataAssets' }, () => { before(() => { cy.login(); + updateJWTTokenExpiryTime(JWT_EXPIRY_TIME_MAP['2 hours']); EntityClass.preRequisitesForTests(); }); after(() => { cy.login(); + updateJWTTokenExpiryTime(JWT_EXPIRY_TIME_MAP['1 hour']); EntityClass.postRequisitesForTests(); }); entities.forEach((entity) => {