Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
Add action for testElasticsearch. (#183)
Browse files Browse the repository at this point in the history
  • Loading branch information
grundleborg authored and hmhealey committed Aug 28, 2020
1 parent 8971a21 commit b3380bb
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 2 deletions.
6 changes: 5 additions & 1 deletion packages/mattermost-redux/src/action_types/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ export default keyMirror({
RECEIVED_COMPLIANCE_REPORT: null,
RECEIVED_COMPLIANCE_REPORTS: null,
RECEIVED_CLUSTER_STATUS: null,
RECEIVED_SAML_CERT_STATUS: null
RECEIVED_SAML_CERT_STATUS: null,

TEST_ELASTICSEARCH_REQUEST: null,
TEST_ELASTICSEARCH_SUCCESS: null,
TEST_ELASTICSEARCH_FAILURE: null
});

9 changes: 9 additions & 0 deletions packages/mattermost-redux/src/actions/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,3 +219,12 @@ export function removeIdpSamlCertificate() {
AdminTypes.DELETE_SAML_IDP_FAILURE
);
}

export function testElasticsearch() {
return bindClientFunc(
Client4.testElasticsearch,
AdminTypes.TEST_ELASTICSEARCH_REQUEST,
AdminTypes.TEST_ELASTICSEARCH_SUCCESS,
AdminTypes.TEST_ELASTICSEARCH_FAILURE
);
}
7 changes: 7 additions & 0 deletions packages/mattermost-redux/src/client/client4.js
Original file line number Diff line number Diff line change
Expand Up @@ -1489,6 +1489,13 @@ export default class Client4 {
);
};

testElasticsearch = async () => {
return this.doFetch(
`${this.getBaseRoute()}/elasticsearch/test`,
{method: 'post'}
);
};

// Client Helpers

doFetch = async (url, options) => {
Expand Down
13 changes: 12 additions & 1 deletion packages/mattermost-redux/src/reducers/requests/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,16 @@ function removeIdpSamlCertificate(state = initialRequestState(), action) {
);
}

function testElasticsearch(state = initialRequestState(), action) {
return handleRequest(
AdminTypes.TEST_ELASTICSEARCH_REQUEST,
AdminTypes.TEST_ELASTICSEARCH_SUCCESS,
AdminTypes.TEST_ELASTICSEARCH_FAILURE,
state,
action
);
}

export default combineReducers({
getLogs,
getAudits,
Expand All @@ -237,6 +247,7 @@ export default combineReducers({
uploadIdpSamlCertificate,
removePublicSamlCertificate,
removePrivateSamlCertificate,
removeIdpSamlCertificate
removeIdpSamlCertificate,
testElasticsearch
});

14 changes: 14 additions & 0 deletions packages/mattermost-redux/test/actions/admin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -471,4 +471,18 @@ describe('Actions.Admin', () => {
throw new Error('removeIdpSamlCertificate request failed err=' + request.error);
}
});

it('testElasticsearch', async () => {
nock(Client4.getBaseRoute()).
post('/elasticsearch/test').
reply(200, OK_RESPONSE);

await Actions.testElasticsearch()(store.dispatch, store.getState);

const state = store.getState();
const request = state.requests.admin.testElasticsearch;
if (request.status === RequestStatus.FAILURE) {
throw new Error('testElasticsearch request failed err=' + request.error);
}
});
});

0 comments on commit b3380bb

Please sign in to comment.