mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-09-25 08:50:18 +00:00
Fix: cypress tests invalid token issue (#15581)
This commit is contained in:
parent
cadca31b1c
commit
b86a8438c3
@ -13,6 +13,7 @@
|
||||
|
||||
import { interceptURL, verifyResponseStatusCode } from '../../common/common';
|
||||
import { searchServiceFromSettingPage } from '../../common/serviceUtils';
|
||||
import { getToken } from '../../common/Utils/LocalStorage';
|
||||
import { GlobalSettingOptions } from '../../constants/settings.constant';
|
||||
|
||||
const schemaNames = ['sales', 'admin', 'anonymous', 'dip', 'gsmadmin_internal'];
|
||||
@ -25,53 +26,55 @@ describe('Schema search', { tags: 'DataAssets' }, () => {
|
||||
});
|
||||
|
||||
it('Prerequisite', () => {
|
||||
const token = localStorage.getItem('oidcIdToken');
|
||||
cy.request({
|
||||
method: 'POST',
|
||||
url: `/api/v1/services/databaseServices`,
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
body: {
|
||||
name: serviceName,
|
||||
serviceType: 'Mysql',
|
||||
connection: {
|
||||
config: {
|
||||
type: 'Mysql',
|
||||
scheme: 'mysql+pymysql',
|
||||
username: 'test',
|
||||
authType: { password: 'test' },
|
||||
hostPort: 'test',
|
||||
supportsMetadataExtraction: true,
|
||||
supportsDBTExtraction: true,
|
||||
supportsProfiler: true,
|
||||
supportsQueryComment: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
}).then((response) => {
|
||||
expect(response.status).to.eq(201);
|
||||
|
||||
const service = response.body.fullyQualifiedName;
|
||||
serviceId = response.body.id;
|
||||
|
||||
cy.getAllLocalStorage().then((data) => {
|
||||
const token = getToken(data);
|
||||
cy.request({
|
||||
method: 'POST',
|
||||
url: `/api/v1/databases`,
|
||||
url: `/api/v1/services/databaseServices`,
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
body: {
|
||||
name: 'default',
|
||||
service,
|
||||
name: serviceName,
|
||||
serviceType: 'Mysql',
|
||||
connection: {
|
||||
config: {
|
||||
type: 'Mysql',
|
||||
scheme: 'mysql+pymysql',
|
||||
username: 'test',
|
||||
authType: { password: 'test' },
|
||||
hostPort: 'test',
|
||||
supportsMetadataExtraction: true,
|
||||
supportsDBTExtraction: true,
|
||||
supportsProfiler: true,
|
||||
supportsQueryComment: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
}).then((response) => {
|
||||
const database = response.body.fullyQualifiedName;
|
||||
schemaNames.map((schema) => {
|
||||
cy.request({
|
||||
method: 'POST',
|
||||
url: `/api/v1/databaseSchemas`,
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
body: {
|
||||
name: schema,
|
||||
database,
|
||||
},
|
||||
expect(response.status).to.eq(201);
|
||||
|
||||
const service = response.body.fullyQualifiedName;
|
||||
serviceId = response.body.id;
|
||||
|
||||
cy.request({
|
||||
method: 'POST',
|
||||
url: `/api/v1/databases`,
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
body: {
|
||||
name: 'default',
|
||||
service,
|
||||
},
|
||||
}).then((response) => {
|
||||
const database = response.body.fullyQualifiedName;
|
||||
schemaNames.map((schema) => {
|
||||
cy.request({
|
||||
method: 'POST',
|
||||
url: `/api/v1/databaseSchemas`,
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
body: {
|
||||
name: schema,
|
||||
database,
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -131,14 +134,15 @@ describe('Schema search', { tags: 'DataAssets' }, () => {
|
||||
});
|
||||
|
||||
it('Cleanup', () => {
|
||||
const token = localStorage.getItem('oidcIdToken');
|
||||
|
||||
cy.request({
|
||||
method: 'DELETE',
|
||||
url: `/api/v1/services/databaseServices/${serviceId}?hardDelete=true&recursive=true`,
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
}).then((response) => {
|
||||
expect(response.status).to.eq(200);
|
||||
cy.getAllLocalStorage().then((data) => {
|
||||
const token = getToken(data);
|
||||
cy.request({
|
||||
method: 'DELETE',
|
||||
url: `/api/v1/services/databaseServices/${serviceId}?hardDelete=true&recursive=true`,
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
}).then((response) => {
|
||||
expect(response.status).to.eq(200);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -85,20 +85,22 @@ describe('Customize Landing Page Flow', { tags: 'Settings' }, () => {
|
||||
|
||||
after(() => {
|
||||
cy.login();
|
||||
const token = localStorage.getItem('oidcIdToken');
|
||||
cy.getAllLocalStorage().then((data) => {
|
||||
const token = getToken(data);
|
||||
|
||||
// Delete created user
|
||||
cy.request({
|
||||
method: 'DELETE',
|
||||
url: `/api/v1/personas/${testData.persona.id}`,
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
// Delete created user
|
||||
cy.request({
|
||||
method: 'DELETE',
|
||||
url: `/api/v1/personas/${testData.persona.id}`,
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
|
||||
// Delete created landing page config doc
|
||||
cy.request({
|
||||
method: 'DELETE',
|
||||
url: `/api/v1/docStore/${testData.docStoreData.id}`,
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
// Delete created landing page config doc
|
||||
cy.request({
|
||||
method: 'DELETE',
|
||||
url: `/api/v1/docStore/${testData.docStoreData.id}`,
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
import { interceptURL, verifyResponseStatusCode } from '../../common/common';
|
||||
import { visitClassificationPage } from '../../common/TagUtils';
|
||||
import { getToken } from '../../common/Utils/LocalStorage';
|
||||
import {
|
||||
NEW_CLASSIFICATION_FOR_VERSION_TEST,
|
||||
NEW_CLASSIFICATION_PATCH_PAYLOAD,
|
||||
@ -45,28 +46,30 @@ describe(
|
||||
});
|
||||
|
||||
it('Prerequisites for classification version page tests', () => {
|
||||
const token = localStorage.getItem('oidcIdToken');
|
||||
|
||||
cy.request({
|
||||
method: 'PUT',
|
||||
url: `/api/v1/classifications`,
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
body: NEW_CLASSIFICATION_FOR_VERSION_TEST,
|
||||
}).then((response) => {
|
||||
expect(response.status).to.eq(201);
|
||||
|
||||
classificationId = response.body.id;
|
||||
cy.getAllLocalStorage().then((data) => {
|
||||
const token = getToken(data);
|
||||
|
||||
cy.request({
|
||||
method: 'PATCH',
|
||||
url: `/api/v1/classifications/${classificationId}`,
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
'Content-Type': 'application/json-patch+json',
|
||||
},
|
||||
body: NEW_CLASSIFICATION_PATCH_PAYLOAD,
|
||||
method: 'PUT',
|
||||
url: `/api/v1/classifications`,
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
body: NEW_CLASSIFICATION_FOR_VERSION_TEST,
|
||||
}).then((response) => {
|
||||
expect(response.status).to.eq(200);
|
||||
expect(response.status).to.eq(201);
|
||||
|
||||
classificationId = response.body.id;
|
||||
|
||||
cy.request({
|
||||
method: 'PATCH',
|
||||
url: `/api/v1/classifications/${classificationId}`,
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
'Content-Type': 'application/json-patch+json',
|
||||
},
|
||||
body: NEW_CLASSIFICATION_PATCH_PAYLOAD,
|
||||
}).then((response) => {
|
||||
expect(response.status).to.eq(200);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -22,6 +22,7 @@ import {
|
||||
verifyResponseStatusCode,
|
||||
} from '../../common/common';
|
||||
import { verifyKpiChart } from '../../common/DataInsightUtils';
|
||||
import { getToken } from '../../common/Utils/LocalStorage';
|
||||
import { SidebarItem } from '../../constants/Entity.interface';
|
||||
import { GlobalSettingOptions } from '../../constants/settings.constant';
|
||||
|
||||
@ -43,14 +44,17 @@ const deleteKpiRequest = () => {
|
||||
cy.wait('@getKpi').then(({ response }) => {
|
||||
const data = response.body.data;
|
||||
if (data.length > 0) {
|
||||
const token = localStorage.getItem('oidcIdToken');
|
||||
data.forEach((element) => {
|
||||
cy.request({
|
||||
method: 'DELETE',
|
||||
url: `/api/v1/kpi/${element.id}?hardDelete=true&recursive=false`,
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
}).then((response) => {
|
||||
expect(response.status).to.eq(200);
|
||||
cy.getAllLocalStorage().then((storageData) => {
|
||||
const token = getToken(storageData);
|
||||
|
||||
data.forEach((element) => {
|
||||
cy.request({
|
||||
method: 'DELETE',
|
||||
url: `/api/v1/kpi/${element.id}?hardDelete=true&recursive=false`,
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
}).then((response) => {
|
||||
expect(response.status).to.eq(200);
|
||||
});
|
||||
});
|
||||
});
|
||||
cy.reload();
|
||||
|
@ -24,6 +24,7 @@ import { deleteGlossary } from '../../common/GlossaryUtils';
|
||||
import { dragAndDropElement } from '../../common/Utils/DragAndDrop';
|
||||
import { visitEntityDetailsPage } from '../../common/Utils/Entity';
|
||||
import { confirmationDragAndDropGlossary } from '../../common/Utils/Glossary';
|
||||
import { getToken } from '../../common/Utils/LocalStorage';
|
||||
import { addOwner, removeOwner } from '../../common/Utils/Owner';
|
||||
import {
|
||||
COLUMN_NAME_FOR_APPLY_GLOSSARY_TERM,
|
||||
@ -684,14 +685,16 @@ const checkSummaryListItemSorting = ({ termFQN, columnName }) => {
|
||||
};
|
||||
|
||||
const deleteUser = () => {
|
||||
const token = localStorage.getItem('oidcIdToken');
|
||||
cy.getAllLocalStorage().then((storageData) => {
|
||||
const token = getToken(storageData);
|
||||
|
||||
cy.request({
|
||||
method: 'DELETE',
|
||||
url: `/api/v1/users/${createdUserId}?hardDelete=true&recursive=false`,
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
}).then((response) => {
|
||||
expect(response.status).to.eq(200);
|
||||
cy.request({
|
||||
method: 'DELETE',
|
||||
url: `/api/v1/users/${createdUserId}?hardDelete=true&recursive=false`,
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
}).then((response) => {
|
||||
expect(response.status).to.eq(200);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user