externalldap: no need to make REST API calls and start server
This commit is contained in:
@@ -13,8 +13,6 @@ const async = require('async'),
|
||||
groups = require('../groups.js'),
|
||||
ldap = require('ldapjs'),
|
||||
safe = require('safetydance'),
|
||||
server = require('../server.js'),
|
||||
superagent = require('superagent'),
|
||||
users = require('../users.js');
|
||||
|
||||
const LDAP_SHARED_PASSWORD = 'validpassword';
|
||||
@@ -206,7 +204,7 @@ class LdapServer {
|
||||
}
|
||||
|
||||
describe('External LDAP', function () {
|
||||
const { setup, cleanup, admin, serverUrl, auditSource } = common;
|
||||
const { setup, cleanup, admin, auditSource } = common;
|
||||
const ldapServer = new LdapServer(LDAP_CONFIG.provider);
|
||||
|
||||
before(function (done) {
|
||||
@@ -619,11 +617,11 @@ describe('External LDAP', function () {
|
||||
before(async function () {
|
||||
ldapServer.setUsers(ldapUsers);
|
||||
ldapServer.setGroups(ldapGroups);
|
||||
await server.start();
|
||||
//await server.start();
|
||||
});
|
||||
|
||||
after(async function () {
|
||||
await server.stop();
|
||||
//await server.stop();
|
||||
});
|
||||
|
||||
it('enable', async function () {
|
||||
@@ -637,11 +635,8 @@ describe('External LDAP', function () {
|
||||
email: 'auto0@login.com'
|
||||
});
|
||||
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/auth/login`)
|
||||
.send({ username: 'autologinuser0', password: LDAP_SHARED_PASSWORD })
|
||||
.ok(() => true);
|
||||
|
||||
expect(response.status).to.equal(401);
|
||||
const [error] = await safe(users.verifyWithUsername('autologinuser0', LDAP_SHARED_PASSWORD, users.AP_WEBADMIN, {}));
|
||||
expect(error.reason).to.be(BoxError.NOT_FOUND);
|
||||
|
||||
const result = await users.list();
|
||||
expect(result.find(function (u) {
|
||||
@@ -656,11 +651,8 @@ describe('External LDAP', function () {
|
||||
});
|
||||
|
||||
it('fails for unknown user', async function () {
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/auth/login`)
|
||||
.send({ username: 'doesnotexist', password: LDAP_SHARED_PASSWORD })
|
||||
.ok(() => true);
|
||||
|
||||
expect(response.status).to.equal(401);
|
||||
const [error] = await safe(users.verifyWithUsername('doesnotexist', LDAP_SHARED_PASSWORD, users.AP_WEBADMIN, {}));
|
||||
expect(error.reason).to.be(BoxError.NOT_FOUND);
|
||||
|
||||
const result = await users.list();
|
||||
expect(result.find(function (u) {
|
||||
@@ -675,11 +667,9 @@ describe('External LDAP', function () {
|
||||
email: 'auto1@login.com'
|
||||
});
|
||||
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/auth/login`)
|
||||
.send({ username: 'autologinuser1', password: 'wrongpassword' })
|
||||
.ok(() => true);
|
||||
const [error] = await safe(users.verifyWithUsername('autologinuser1', 'wrongpassword', users.AP_WEBADMIN, {}));
|
||||
expect(error.reason).to.be(BoxError.INVALID_CREDENTIALS);
|
||||
|
||||
expect(response.status).to.equal(401);
|
||||
const result = await users.list();
|
||||
expect(result.find(function (u) {
|
||||
return u.username === 'autologinuser1';
|
||||
@@ -694,11 +684,7 @@ describe('External LDAP', function () {
|
||||
password: LDAP_SHARED_PASSWORD
|
||||
});
|
||||
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/auth/login`)
|
||||
.send({ username: 'autologinuser2', password: LDAP_SHARED_PASSWORD })
|
||||
.ok(() => true);
|
||||
|
||||
expect(response.status).to.equal(200);
|
||||
await users.verifyWithUsername('autologinuser2', LDAP_SHARED_PASSWORD, users.AP_WEBADMIN, {});
|
||||
|
||||
const result = await users.list();
|
||||
expect(result.find(function (u) {
|
||||
|
||||
Reference in New Issue
Block a user