mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-08-27 10:26:09 +00:00
test: add updateJWTTokenExpiryTime util (#16606)
This commit is contained in:
parent
95e5177939
commit
8c173bed6a
@ -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);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
@ -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,
|
||||
};
|
||||
|
@ -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();
|
||||
});
|
||||
|
@ -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();
|
||||
});
|
||||
|
||||
|
@ -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) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user