mattermost-mobile/detox/e2e/support/server_api/ldap.js
Joseph Baylon b87cf8358b
MM-41854 Detox/E2E: Setup detox infrastructure in Gekidou (#5979)
* MM-41854 Detox/E2E: Setup detox infrastructure in Gekidou

* Fix lint issues

* Fix lint issues

* Update API to include baseUrl for multiple servers

* Update init.js to have default siteUrl as baseUrl

* Update init.js to have default siteUrl as baseUrl

* Update import of testConfig

* Update import of testConfig

* Update postMessageAs signature

* Update detox/webhook_server.js

Co-authored-by: Avinash Lingaloo <avinashlng1080@gmail.com>

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Co-authored-by: Avinash Lingaloo <avinashlng1080@gmail.com>
2022-03-01 07:20:59 -08:00

69 lines
2.1 KiB
JavaScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import jestExpect from 'expect';
import client from './client';
import {getResponseFromError} from './common';
// ****************************************************************
// LDAP
// See https://api.mattermost.com/#tag/LDAP
//
// Exported API function should have the following:
// - documented using JSDoc
// - meaningful description
// - match the referenced API endpoints
// - parameter/s defined by `@param`
// - return value defined by `@return`
// ****************************************************************
/**
* Synchronize any user attribute changes in the configured AD/LDAP server with Mattermost.
* See https://api.mattermost.com/#operation/SyncLdap
* @param {string} baseUrl - the base server URL
* @return {string} returns response on success or {error, status} on error
*/
export const apiLDAPSync = async (baseUrl) => {
try {
return await client.post(`${baseUrl}/api/v4/ldap/sync`);
} catch (err) {
return getResponseFromError(err);
}
};
/**
* Test the current AD/LDAP configuration to see if the AD/LDAP server can be contacted successfully.
* See https://api.mattermost.com/#operation/TestLdap
* @param {string} baseUrl - the base server URL
* @return {Object} returns {status} on success or {error, status} on error
*/
export const apiLDAPTest = async (baseUrl) => {
try {
const response = await client.post(`${baseUrl}/api/v4/ldap/test`);
return {status: response.status};
} catch (err) {
return getResponseFromError(err);
}
};
/**
* Check that LDAP server can connect and is synchronized with Mattermost server.
* @param {string} baseUrl - the base server URL
*/
export const apiRequireLDAPServer = async (baseUrl) => {
const {error: testError} = await apiLDAPTest(baseUrl);
jestExpect(testError).toBeUndefined();
const {error: syncError} = await apiLDAPSync(baseUrl);
jestExpect(syncError).toBeUndefined();
};
export const Ldap = {
apiLDAPSync,
apiLDAPTest,
apiRequireLDAPServer,
};
export default Ldap;