Commit 1761e049 authored by Patricio Bruna's avatar Patricio Bruna

Fixed regex to get domainAdmins

parent d37aa40f
......@@ -30755,7 +30755,7 @@ return /******/ (function(modules) { // webpackBootstrap
module.exports = {
"name": "zimbra-admin-api-js",
"version": "0.2.14",
"version": "0.2.15",
"main": "lib/zimbra-admin-api.js",
"dependencies": {
"crypto-browserify": "^3.11.0",
......@@ -31874,7 +31874,7 @@ return /******/ (function(modules) { // webpackBootstrap
key: 'getAdmins',
value: function getAdmins(callback) {
var that = this;
var admins_ids = this.getAdminsIdsFromGrants();
var admins_ids = this.getAdminsIdsFromGrants(this.attrs.zimbraACE);
var query = this.makeAdminIdsQuery(admins_ids);
return this.api.getAllAccounts(callback, { query: query });
}
......@@ -31884,12 +31884,13 @@ return /******/ (function(modules) { // webpackBootstrap
}, {
key: 'getAdminsIdsFromGrants',
value: function getAdminsIdsFromGrants() {
value: function getAdminsIdsFromGrants(zimbraACES) {
var _this4 = this;
var ids = [];
this.parseACL(this.attrs.zimbraACE).forEach(function (grantee) {
if (grantee.right === _this4.domainAdminRights) ids.push(grantee.id);
var regex = new RegExp(this.domainAdminRights + '$');
this.parseACL(zimbraACES).forEach(function (grantee) {
if (regex.test(_this4.domainAdminRights)) ids.push(grantee.id);
});
return ids;
}
......
{
"name": "zimbra-admin-api-js",
"version": "0.2.14",
"version": "0.2.15",
"main": "lib/zimbra-admin-api.js",
"dependencies": {
"crypto-browserify": "^3.11.0",
......
......@@ -86,17 +86,18 @@ class Domain extends Zimbra {
// TODO: Fix this fucking ugly code
getAdmins(callback) {
const that = this;
const admins_ids = this.getAdminsIdsFromGrants();
const admins_ids = this.getAdminsIdsFromGrants(this.attrs.zimbraACE);
const query = this.makeAdminIdsQuery(admins_ids);
return this.api.getAllAccounts(callback, {query: query});
}
// Return the ZimbraId if the grantee have the domainAdminRights right
// Grant.right_name() == domainAdminRights
getAdminsIdsFromGrants() {
getAdminsIdsFromGrants(zimbraACES) {
const ids = [];
this.parseACL(this.attrs.zimbraACE).forEach((grantee) => {
if (grantee.right === this.domainAdminRights) ids.push(grantee.id);
const regex = new RegExp(`${this.domainAdminRights}$`);
this.parseACL(zimbraACES).forEach((grantee) => {
if (regex.test(this.domainAdminRights)) ids.push(grantee.id);
});
return ids;
}
......
......@@ -588,13 +588,17 @@
domain.addAdmin(account.id, coses, function(e, d){
if (e) return console.error(e);
expect(err).to.be.null;
domain.getACLs(function(e, d){
d.getACLs(function(e, acls){
if (e) return console.error(e);
const expectedGrants = ["domainAdminRights", "set.dl.zimbraACE", "set.domain.amavisBlacklistSender", "set.domain.amavisWhitelistSender"];
const actualGrants = d.map(function(d){return d.rightName}).sort()
const actualGrants = acls.map(function(acl){return acl.rightName}).sort()
expect(expectedGrants[0]).to.be.equal(actualGrants[0]);
expect(expectedGrants[2]).to.be.equal(actualGrants[2]);
done();
d.getAdmins(function(e, admins){
if (e) return console.error(e);
expect(admins.account[0].name).to.be.equal(domain_admin);
done();
})
});
});
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment