Commit 458a4bf5 authored by Patricio Bruna's avatar Patricio Bruna

Added getGrant(), Grant Class, and refactor test

parent bc6eb4cb
...@@ -131,6 +131,7 @@ return /******/ (function(modules) { // webpackBootstrap ...@@ -131,6 +131,7 @@ return /******/ (function(modules) { // webpackBootstrap
this.parseRemoveResponse = this.parseRemoveResponse.bind(this); this.parseRemoveResponse = this.parseRemoveResponse.bind(this);
this.parseCountAccountResponse = this.parseCountAccountResponse.bind(this); this.parseCountAccountResponse = this.parseCountAccountResponse.bind(this);
this.parseSearchResponse = this.parseSearchResponse.bind(this); this.parseSearchResponse = this.parseSearchResponse.bind(this);
this.parseGrantsResponse = this.parseGrantsResponse.bind(this);
this.dictionary = new _dictionary2.default(); this.dictionary = new _dictionary2.default();
} }
...@@ -225,6 +226,13 @@ return /******/ (function(modules) { // webpackBootstrap ...@@ -225,6 +226,13 @@ return /******/ (function(modules) { // webpackBootstrap
}); });
return callback(null, result); return callback(null, result);
} }
}, {
key: 'parseGrantsResponse',
value: function parseGrantsResponse(data, request_data, callback) {
var result = {};
var response_object = data.get().GetGrantsResponse;
callback(null, response_object);
}
}, { }, {
key: 'parseResponse', key: 'parseResponse',
value: function parseResponse(data, request_data, callback) { value: function parseResponse(data, request_data, callback) {
...@@ -268,7 +276,7 @@ return /******/ (function(modules) { // webpackBootstrap ...@@ -268,7 +276,7 @@ return /******/ (function(modules) { // webpackBootstrap
var response_name = that.dictionary.resourceResponseName(resource); var response_name = that.dictionary.resourceResponseName(resource);
var response_object = data.get()[request_data.response_name][response_name]; var response_object = data.get()[request_data.response_name][response_name];
var response_array = []; var response_array = [];
response_object.forEach(function (r) { if (response_object) response_object.forEach(function (r) {
var element = that.dictionary.classFactory(resource, r, that); var element = that.dictionary.classFactory(resource, r, that);
response_array.push(element); response_array.push(element);
}); });
...@@ -448,25 +456,36 @@ return /******/ (function(modules) { // webpackBootstrap ...@@ -448,25 +456,36 @@ return /******/ (function(modules) { // webpackBootstrap
request_data.parse_response = this.parseAllResponse; request_data.parse_response = this.parseAllResponse;
this.performRequest(request_data); this.performRequest(request_data);
} }
// Returns all grants on the specified target entry, or all grants granted to the specified grantee entry.
// target_data and grantee_data are both objects like:
// {
// type: (account|cos|dl|domain),
// identifier: (name or zimbraId)
// }
}, { }, {
key: 'getGrants', key: 'getGrants',
value: function getGrants(target_data, grantee_data, callback) { value: function getGrants(target_data, grantee_data, callback) {
var request_data = {}; var request_data = {};
var resource = 'Grant';
request_data.params = this.requestParams(); request_data.params = this.requestParams();
request_data.request_name = 'GetGrants'; request_data.request_name = 'Get' + resource + 's';
request_data.response_name = 'GetGrantsResponse'; request_data.response_name = 'Get' + resource + 'sResponse';
request_data.params.name = request_data.request_name + 'Request'; request_data.params.name = request_data.request_name + 'Request';
request_data.callback = callback; request_data.callback = callback;
request_data.parse_response = this.parseGetGrantsResponse; request_data.resource = resource;
request_data.params.params.target = { request_data.parse_response = this.parseAllResponse;
if (target_data) request_data.params.params.target = {
'type': target_data.type, 'type': target_data.type,
'by': this.dictionary.byIdOrName(target_data.identifier), 'by': this.dictionary.byIdOrName(target_data.identifier),
'_content': target_data.identifier '_content': target_data.identifier
}; };
request_data.params.params.grantee = { if (grantee_data) request_data.params.params.grantee = {
'type': target_data.type, 'type': grantee_data.type,
'by': this.dictionary.byIdOrName(target_data.identifier), 'by': this.dictionary.byIdOrName(grantee_data.identifier),
'_content': target_data.identifier 'all': 1,
'_content': grantee_data.identifier
}; };
this.performRequest(request_data); this.performRequest(request_data);
} }
...@@ -12207,12 +12226,19 @@ return /******/ (function(modules) { // webpackBootstrap ...@@ -12207,12 +12226,19 @@ return /******/ (function(modules) { // webpackBootstrap
var _cos2 = _interopRequireDefault(_cos); var _cos2 = _interopRequireDefault(_cos);
var _grant = __webpack_require__(283);
var _grant2 = _interopRequireDefault(_grant);
var _distribution_list = __webpack_require__(117); var _distribution_list = __webpack_require__(117);
var _distribution_list2 = _interopRequireDefault(_distribution_list); var _distribution_list2 = _interopRequireDefault(_distribution_list);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// Copyright (c) 2016 ZBox, Spa. All Rights Reserved.
// See LICENSE.txt for license information.
var Dictionary = function () { var Dictionary = function () {
function Dictionary() { function Dictionary() {
(0, _classCallCheck3.default)(this, Dictionary); (0, _classCallCheck3.default)(this, Dictionary);
...@@ -12284,6 +12310,14 @@ return /******/ (function(modules) { // webpackBootstrap ...@@ -12284,6 +12310,14 @@ return /******/ (function(modules) { // webpackBootstrap
class_name: _account2.default, class_name: _account2.default,
response_name: 'account' response_name: 'account'
}, },
alias: {
response_name: 'alias',
class_name: _alias2.default
},
cos: {
class_name: _cos2.default,
response_name: 'cos'
},
distributionlist: { distributionlist: {
class_name: _distribution_list2.default, class_name: _distribution_list2.default,
response_name: 'dl' response_name: 'dl'
...@@ -12292,21 +12326,15 @@ return /******/ (function(modules) { // webpackBootstrap ...@@ -12292,21 +12326,15 @@ return /******/ (function(modules) { // webpackBootstrap
class_name: _distribution_list2.default, class_name: _distribution_list2.default,
response_name: 'dl' response_name: 'dl'
}, },
alias: { grant: {
response_name: 'alias', class_name: _grant2.default,
class_name: _alias2.default response_name: 'grant'
},
cos: {
class_name: _cos2.default,
response_name: 'cos'
} }
}; };
} }
}]); }]);
return Dictionary; return Dictionary;
}(); // Copyright (c) 2016 ZBox, Spa. All Rights Reserved. }();
// See LICENSE.txt for license information.
exports.default = Dictionary; exports.default = Dictionary;
...@@ -13068,7 +13096,11 @@ return /******/ (function(modules) { // webpackBootstrap ...@@ -13068,7 +13096,11 @@ return /******/ (function(modules) { // webpackBootstrap
function Domain(domain_obj, zimbra_api_client) { function Domain(domain_obj, zimbra_api_client) {
(0, _classCallCheck3.default)(this, Domain); (0, _classCallCheck3.default)(this, Domain);
return (0, _possibleConstructorReturn3.default)(this, (0, _getPrototypeOf2.default)(Domain).call(this, domain_obj, zimbra_api_client));
var _this = (0, _possibleConstructorReturn3.default)(this, (0, _getPrototypeOf2.default)(Domain).call(this, domain_obj, zimbra_api_client));
_this.domainAdminRights = 'domainAdminRights';
return _this;
} }
(0, _createClass3.default)(Domain, [{ (0, _createClass3.default)(Domain, [{
...@@ -40110,6 +40142,35 @@ return /******/ (function(modules) { // webpackBootstrap ...@@ -40110,6 +40142,35 @@ return /******/ (function(modules) { // webpackBootstrap
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(139).Buffer)) /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(139).Buffer))
/***/ },
/* 283 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _classCallCheck2 = __webpack_require__(68);
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// Copyright (c) 2016 ZBox, Spa. All Rights Reserved.
// See LICENSE.txt for license information.
var Grant = function Grant(grant) {
(0, _classCallCheck3.default)(this, Grant);
this.grantee = grant.grantee[0];
this.target = grant.target[0];
this.right = grant.right[0];
};
exports.default = Grant;
/***/ } /***/ }
/******/ ]) /******/ ])
}); });
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -37,6 +37,7 @@ export default class ZimbraAdminApi { ...@@ -37,6 +37,7 @@ export default class ZimbraAdminApi {
this.parseRemoveResponse = this.parseRemoveResponse.bind(this); this.parseRemoveResponse = this.parseRemoveResponse.bind(this);
this.parseCountAccountResponse = this.parseCountAccountResponse.bind(this); this.parseCountAccountResponse = this.parseCountAccountResponse.bind(this);
this.parseSearchResponse = this.parseSearchResponse.bind(this); this.parseSearchResponse = this.parseSearchResponse.bind(this);
this.parseGrantsResponse = this.parseGrantsResponse.bind(this);
this.dictionary = new Dictionary(); this.dictionary = new Dictionary();
} }
...@@ -127,11 +128,17 @@ export default class ZimbraAdminApi { ...@@ -127,11 +128,17 @@ export default class ZimbraAdminApi {
result[cos.name] = { result[cos.name] = {
used: parseInt(cos._content), used: parseInt(cos._content),
id: cos.id id: cos.id
} };
}); });
return callback(null, result); return callback(null, result);
} }
parseGrantsResponse(data, request_data, callback) {
const result = {};
const response_object = data.get().GetGrantsResponse;
callback(null, response_object);
}
parseResponse(data, request_data, callback) { parseResponse(data, request_data, callback) {
const resource = request_data.resource.toLowerCase(); const resource = request_data.resource.toLowerCase();
const that = this; const that = this;
...@@ -170,7 +177,7 @@ export default class ZimbraAdminApi { ...@@ -170,7 +177,7 @@ export default class ZimbraAdminApi {
const response_name = that.dictionary.resourceResponseName(resource); const response_name = that.dictionary.resourceResponseName(resource);
const response_object = data.get()[request_data.response_name][response_name]; const response_object = data.get()[request_data.response_name][response_name];
const response_array = []; const response_array = [];
response_object.forEach((r) => { if (response_object) response_object.forEach((r) => {
let element = that.dictionary.classFactory(resource, r, that); let element = that.dictionary.classFactory(resource, r, that);
response_array.push(element); response_array.push(element);
}); });
...@@ -326,23 +333,33 @@ export default class ZimbraAdminApi { ...@@ -326,23 +333,33 @@ export default class ZimbraAdminApi {
this.performRequest(request_data); this.performRequest(request_data);
} }
// Returns all grants on the specified target entry, or all grants granted to the specified grantee entry.
// target_data and grantee_data are both objects like:
// {
// type: (account|cos|dl|domain),
// identifier: (name or zimbraId)
// }
getGrants(target_data, grantee_data, callback) { getGrants(target_data, grantee_data, callback) {
const request_data = { }; const request_data = { };
const resource = 'Grant';
request_data.params = this.requestParams(); request_data.params = this.requestParams();
request_data.request_name = 'GetGrants'; request_data.request_name = `Get${resource}s`;
request_data.response_name = 'GetGrantsResponse'; request_data.response_name = `Get${resource}sResponse`;
request_data.params.name = `${request_data.request_name}Request`; request_data.params.name = `${request_data.request_name}Request`;
request_data.callback = callback; request_data.callback = callback;
request_data.parse_response = this.parseGetGrantsResponse; request_data.resource = resource;
request_data.params.params.target = { request_data.parse_response = this.parseAllResponse;
if (target_data) request_data.params.params.target = {
'type': target_data.type, 'type': target_data.type,
'by': this.dictionary.byIdOrName(target_data.identifier), 'by': this.dictionary.byIdOrName(target_data.identifier),
'_content': target_data.identifier '_content': target_data.identifier
}; };
request_data.params.params.grantee = { if (grantee_data) request_data.params.params.grantee = {
'type': target_data.type, 'type': grantee_data.type,
'by': this.dictionary.byIdOrName(target_data.identifier), 'by': this.dictionary.byIdOrName(grantee_data.identifier),
'_content': target_data.identifier 'all': 1,
'_content': grantee_data.identifier
}; };
this.performRequest(request_data); this.performRequest(request_data);
} }
......
...@@ -5,6 +5,7 @@ import Domain from './../zimbra/domain.js'; ...@@ -5,6 +5,7 @@ import Domain from './../zimbra/domain.js';
import Account from './../zimbra/account.js'; import Account from './../zimbra/account.js';
import Alias from './../zimbra/alias.js'; import Alias from './../zimbra/alias.js';
import Cos from './../zimbra/cos.js'; import Cos from './../zimbra/cos.js';
import Grant from './../zimbra/grant.js';
import DistributionList from './../zimbra/distribution_list.js'; import DistributionList from './../zimbra/distribution_list.js';
export default class Dictionary { export default class Dictionary {
...@@ -64,6 +65,14 @@ export default class Dictionary { ...@@ -64,6 +65,14 @@ export default class Dictionary {
class_name: Account, class_name: Account,
response_name: 'account' response_name: 'account'
}, },
alias: {
response_name: 'alias',
class_name: Alias,
},
cos: {
class_name: Cos,
response_name: 'cos'
},
distributionlist: { distributionlist: {
class_name: DistributionList, class_name: DistributionList,
response_name: 'dl' response_name: 'dl'
...@@ -72,15 +81,10 @@ export default class Dictionary { ...@@ -72,15 +81,10 @@ export default class Dictionary {
class_name: DistributionList, class_name: DistributionList,
response_name: 'dl' response_name: 'dl'
}, },
alias: { grant: {
response_name: 'alias', class_name: Grant,
class_name: Alias, response_name: 'grant'
},
cos: {
class_name: Cos,
response_name: 'cos'
} }
}; };
} }
......
...@@ -6,6 +6,7 @@ import Zimbra from './zimbra.js'; ...@@ -6,6 +6,7 @@ import Zimbra from './zimbra.js';
export default class Domain extends Zimbra { export default class Domain extends Zimbra {
constructor(domain_obj, zimbra_api_client) { constructor(domain_obj, zimbra_api_client) {
super(domain_obj, zimbra_api_client); super(domain_obj, zimbra_api_client);
this.domainAdminRights = 'domainAdminRights';
} }
countAccounts(callback) { countAccounts(callback) {
......
// Copyright (c) 2016 ZBox, Spa. All Rights Reserved.
// See LICENSE.txt for license information.
export default class Grant {
constructor(grant) {
this.grantee = grant.grantee[0];
this.target = grant.target[0];
this.right = grant.right[0];
}
}
...@@ -21,10 +21,6 @@ ...@@ -21,10 +21,6 @@
describe('Basic tests', function() { describe('Basic tests', function() {
this.fixtures = {
domain: loadFixture('domain')
};
it('should return error object when timeout', function() { it('should return error object when timeout', function() {
let api = new ZimbraAdminApi({ let api = new ZimbraAdminApi({
'url': 'http://localhost', 'url': 'http://localhost',
...@@ -144,56 +140,55 @@ ...@@ -144,56 +140,55 @@
api.getDomain('zboxapp.dev', callback); api.getDomain('zboxapp.dev', callback);
}); });
it('should create and return an account', function(done){ it('getInfo() should return the logged user info', function(done){
let account_name = Date.now() + '@big.com';
let account_password = Date.now();
let account_attributes = {};
let api = new ZimbraAdminApi(auth_data); let api = new ZimbraAdminApi(auth_data);
api.createAccount(account_name, account_password, account_attributes, function(err, data){ let callback = function(err, data) {
if (err) return console.log(err); if (err) return console.log(err);
expect(data.name).to.equal(account_name); api.getInfo(function(err, data){
done(); if (err) return console.log(err);
}); expect(data.name).to.equal('admin@zboxapp.dev');
done();
});
};
api.login(callback);
}); });
it('should create and return Domain', function(done){ it('should return directorySearch with total info', function(done){
let resource_name = Date.now() + '.dev';
let resource_attributes = {};
let api = new ZimbraAdminApi(auth_data); let api = new ZimbraAdminApi(auth_data);
api.createDomain(resource_name, resource_attributes, function(err, data){ let query_object = {limit: 10, domain: 'customer.dev', types: "accounts,distributionlists,aliases"};
if (err) return console.log(err); api.directorySearch(query_object, function(err, data){
expect(data.name).to.equal(resource_name); expect(data.more).to.equal(true);
expect(data.total).to.be.above(1);
expect(data.account.length).to.be.at.least(2);
done(); done();
}); });
}); });
it('should return error "account.DOMAIN_EXISTS" if Domain Exists', function(done){ it('countAccounts hould return {} for empty Domain', function(done){
let resource_name = 'zboxapp.dev';
let resource_attributes = {};
let api = new ZimbraAdminApi(auth_data); let api = new ZimbraAdminApi(auth_data);
api.createDomain(resource_name, resource_attributes, function(err, data){ api.countAccounts('juanitalapoderosa.com', function(err, data){
expect(err.extra.code).to.equal('account.DOMAIN_EXISTS'); if (err) console.error(err);
expect(data).to.be.empty;
done(); done();
}); });
}); });
it('should create and return Domain with attributes', function(done){ });
let resource_name = Date.now() + '.dev';
let resource_attributes = { describe('Account tests', function() {
zimbraSkinLogoURL: 'http://www.zboxapp.com',
postOfficeBox: 'ZBoxApp' it('should create and return an account', function(done){
}; let account_name = Date.now() + '@big.com';
let account_password = Date.now();
let account_attributes = {};
let api = new ZimbraAdminApi(auth_data); let api = new ZimbraAdminApi(auth_data);
let callback = function(err, data){ api.createAccount(account_name, account_password, account_attributes, function(err, data){
if (err) return console.log(err); if (err) return console.log(err);
expect(data.attrs.zimbraSkinLogoURL).to.equal('http://www.zboxapp.com'); expect(data.name).to.equal(account_name);
expect(data.attrs.postOfficeBox).to.equal('ZBoxApp');
done(); done();
}; });
api.createDomain(resource_name, resource_attributes, callback);
}); });
it('should create and return an account with extra attributes', function(done){ it('should create and return an account with extra attributes', function(done){
let account_name = Date.now() + '@big.com'; let account_name = Date.now() + '@big.com';
let account_password = Date.now(); let account_password = Date.now();
...@@ -207,30 +202,6 @@ ...@@ -207,30 +202,6 @@
}); });
}); });
it('getInfo() should return the logged user info', function(done){
let api = new ZimbraAdminApi(auth_data);
let callback = function(err, data) {
if (err) return console.log(err);
api.getInfo(function(err, data){
if (err) return console.log(err);
expect(data.name).to.equal('admin@zboxapp.dev');
done();
});
};
api.login(callback);
});
it('should return directorySearch with total info', function(done){
let api = new ZimbraAdminApi(auth_data);
let query_object = {limit: 10, domain: 'customer.dev', types: "accounts,distributionlists,aliases"};
api.directorySearch(query_object, function(err, data){
expect(data.more).to.equal(true);
expect(data.total).to.be.above(1);
expect(data.account.length).to.be.at.least(2);
done();
});
});
it('should modify Account attributes', function(done){ it('should modify Account attributes', function(done){
let api = new ZimbraAdminApi(auth_data); let api = new ZimbraAdminApi(auth_data);
let description = Date.now().toString(); let description = Date.now().toString();
...@@ -250,36 +221,6 @@ ...@@ -250,36 +221,6 @@
}); });
}); });
it('should modify Domain attributes', function(done){
let api = new ZimbraAdminApi(auth_data);
let description = Date.now().toString();
let attributes = {
description: description
};
api.getDomain('zboxapp.dev', function(err, data){
if (err) console.log(err);
api.modifyDomain(data.id, attributes, function(err, data){
expect(data.attrs.description).to.be.equal(description);
done();
});
});
});
it('should modify DistributionList attributes', function(done){
let api = new ZimbraAdminApi(auth_data);
let description = Date.now().toString();
let attributes = {
description: description
};
api.getDistributionList('abierta@customer.dev', function(err, data){
if (err) console.log(err);
api.modifyDistributionList(data.id, attributes, function(err, data){
expect(data.attrs.description).to.be.equal(description);
done();
});
});
});
it('should remove account', function(done){ it('should remove account', function(done){
let account_name = Date.now() + '@big.com'; let account_name = Date.now() + '@big.com';
let account_password = Date.now(); let account_password = Date.now();
...@@ -295,27 +236,69 @@ ...@@ -295,27 +236,69 @@
}); });
}); });
it('should remove Domain', function(done){ });
describe('Domain tests', function() {
it('should create and return Domain', function(done){
let resource_name = Date.now() + '.dev'; let resource_name = Date.now() + '.dev';
let resource_attributes = {}; let resource_attributes = {};
let api = new ZimbraAdminApi(auth_data); let api = new ZimbraAdminApi(auth_data);
api.createDomain(resource_name, resource_attributes, function(err, data){ api.createDomain(resource_name, resource_attributes, function(err, data){
if (err) return console.log(err); if (err) return console.log(err);
api.removeDomain(data.id, function(err, data){ expect(data.name).to.equal(resource_name);
if (err) return console.log(err); done();
expect(data._jsns).to.equal("urn:zimbraAdmin"); });
});
it('should return error "account.DOMAIN_EXISTS" if Domain Exists', function(done){
let resource_name = 'zboxapp.dev';
let resource_attributes = {};
let api = new ZimbraAdminApi(auth_data);
api.createDomain(resource_name, resource_attributes, function(err, data){
expect(err.extra.code).to.equal('account.DOMAIN_EXISTS');
done();
});
});
it('should create and return Domain with attributes', function(done){
let resource_name = Date.now() + '.dev';
let resource_attributes = {
zimbraSkinLogoURL: 'http://www.zboxapp.com',
postOfficeBox: 'ZBoxApp'
};
let api = new ZimbraAdminApi(auth_data);
let callback = function(err, data){
if (err) return console.log(err);
expect(data.attrs.zimbraSkinLogoURL).to.equal('http://www.zboxapp.com');
expect(data.attrs.postOfficeBox).to.equal('ZBoxApp');
done();
};
api.createDomain(resource_name, resource_attributes, callback);
});
it('should modify Domain attributes', function(done){
let api = new ZimbraAdminApi(auth_data);
let description = Date.now().toString();
let attributes = {
description: description
};
api.getDomain('zboxapp.dev', function(err, data){
if (err) console.log(err);
api.modifyDomain(data.id, attributes, function(err, data){
expect(data.attrs.description).to.be.equal(description);
done(); done();
}); });
}); });
}); });
it('should remove DL', function(done){ it('should remove Domain', function(done){
let resource_name = Date.now() + '@zboxapp.dev'; let resource_name = Date.now() + '.dev';
let resource_attributes = {}; let resource_attributes = {};
let api = new ZimbraAdminApi(auth_data); let api = new ZimbraAdminApi(auth_data);
api.createDistributionList(resource_name, resource_attributes, function(err, data){ api.createDomain(resource_name, resource_attributes, function(err, data){
if (err) return console.log(err); if (err) return console.log(err);
api.removeDistributionList(data.id, function(err, data){ api.removeDomain(data.id, function(err, data){
if (err) return console.log(err); if (err) return console.log(err);
expect(data._jsns).to.equal("urn:zimbraAdmin"); expect(data._jsns).to.equal("urn:zimbraAdmin");
done(); done();
...@@ -332,15 +315,6 @@ ...@@ -332,15 +315,6 @@
}); });
}); });
it('countAccounts hould return {} for empty Domain', function(done){
let api = new ZimbraAdminApi(auth_data);
api.countAccounts('juanitalapoderosa.com', function(err, data){
if (err) console.error(err);
expect(data).to.be.empty;
done();
});
});
it('domain.countAccounts() should return the counts', function(done){ it('domain.countAccounts() should return the counts', function(done){
let api = new ZimbraAdminApi(auth_data); let api = new ZimbraAdminApi(auth_data);
...@@ -367,4 +341,75 @@ ...@@ -367,4 +341,75 @@
}); });
}); });
describe('DistributionList tests', function() {
it('should remove DL', function(done){
let resource_name = Date.now() + '@zboxapp.dev';
let resource_attributes = {};
let api = new ZimbraAdminApi(auth_data);
api.createDistributionList(resource_name, resource_attributes, function(err, data){
if (err) return console.log(err);
api.removeDistributionList(data.id, function(err, data){
if (err) return console.log(err);
expect(data._jsns).to.equal("urn:zimbraAdmin");
done();
});
});
});
it('should modify DistributionList attributes', function(done){
let api = new ZimbraAdminApi(auth_data);
let description = Date.now().toString();
let attributes = {
description: description
};
api.getDistributionList('abierta@customer.dev', function(err, data){
if (err) console.log(err);
api.modifyDistributionList(data.id, attributes, function(err, data){
expect(data.attrs.description).to.be.equal(description);
done();
});
});
});
});
describe('Grants tests', function() {
it('should get the Grants with null target_data', function(done) {
let api = new ZimbraAdminApi(auth_data);
let grantee_data = {type: 'usr', identifier: 'domain_admin@customer.dev'};
api.getGrants(null, grantee_data, function(err, data){
if (err) console.log(err);
expect(data[0].constructor.name).to.equal('Grant');
expect(data[0].right._content).to.equal("domainAdminRights");
done();
});
});
it('should get the Grants with null grantee_data', function(done) {
let api = new ZimbraAdminApi(auth_data);
let target_data = {type: 'domain', identifier: 'customer.dev'};
api.getGrants(target_data, null, function(err, data){
if (err) console.log(err);
expect(data[0].constructor.name).to.equal('Grant');
expect(data[0].right._content).to.equal("domainAdminRights");
done();
});
});
it('should return Empty Array if no Grants', function(done) {
let api = new ZimbraAdminApi(auth_data);
let target_data = {type: 'domain', identifier: 'zboxapp.dev'};
api.getGrants(target_data, null, function(err, data){
if (err) console.log(err);
expect(data).to.be.empty;
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