Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
zimbra-admin-api-js
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Public
zimbra-admin-api-js
Commits
25c76025
Commit
25c76025
authored
Apr 25, 2016
by
Patricio Bruna
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Domains: Add/Remove Admins - DLs: Add/Remove Owners
parent
8a64acef
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
445 additions
and
74 deletions
+445
-74
README.md
README.md
+19
-0
TODOS.md
TODOS.md
+5
-5
zimbra-admin-api.js
lib/zimbra-admin-api.js
+267
-37
zimbra-admin-api.js.map
lib/zimbra-admin-api.js.map
+1
-1
package.json
package.json
+1
-1
index.js
src/index.js
+21
-22
dictionary.js
src/utils/dictionary.js
+27
-0
distribution_list.js
src/zimbra/distribution_list.js
+18
-0
domain.js
src/zimbra/domain.js
+12
-1
zimbra.js
src/zimbra/zimbra.js
+6
-7
test.js
test/js/spec/test.js
+68
-0
No files found.
README.md
View file @
25c76025
...
...
@@ -351,6 +351,15 @@ domain.countAccounts(callback);
If the
`Domain`
is empty, no 'Accounts', the result will be a
`{}`
.
### Add / Remove Admin
```
javascript
domain
.
addAdmin
(
'new_member@example.com'
,
callback
);
// {} if Success
domain
.
removeAdmin
(
'new_member@example.com'
,
callback
);
// {} if Success
```
### Domain Admins
Return an Array of the Domain Admins
`Accounts`
.
...
...
@@ -387,6 +396,16 @@ dl.removeMembers(['1@example.com', '2@example.com'], callback);
// Return Error if any of the emails isn't a member
```
### Add / Remove Owner
```
javascript
dl
.
addOwner
(
'new_member@example.com'
,
callback
);
// {} if Success
dl
.
removeOwner
(
'new_member@example.com'
,
callback
);
// {} if Success
```
### Get Owners
Owners are the Zimbra emails addresses that are allowed to send emails to the
`DL`
.
If a
`DL`
has at least one
`Owener`
is a
**Private DL**
.
...
...
TODOS.md
View file @
25c76025
...
...
@@ -11,15 +11,15 @@
## DistributionList
*
[
]
Listas privadas
*
[
]
Toda su gestion
*
[
X
]
Listas privadas
*
[
X
]
Toda su gestion
## Domains
*
[
]
Add y remove Admins
*
[
X
]
Add y remove Admins
*
[
]
Devolver Tipo de renovación
*
[
]
Devolver Empresa (esto entiendo necesitamos otro API)
*
[
X
]
Devolver Tipo de renovación
*
[
X
]
Devolver Empresa (esto entiendo necesitamos otro API)
*
[
X
]
Devolver casillas segun el tipo de plan, cantidad asignadas y cantidad utilizadas para un dominio
*
[
X
]
Limite de casillas
*
[
X
]
Devolver Fecha de la proxima renovación
...
...
lib/zimbra-admin-api.js
View file @
25c76025
...
...
@@ -71,6 +71,10 @@ return /******/ (function(modules) { // webpackBootstrap
var _typeof3 = _interopRequireDefault(_typeof2);
var _slicedToArray2 = __webpack_require__(285);
var _slicedToArray3 = _interopRequireDefault(_slicedToArray2);
var _classCallCheck2 = __webpack_require__(68);
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
...
...
@@ -370,23 +374,22 @@ return /******/ (function(modules) { // webpackBootstrap
key: 'grantRight',
value: function grantRight(target_data, grantee_data, right_name, callback) {
var request_data = {};
var _dictionary$buildTarg = this.dictionary.buildTargetGrantee(target_data, grantee_data);
var _dictionary$buildTarg2 = (0, _slicedToArray3.default)(_dictionary$buildTarg, 2);
var target = _dictionary$buildTarg2[0];
var grantee = _dictionary$buildTarg2[1];
request_data.params = this.requestParams();
request_data.request_name = 'GrantRight';
request_data.params.name = request_data.request_name + 'Request';
request_data.response_name = request_data.request_name + 'Response';
request_data.callback = callback;
request_data.parse_response = this.parseEmptyResponse;
if (target_data) request_data.params.params.target = {
'type': target_data.type,
'by': this.dictionary.byIdOrName(target_data.identifier),
'_content': target_data.identifier
};
if (grantee_data) request_data.params.params.grantee = {
'type': grantee_data.type,
'by': this.dictionary.byIdOrName(grantee_data.identifier),
'all': 1,
'_content': grantee_data.identifier
};
request_data.params.params.grantee = grantee;
request_data.params.params.target = target;
request_data.params.params.right = { '_content': right_name };
this.performRequest(request_data);
}
...
...
@@ -536,6 +539,14 @@ return /******/ (function(modules) { // webpackBootstrap
key: 'getGrants',
value: function getGrants(target_data, grantee_data, callback) {
var request_data = {};
var _dictionary$buildTarg3 = this.dictionary.buildTargetGrantee(target_data, grantee_data);
var _dictionary$buildTarg4 = (0, _slicedToArray3.default)(_dictionary$buildTarg3, 2);
var target = _dictionary$buildTarg4[0];
var grantee = _dictionary$buildTarg4[1];
var resource = 'Grant';
request_data.params = this.requestParams();
request_data.request_name = 'Get' + resource + 's';
...
...
@@ -544,17 +555,8 @@ return /******/ (function(modules) { // webpackBootstrap
request_data.callback = callback;
request_data.resource = resource;
request_data.parse_response = this.parseAllResponse;
if (target_data) request_data.params.params.target = {
'type': target_data.type,
'by': this.dictionary.byIdOrName(target_data.identifier),
'_content': target_data.identifier
};
if (grantee_data) request_data.params.params.grantee = {
'type': grantee_data.type,
'by': this.dictionary.byIdOrName(grantee_data.identifier),
'all': 1,
'_content': grantee_data.identifier
};
request_data.params.params.grantee = grantee;
request_data.params.params.target = target;
this.performRequest(request_data);
}
...
...
@@ -670,6 +672,29 @@ return /******/ (function(modules) { // webpackBootstrap
request_data.params.params = { id: dl_id, dlm: this.dictionary.convertToZimbraArray(members) };
this.performRequest(request_data);
}
}, {
key: 'revokeRight',
value: function revokeRight(target_data, grantee_data, right_name, callback) {
var request_data = {};
var _dictionary$buildTarg5 = this.dictionary.buildTargetGrantee(target_data, grantee_data);
var _dictionary$buildTarg6 = (0, _slicedToArray3.default)(_dictionary$buildTarg5, 2);
var target = _dictionary$buildTarg6[0];
var grantee = _dictionary$buildTarg6[1];
request_data.params = this.requestParams();
request_data.request_name = 'RevokeRight';
request_data.params.name = request_data.request_name + 'Request';
request_data.response_name = request_data.request_name + 'Response';
request_data.callback = callback;
request_data.parse_response = this.parseEmptyResponse;
request_data.params.params.grantee = grantee;
request_data.params.params.target = target;
request_data.params.params.right = { '_content': right_name };
this.performRequest(request_data);
}
// Search the Directory
// search_object = {
...
...
@@ -12432,6 +12457,35 @@ return /******/ (function(modules) { // webpackBootstrap
});
return result;
}
}, {
key: 'buildTargetGrantee',
value: function buildTargetGrantee(target_data, grantee_data) {
var target = null,
grantee = null;
if (target_data) target = {
'type': target_data.type,
'by': this.byIdOrName(target_data.identifier),
'_content': target_data.identifier
};
if (grantee_data) grantee = {
'type': grantee_data.type,
'by': this.byIdOrName(grantee_data.identifier),
'all': 1,
'_content': grantee_data.identifier
};
return [target, grantee];
}
}, {
key: 'buildGranteeData',
value: function buildGranteeData(grantee_id, type) {
return {
'type': type,
'by': this.byIdOrName(grantee_id),
'all': 1,
'_content': grantee_id,
'identifier': grantee_id
};
}
}, {
key: 'classFactory',
value: function classFactory(resource, object, client) {
...
...
@@ -13282,7 +13336,10 @@ return /******/ (function(modules) { // webpackBootstrap
(0, _createClass3.default)(Domain, [{
key: 'addAdmin',
value: function addAdmin(account_id, callback) {
var grantee_data = this.buildGranteeData(account_id, 'Account');
var grantee_data = {
'type': 'usr',
'identifier': account_id
};
this.grantRight(grantee_data, this.domainAdminRights, callback);
}
...
...
@@ -13360,6 +13417,15 @@ return /******/ (function(modules) { // webpackBootstrap
});
return results;
}
}, {
key: 'removeAdmin',
value: function removeAdmin(account_id, callback) {
var grantee_data = {
'type': 'usr',
'identifier': account_id
};
this.revokeRight(grantee_data, this.domainAdminRights, callback);
}
}]);
return Domain;
}(_zimbra2.default); // Copyright (c) 2016 ZBox, Spa. All Rights Reserved.
...
...
@@ -13593,7 +13659,7 @@ return /******/ (function(modules) { // webpackBootstrap
/* 113 */
/***/ function(module, exports, __webpack_require__) {
'use strict'
;
"use strict"
;
Object.defineProperty(exports, "__esModule", {
value: true
...
...
@@ -13623,7 +13689,7 @@ return /******/ (function(modules) { // webpackBootstrap
}
(0, _createClass3.default)(Zimbra, [{
key:
'buildAttrsMap'
,
key:
"buildAttrsMap"
,
value: function buildAttrsMap(obj_ary) {
var attrs = {};
obj_ary.forEach(function (r) {
...
...
@@ -13638,23 +13704,18 @@ return /******/ (function(modules) { // webpackBootstrap
return attrs;
}
}, {
key:
'buildRighTargetData'
,
key:
"buildRighTargetData"
,
value: function buildRighTargetData() {
var type = this.api.dictionary.classNameToZimbraType(this.constructor.name);
return { type: type, identifier: this.id };
}
}, {
key: 'buildGranteeData',
value: function buildGranteeData(object_id, type) {
return {
'type': type,
'by': this.api.dictionary.byIdOrName(object_id),
'all': 1,
'_content': object_id
};
key: "buildGranteeData",
value: function buildGranteeData(grantee_id, type) {
return this.api.dictionary.buildGranteeData(grantee_id, type);
}
}, {
key:
'parseACL'
,
key:
"parseACL"
,
value: function parseACL(acls) {
var elements = [].concat.apply([], [acls]);
var grantees = {};
...
...
@@ -13668,7 +13729,7 @@ return /******/ (function(modules) { // webpackBootstrap
// return ACLS for the Object
}, {
key:
'getACLs'
,
key:
"getACLs"
,
value: function getACLs(callback) {
if (this.grants) return callback(null, this.grants);
var that = this;
...
...
@@ -13679,10 +13740,15 @@ return /******/ (function(modules) { // webpackBootstrap
});
}
}, {
key:
'grantRight'
,
key:
"grantRight"
,
value: function grantRight(grantee_data, right_name, callback) {
this.api.grantRight(this.buildRighTargetData(), grantee_data, right_name, callback);
}
}, {
key: "revokeRight",
value: function revokeRight(grantee_data, right_name, callback) {
this.api.revokeRight(this.buildRighTargetData(), grantee_data, right_name, callback);
}
}]);
return Zimbra;
}();
...
...
@@ -13952,6 +14018,7 @@ return /******/ (function(modules) { // webpackBootstrap
var _this = (0, _possibleConstructorReturn3.default)(this, (0, _getPrototypeOf2.default)(DistributionList).call(this, dl_obj, zimbra_api_client));
_this.members = _this.parseMembers(dl_obj);
_this.ownerRights = 'sendToDistList';
return _this;
}
...
...
@@ -13963,6 +14030,15 @@ return /******/ (function(modules) { // webpackBootstrap
value: function addMembers(members, callback) {
this.api.addDistributionListMember(this.id, members, callback);
}
}, {
key: 'addOwner',
value: function addOwner(account_id, callback) {
var grantee_data = {
'type': 'usr',
'identifier': account_id
};
this.grantRight(grantee_data, this.ownerRights, callback);
}
// return the ID of the owner
...
...
@@ -14010,6 +14086,15 @@ return /******/ (function(modules) { // webpackBootstrap
value: function removeMembers(members, callback) {
this.api.removeDistributionListMember(this.id, members, callback);
}
}, {
key: 'removeOwner',
value: function removeOwner(account_id, callback) {
var grantee_data = {
'type': 'usr',
'identifier': account_id
};
this.revokeRight(grantee_data, this.ownerRights, callback);
}
}]);
return DistributionList;
}(_zimbra2.default); // Copyright (c) 2016 ZBox, Spa. All Rights Reserved.
...
...
@@ -41045,6 +41130,151 @@ return /******/ (function(modules) { // webpackBootstrap
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(145).Buffer))
/***/ },
/* 285 */
/***/ function(module, exports, __webpack_require__) {
/*** IMPORTS FROM imports-loader ***/
var $ = __webpack_require__(3);
var jQuery = __webpack_require__(3);
"use strict";
exports.__esModule = true;
var _isIterable2 = __webpack_require__(286);
var _isIterable3 = _interopRequireDefault(_isIterable2);
var _getIterator2 = __webpack_require__(289);
var _getIterator3 = _interopRequireDefault(_getIterator2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = function () {
function sliceIterator(arr, i) {
var _arr = [];
var _n = true;
var _d = false;
var _e = undefined;
try {
for (var _i = (0, _getIterator3.default)(arr), _s; !(_n = (_s = _i.next()).done); _n = true) {
_arr.push(_s.value);
if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
} finally {
try {
if (!_n && _i["return"]) _i["return"]();
} finally {
if (_d) throw _e;
}
}
return _arr;
}
return function (arr, i) {
if (Array.isArray(arr)) {
return arr;
} else if ((0, _isIterable3.default)(Object(arr))) {
return sliceIterator(arr, i);
} else {
throw new TypeError("Invalid attempt to destructure non-iterable instance");
}
};
}();
/***/ },
/* 286 */
/***/ function(module, exports, __webpack_require__) {
/*** IMPORTS FROM imports-loader ***/
var $ = __webpack_require__(3);
var jQuery = __webpack_require__(3);
module.exports = { "default": __webpack_require__(287), __esModule: true };
/***/ },
/* 287 */
/***/ function(module, exports, __webpack_require__) {
/*** IMPORTS FROM imports-loader ***/
var $ = __webpack_require__(3);
var jQuery = __webpack_require__(3);
__webpack_require__(51);
__webpack_require__(7);
module.exports = __webpack_require__(288);
/***/ },
/* 288 */
/***/ function(module, exports, __webpack_require__) {
/*** IMPORTS FROM imports-loader ***/
var $ = __webpack_require__(3);
var jQuery = __webpack_require__(3);
var classof = __webpack_require__(92)
, ITERATOR = __webpack_require__(48)('iterator')
, Iterators = __webpack_require__(30);
module.exports = __webpack_require__(15).isIterable = function(it){
var O = Object(it);
return O[ITERATOR] !== undefined
|| '@@iterator' in O
|| Iterators.hasOwnProperty(classof(O));
};
/***/ },
/* 289 */
/***/ function(module, exports, __webpack_require__) {
/*** IMPORTS FROM imports-loader ***/
var $ = __webpack_require__(3);
var jQuery = __webpack_require__(3);
module.exports = { "default": __webpack_require__(290), __esModule: true };
/***/ },
/* 290 */
/***/ function(module, exports, __webpack_require__) {
/*** IMPORTS FROM imports-loader ***/
var $ = __webpack_require__(3);
var jQuery = __webpack_require__(3);
__webpack_require__(51);
__webpack_require__(7);
module.exports = __webpack_require__(291);
/***/ },
/* 291 */
/***/ function(module, exports, __webpack_require__) {
/*** IMPORTS FROM imports-loader ***/
var $ = __webpack_require__(3);
var jQuery = __webpack_require__(3);
var anObject = __webpack_require__(20)
, get = __webpack_require__(91);
module.exports = __webpack_require__(15).getIterator = function(it){
var iterFn = get(it);
if(typeof iterFn != 'function')throw TypeError(it + ' is not iterable!');
return anObject(iterFn.call(it));
};
/***/ }
/******/ ])
});
lib/zimbra-admin-api.js.map
View file @
25c76025
This source diff could not be displayed because it is too large. You can
view the blob
instead.
package.json
View file @
25c76025
{
"name"
:
"zimbra-admin-api-js"
,
"version"
:
"0.0.1
4
"
,
"version"
:
"0.0.1
5
"
,
"private"
:
true
,
"main"
:
"lib/zimbra-admin-api.js"
,
"dependencies"
:
{
...
...
src/index.js
View file @
25c76025
...
...
@@ -262,23 +262,15 @@ export default class ZimbraAdminApi {
// }
grantRight
(
target_data
,
grantee_data
,
right_name
,
callback
)
{
const
request_data
=
{
};
const
[
target
,
grantee
]
=
this
.
dictionary
.
buildTargetGrantee
(
target_data
,
grantee_data
);
request_data
.
params
=
this
.
requestParams
();
request_data
.
request_name
=
'GrantRight'
;
request_data
.
params
.
name
=
`
${
request_data
.
request_name
}
Request`
;
request_data
.
response_name
=
`
${
request_data
.
request_name
}
Response`
;
request_data
.
callback
=
callback
;
request_data
.
parse_response
=
this
.
parseEmptyResponse
;
if
(
target_data
)
request_data
.
params
.
params
.
target
=
{
'type'
:
target_data
.
type
,
'by'
:
this
.
dictionary
.
byIdOrName
(
target_data
.
identifier
),
'_content'
:
target_data
.
identifier
};
if
(
grantee_data
)
request_data
.
params
.
params
.
grantee
=
{
'type'
:
grantee_data
.
type
,
'by'
:
this
.
dictionary
.
byIdOrName
(
grantee_data
.
identifier
),
'all'
:
1
,
'_content'
:
grantee_data
.
identifier
};
request_data
.
params
.
params
.
grantee
=
grantee
;
request_data
.
params
.
params
.
target
=
target
;
request_data
.
params
.
params
.
right
=
{
'_content'
:
right_name
};
this
.
performRequest
(
request_data
);
}
...
...
@@ -399,6 +391,7 @@ export default class ZimbraAdminApi {
// }
getGrants
(
target_data
,
grantee_data
,
callback
)
{
const
request_data
=
{
};
const
[
target
,
grantee
]
=
this
.
dictionary
.
buildTargetGrantee
(
target_data
,
grantee_data
);
const
resource
=
'Grant'
;
request_data
.
params
=
this
.
requestParams
();
request_data
.
request_name
=
`Get
${
resource
}
s`
;
...
...
@@ -407,17 +400,8 @@ export default class ZimbraAdminApi {
request_data
.
callback
=
callback
;
request_data
.
resource
=
resource
;
request_data
.
parse_response
=
this
.
parseAllResponse
;
if
(
target_data
)
request_data
.
params
.
params
.
target
=
{
'type'
:
target_data
.
type
,
'by'
:
this
.
dictionary
.
byIdOrName
(
target_data
.
identifier
),
'_content'
:
target_data
.
identifier
};
if
(
grantee_data
)
request_data
.
params
.
params
.
grantee
=
{
'type'
:
grantee_data
.
type
,
'by'
:
this
.
dictionary
.
byIdOrName
(
grantee_data
.
identifier
),
'all'
:
1
,
'_content'
:
grantee_data
.
identifier
};
request_data
.
params
.
params
.
grantee
=
grantee
;
request_data
.
params
.
params
.
target
=
target
;
this
.
performRequest
(
request_data
);
}
...
...
@@ -507,6 +491,21 @@ export default class ZimbraAdminApi {
this
.
performRequest
(
request_data
);
}
revokeRight
(
target_data
,
grantee_data
,
right_name
,
callback
)
{
const
request_data
=
{
};
const
[
target
,
grantee
]
=
this
.
dictionary
.
buildTargetGrantee
(
target_data
,
grantee_data
);
request_data
.
params
=
this
.
requestParams
();
request_data
.
request_name
=
'RevokeRight'
;
request_data
.
params
.
name
=
`
${
request_data
.
request_name
}
Request`
;
request_data
.
response_name
=
`
${
request_data
.
request_name
}
Response`
;
request_data
.
callback
=
callback
;
request_data
.
parse_response
=
this
.
parseEmptyResponse
;
request_data
.
params
.
params
.
grantee
=
grantee
;
request_data
.
params
.
params
.
target
=
target
;
request_data
.
params
.
params
.
right
=
{
'_content'
:
right_name
};
this
.
performRequest
(
request_data
);
}
// Search the Directory
// search_object = {
// query: An LDAP query or null for everything,
...
...
src/utils/dictionary.js
View file @
25c76025
...
...
@@ -37,6 +37,33 @@ export default class Dictionary {
return
result
;
}
buildTargetGrantee
(
target_data
,
grantee_data
)
{
let
target
=
null
,
grantee
=
null
;
if
(
target_data
)
target
=
{
'type'
:
target_data
.
type
,
'by'
:
this
.
byIdOrName
(
target_data
.
identifier
),
'_content'
:
target_data
.
identifier
}
if
(
grantee_data
)
grantee
=
{
'type'
:
grantee_data
.
type
,
'by'
:
this
.
byIdOrName
(
grantee_data
.
identifier
),
'all'
:
1
,
'_content'
:
grantee_data
.
identifier
};
return
([
target
,
grantee
]);
}
buildGranteeData
(
grantee_id
,
type
)
{
return
{
'type'
:
type
,
'by'
:
this
.
byIdOrName
(
grantee_id
),
'all'
:
1
,
'_content'
:
grantee_id
,
'identifier'
:
grantee_id
};
}
classFactory
(
resource
,
object
,
client
)
{
const
class_name
=
this
.
resourceToClass
(
resource
.
toLowerCase
());
return
new
class_name
(
object
,
client
);
...
...
src/zimbra/distribution_list.js
View file @
25c76025
...
...
@@ -7,6 +7,7 @@ export default class DistributionList extends Zimbra {
constructor
(
dl_obj
,
zimbra_api_client
)
{
super
(
dl_obj
,
zimbra_api_client
);
this
.
members
=
this
.
parseMembers
(
dl_obj
);
this
.
ownerRights
=
'sendToDistList'
;
}
// Add members to DL
...
...
@@ -14,6 +15,14 @@ export default class DistributionList extends Zimbra {
this
.
api
.
addDistributionListMember
(
this
.
id
,
members
,
callback
);
}
addOwner
(
account_id
,
callback
)
{
const
grantee_data
=
{
'type'
:
'usr'
,
'identifier'
:
account_id
}
this
.
grantRight
(
grantee_data
,
this
.
ownerRights
,
callback
);
}
// return the ID of the owner
getOwners
(
callback
)
{
if
(
this
.
owners
)
return
callback
(
null
,
this
.
owners
);
...
...
@@ -53,4 +62,13 @@ export default class DistributionList extends Zimbra {
this
.
api
.
removeDistributionListMember
(
this
.
id
,
members
,
callback
);
}
removeOwner
(
account_id
,
callback
)
{
const
grantee_data
=
{
'type'
:
'usr'
,
'identifier'
:
account_id
}
this
.
revokeRight
(
grantee_data
,
this
.
ownerRights
,
callback
);
}
}
src/zimbra/domain.js
View file @
25c76025
...
...
@@ -10,7 +10,10 @@ export default class Domain extends Zimbra {
}
addAdmin
(
account_id
,
callback
)
{
const
grantee_data
=
this
.
buildGranteeData
(
account_id
,
'Account'
);
const
grantee_data
=
{
'type'
:
'usr'
,
'identifier'
:
account_id
}
this
.
grantRight
(
grantee_data
,
this
.
domainAdminRights
,
callback
);
}
...
...
@@ -80,4 +83,12 @@ export default class Domain extends Zimbra {
return
results
;
}
removeAdmin
(
account_id
,
callback
)
{
const
grantee_data
=
{
'type'
:
'usr'
,
'identifier'
:
account_id
}
this
.
revokeRight
(
grantee_data
,
this
.
domainAdminRights
,
callback
);
}
}
src/zimbra/zimbra.js
View file @
25c76025
...
...
@@ -28,13 +28,8 @@ export default class Zimbra {
return
{
type
:
type
,
identifier
:
this
.
id
};
}
buildGranteeData
(
object_id
,
type
)
{
return
{
'type'
:
type
,
'by'
:
this
.
api
.
dictionary
.
byIdOrName
(
object_id
),
'all'
:
1
,
'_content'
:
object_id
};
buildGranteeData
(
grantee_id
,
type
)
{
return
this
.
api
.
dictionary
.
buildGranteeData
(
grantee_id
,
type
);
}
parseACL
(
acls
)
{
...
...
@@ -62,4 +57,8 @@ export default class Zimbra {
this
.
api
.
grantRight
(
this
.
buildRighTargetData
(),
grantee_data
,
right_name
,
callback
);
}
revokeRight
(
grantee_data
,
right_name
,
callback
){
this
.
api
.
revokeRight
(
this
.
buildRighTargetData
(),
grantee_data
,
right_name
,
callback
);
}
}
test/js/spec/test.js
View file @
25c76025
...
...
@@ -456,7 +456,41 @@
});
});
it
(
'addAdmin should add Admin'
,
function
(
done
){
let
api
=
new
ZimbraAdminApi
(
auth_data
);
let
domain_admin
=
'domain_admin@customer.dev'
;
let
resource_name
=
Date
.
now
()
+
'.dev'
;
api
.
createDomain
(
resource_name
,
{},
function
(
err
,
data
){
if
(
err
)
console
.
error
(
err
);
let
domain
=
data
;
domain
.
addAdmin
(
domain_admin
,
function
(
e
,
d
){
if
(
e
)
return
console
.
error
(
e
);
expect
(
err
).
to
.
be
.
null
;
domain
.
getACLs
(
function
(
e
,
d
){
if
(
e
)
return
console
.
error
(
e
);
expect
(
d
[
0
].
grantee
.
name
).
to
.
be
.
equal
(
domain_admin
);
done
();
});
});
});
});
it
(
'removeAdmin should remove the Admin'
,
function
(
done
){
let
api
=
new
ZimbraAdminApi
(
auth_data
);
let
domain_admin
=
'domain_admin@customer.dev'
;
let
resource_name
=
Date
.
now
()
+
'.dev'
;
api
.
createDomain
(
resource_name
,
{},
function
(
err
,
domain
){
domain
.
addAdmin
(
domain_admin
,
function
(
e
,
d
){
domain
.
removeAdmin
(
domain_admin
,
function
(
e
,
d
){
domain
.
getACLs
(
function
(
e
,
d
){
if
(
e
)
return
console
.
error
(
e
);
expect
(
d
.
length
).
to
.
be
.
equal
(
0
);
done
();
});
});
});
});
});
});
...
...
@@ -554,6 +588,40 @@
});
});
it
(
'addOwner should add Owner'
,
function
(
done
){
let
api
=
new
ZimbraAdminApi
(
auth_data
);
let
owner_email
=
'domain_admin@customer.dev'
;
let
resource_name
=
Date
.
now
()
+
'@customer.dev'
;
api
.
createDistributionList
(
resource_name
,
{},
function
(
err
,
dl
){
dl
.
addOwner
(
owner_email
,
function
(
e
,
d
){
if
(
e
)
return
console
.
error
(
e
);
expect
(
err
).
to
.
be
.
null
;
dl
.
getACLs
(
function
(
e
,
d
){
if
(
e
)
return
console
.
error
(
e
);
expect
(
d
[
0
].
grantee
.
name
).
to
.
be
.
equal
(
owner_email
);
done
();
});
});
});
});
it
(
'removeOwner should remove the Owner'
,
function
(
done
){
let
api
=
new
ZimbraAdminApi
(
auth_data
);
let
owner_email
=
'domain_admin@customer.dev'
;
let
resource_name
=
Date
.
now
()
+
'@customer.dev'
;
api
.
createDistributionList
(
resource_name
,
{},
function
(
err
,
dl
){
dl
.
addOwner
(
owner_email
,
function
(
e
,
d
){
dl
.
removeOwner
(
owner_email
,
function
(
e
,
d
){
dl
.
getACLs
(
function
(
e
,
d
){
if
(
e
)
return
console
.
error
(
e
);
expect
(
d
.
length
).
to
.
be
.
equal
(
0
);
done
();
});
});
});
});
});
});
describe
(
'Grants tests'
,
function
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment