Add exposed ldap secret for bind auth
This commit is contained in:
@@ -83,6 +83,7 @@ describe('Settings API', function () {
|
||||
// keep in sync with defaults in settings.js
|
||||
let defaultConfig = {
|
||||
enabled: false,
|
||||
secret: '',
|
||||
allowlist: ''
|
||||
};
|
||||
|
||||
@@ -106,10 +107,49 @@ describe('Settings API', function () {
|
||||
expect(response.statusCode).to.equal(400);
|
||||
});
|
||||
|
||||
it('can set exposed_ldap_config', async function () {
|
||||
it('cannot set exposed_ldap_config without secret', async function () {
|
||||
let tmp = JSON.parse(JSON.stringify(defaultConfig));
|
||||
delete tmp.secret;
|
||||
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/settings/exposed_ldap_config`)
|
||||
.query({ access_token: owner.token })
|
||||
.send(tmp)
|
||||
.ok(() => true);
|
||||
|
||||
expect(response.statusCode).to.equal(400);
|
||||
});
|
||||
|
||||
it('cannot enable exposed_ldap_config with empty secret', async function () {
|
||||
let tmp = JSON.parse(JSON.stringify(defaultConfig));
|
||||
tmp.enabled = true;
|
||||
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/settings/exposed_ldap_config`)
|
||||
.query({ access_token: owner.token })
|
||||
.send(tmp)
|
||||
.ok(() => true);
|
||||
|
||||
expect(response.statusCode).to.equal(400);
|
||||
});
|
||||
|
||||
it('cannot enable exposed_ldap_config with empty allowlist', async function () {
|
||||
let tmp = JSON.parse(JSON.stringify(defaultConfig));
|
||||
tmp.enabled = true;
|
||||
tmp.secret = 'ldapsecret';
|
||||
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/settings/exposed_ldap_config`)
|
||||
.query({ access_token: owner.token })
|
||||
.send(tmp)
|
||||
.ok(() => true);
|
||||
|
||||
expect(response.statusCode).to.equal(400);
|
||||
});
|
||||
|
||||
it('can enable exposed_ldap_config', async function () {
|
||||
let tmp = JSON.parse(JSON.stringify(defaultConfig));
|
||||
tmp.enabled = true;
|
||||
tmp.secret = 'ldapsecret';
|
||||
tmp.allowlist = '1.2.3.4';
|
||||
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/settings/exposed_ldap_config`)
|
||||
.query({ access_token: owner.token })
|
||||
.send(tmp);
|
||||
@@ -125,7 +165,7 @@ describe('Settings API', function () {
|
||||
.query({ access_token: owner.token });
|
||||
|
||||
expect(response.statusCode).to.equal(200);
|
||||
expect(response.body).to.eql({ enabled: true, allowlist: '' });
|
||||
expect(response.body).to.eql({ enabled: true, secret: 'ldapsecret', allowlist: '1.2.3.4' });
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user