groups: members cannot be set for external groups
This commit is contained in:
@@ -397,7 +397,7 @@ describe('External LDAP', function () {
|
||||
await externalLdap.sync(function progress() {});
|
||||
const result = await users.list();
|
||||
expect(result.find(function (u) {
|
||||
return u.username === 'firstuser' && u.email === 'first@user.com' && u.displayName === 'First User';
|
||||
return u.username === 'firstuser' && u.email === 'first@user.com' && u.displayName === 'First User' && u.source === 'ldap';
|
||||
})).to.be.ok();
|
||||
});
|
||||
|
||||
@@ -408,11 +408,11 @@ describe('External LDAP', function () {
|
||||
await externalLdap.sync(function progress() {});
|
||||
const result = await users.list();
|
||||
expect(result.find(function (u) {
|
||||
return u.username === 'firstuser' && u.email === 'first@changed.com' && u.displayName === 'User First';
|
||||
return u.username === 'firstuser' && u.email === 'first@changed.com' && u.displayName === 'User First' && u.source === 'ldap';
|
||||
})).to.be.ok();
|
||||
});
|
||||
|
||||
it('mapps already existing users with same username', async function () {
|
||||
it('maps already existing users with same username', async function () {
|
||||
gLdapUsers.push({
|
||||
username: admin.username,
|
||||
displayName: 'Something Else',
|
||||
@@ -436,6 +436,11 @@ describe('External LDAP', function () {
|
||||
expect(result.length).to.equal(0);
|
||||
});
|
||||
|
||||
it('can set groups of external user when group sync is disabled', async function () {
|
||||
const user = await users.getByUsername(gLdapUsers[0].username);
|
||||
await groups.setMembership(user, []);
|
||||
});
|
||||
|
||||
it('enable with groupSync', async function () {
|
||||
let conf = Object.assign({}, LDAP_CONFIG);
|
||||
conf.syncGroups = true;
|
||||
@@ -458,7 +463,7 @@ describe('External LDAP', function () {
|
||||
await externalLdap.sync(function progress() {});
|
||||
const result = await groups.list();
|
||||
expect(result.find(function (g) {
|
||||
return g.name === 'extgroup1';
|
||||
return g.name === 'extgroup1' && g.source === 'ldap';
|
||||
})).to.be.ok();
|
||||
});
|
||||
|
||||
@@ -471,11 +476,11 @@ describe('External LDAP', function () {
|
||||
const result = await groups.list();
|
||||
expect(result.length).to.be(2);
|
||||
expect(result.find(function (g) {
|
||||
return g.name === 'extgroup2';
|
||||
return g.name === 'extgroup2' && g.source === 'ldap';
|
||||
})).to.be.ok();
|
||||
});
|
||||
|
||||
it('does not create already existing group', async function () {
|
||||
it('does not create or change already existing group', async function () {
|
||||
gLdapGroups.push({
|
||||
groupname: 'INTERNALgroup' // also tests lowercasing
|
||||
});
|
||||
@@ -485,6 +490,9 @@ describe('External LDAP', function () {
|
||||
|
||||
const result = await groups.list();
|
||||
expect(result.length).to.equal(3);
|
||||
expect(result.find(function (g) {
|
||||
return g.name === 'internalgroup' && g.source === 'ldap'; // source is updated to LDAP
|
||||
})).to.be.ok();
|
||||
});
|
||||
|
||||
it('adds users of groups', async function () {
|
||||
@@ -530,6 +538,12 @@ describe('External LDAP', function () {
|
||||
const u = await users.get(result2[0]);
|
||||
expect(u.username).to.equal(gLdapUsers[0].username);
|
||||
});
|
||||
|
||||
it('cannot set groups of external user when group sync is disabled', async function () {
|
||||
const user = await users.getByUsername(gLdapUsers[0].username);
|
||||
const [error] = await safe(groups.setMembership(user, []));
|
||||
expect(error.reason).to.be(BoxError.BAD_STATE);
|
||||
});
|
||||
});
|
||||
|
||||
describe('user auto creation', function () {
|
||||
|
||||
Reference in New Issue
Block a user