Skip to content

Commit

Permalink
Fix meta data missing in no auth data source saved object
Browse files Browse the repository at this point in the history
Signed-off-by: Lin Wang <[email protected]>
  • Loading branch information
wanglam committed Oct 29, 2024
1 parent 30639d2 commit 9ba2438
Showing 1 changed file with 44 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,29 +35,57 @@ Cypress.Commands.add('deleteAllDataSources', () => {
);
});

Cypress.Commands.add(
'createDataSourceNoAuth',
({ title = 'RemoteDataSourceNoAuth' } = {}) => {
cy.request({
const fetchDataSourceMetadata = (body) =>
cy
.request({
method: 'POST',
url: `${BASE_PATH}/api/saved_objects/data-source`,
url: `${BASE_PATH}/internal/data-source-management/fetchDataSourceMetaData`,
headers: {
'osd-xsrf': true,
},
body: {
attributes: {
title,
endpoint: Cypress.env('remoteDataSourceNoAuthUrl'),
auth: {
type: 'no_auth',
body,
failOnStatusCode: false,
})
.then(({ body }) => body);

Cypress.Commands.add(
'createDataSourceNoAuth',
({ title = 'RemoteDataSourceNoAuth' } = {}) => {
const endpoint = Cypress.env('remoteDataSourceNoAuthUrl');
const createDataSourceNoAuth = (dataSourceMetaData = {}) => {
cy.request({
method: 'POST',
url: `${BASE_PATH}/api/saved_objects/data-source`,
headers: {
'osd-xsrf': true,
},
body: {
attributes: {
title,
endpoint,
auth: {
type: 'no_auth',
},
...dataSourceMetaData,
},
},
}).then((resp) => {
if (resp && resp.body && resp.body.id) {
return [resp.body.id, title];
}
});
};
fetchDataSourceMetadata({
dataSourceAttr: {
endpoint,
auth: {
type: 'no_auth',
},
},
}).then((resp) => {
if (resp && resp.body && resp.body.id) {
return [resp.body.id, title];
}
});
}).then(
(dataSourceMeta) => createDataSourceNoAuth(dataSourceMeta),
() => createDataSourceNoAuth()
);
}
);

Expand Down

0 comments on commit 9ba2438

Please sign in to comment.