Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation succeed as long as status code in response is 200 #6399

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- [BUG][Multiple Datasource]Fix bug in data source aggregated view to change it to depend on displayAllCompatibleDataSources property to show the badge value ([#6291](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6291))
- [BUG][Multiple Datasource]Read hideLocalCluster setting from yml and set in data source selector and data source menu ([#6361](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6361))
- [BUG] Fix for checkForFunctionProperty so that order does not matter ([#6248](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6248))
- [BUG][Multiple Datasource] Validation succeed as long as status code in response is 200 ([#6399](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6399))

### 🚞 Infrastructure

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,24 +165,20 @@ describe('DataSourceManagement: data_source_connection_validator.ts', () => {
expect(validateDataSourcesResponse.statusCode).toBe(200);
});

test('failure: opensearch client response code is 200 and response body is empty', async () => {
try {
const opensearchClient = opensearchServiceMock.createOpenSearchClient();
opensearchClient.cat.indices.mockResolvedValue(opensearchServiceMock.createApiResponse());
const dataSourceValidator = new DataSourceConnectionValidator(opensearchClient, {
auth: {
statusCode: 200,
body: '',
credentials: {
service: SigV4ServiceName.OpenSearchServerless,
},
test('Success: opensearch client response code is 200 and response body is empty', async () => {
const opensearchClient = opensearchServiceMock.createOpenSearchClient();
opensearchClient.cat.indices.mockResolvedValue(opensearchServiceMock.createApiResponse());
const dataSourceValidator = new DataSourceConnectionValidator(opensearchClient, {
auth: {
statusCode: 200,
body: '',
credentials: {
service: SigV4ServiceName.OpenSearchServerless,
},
});
const validateDataSourcesResponse = await dataSourceValidator.validate();
expect(validateDataSourcesResponse.statusCode).toBe(200);
} catch (e) {
expect(e).toBeTruthy();
}
},
});
const validateDataSourcesResponse = await dataSourceValidator.validate();
expect(validateDataSourcesResponse.statusCode).toBe(200);
});

test('failure: opensearch client response code is other than 200', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class DataSourceConnectionValidator {
this.dataSourceAttr.auth?.credentials?.service === SigV4ServiceName.OpenSearchServerless
) {
validationResponse = await this.callDataCluster.cat.indices();
if (validationResponse?.statusCode === 200 && validationResponse?.body) {
if (validationResponse?.statusCode === 200) {
return validationResponse;
}
} else {
Expand Down
Loading