Commit 3fbf7446 authored by Patricio Bruna's avatar Patricio Bruna

Added info is its an Alias Domain

parent df190744
{
"esnext": true
"esnext": true,
"node": true,
"predef": [ "describe", "it", "beforeEach", "afterEach" ]
}
......@@ -389,6 +389,20 @@ zimbraApi.getAllCos(callback);
## Domains
This are functions especifics to `Domains`.
### isAliasDomain & masterDomainName
These are `properties`, **not functions**.
* `isAliasDomain`, return if a Domain is an Alias Domain.
* `masterDomainName`, return the name of the master domain.
```
domain.isAliasDomain
// true || false
domain.masterDomainName
// example.com
```
### Count Accounts
Count number of accounts by `CoS` in a domain.
......
......@@ -30748,7 +30748,7 @@ return /******/ (function(modules) { // webpackBootstrap
module.exports = {
"name": "zimbra-admin-api-js",
"version": "0.2.8",
"version": "0.2.9",
"main": "lib/zimbra-admin-api.js",
"dependencies": {
"crypto-browserify": "^3.11.0",
......@@ -31759,6 +31759,7 @@ return /******/ (function(modules) { // webpackBootstrap
var _this = (0, _possibleConstructorReturn3.default)(this, (0, _getPrototypeOf2.default)(Domain).call(this, domain_obj, zimbra_api_client));
_this.domainAdminRights = 'domainAdminRights';
_this.checkAliasDomain();
return _this;
}
......@@ -31831,6 +31832,16 @@ return /******/ (function(modules) { // webpackBootstrap
});
return requests;
}
}, {
key: 'checkAliasDomain',
value: function checkAliasDomain() {
this.isAliasDomain = this.attrs.zimbraDomainType === 'alias' ? true : false;
if (this.isAliasDomain) {
var masterDomain = this.attrs.zimbraMailCatchAllForwardingAddress;
this.masterDomainName = masterDomain.split(/@/)[1];
}
return true;
}
// TODO: Fix this fucking ugly code
......
{
"name": "zimbra-admin-api-js",
"version": "0.2.8",
"version": "0.2.9",
"main": "lib/zimbra-admin-api.js",
"dependencies": {
"crypto-browserify": "^3.11.0",
......
......@@ -9,11 +9,12 @@ class Domain extends Zimbra {
constructor(domain_obj, zimbra_api_client) {
super(domain_obj, zimbra_api_client);
this.domainAdminRights = 'domainAdminRights';
this.checkAliasDomain();
}
// TODO: Too ugly code
addAdmin(account_id, coses = [], callback) {
const grantee_data = { 'type': 'usr', 'identifier': account_id };
const grantee_data = { 'type': 'usr', 'identifier': account_id };
this.addDelegatedAttributeToAccount(account_id, (err,data) => {
if (err) return callback(err);
this.grantRight(grantee_data, this.domainAdminRights, (err, data) => {
......@@ -22,14 +23,14 @@ class Domain extends Zimbra {
});
});
}
addDelegatedAttributeToAccount(account_id, callback) {
this.api.modifyAccount(account_id, { zimbraIsDelegatedAdminAccount: 'TRUE' }, (err, data) => {
if (err) return callback(err);
return callback(null, data);
});
}
// This functions add the rights to the domain admin
// to be able to change the accounts cos
assignCosRights(grantee_data, coses, callback, revoke = false) {
......@@ -49,7 +50,7 @@ class Domain extends Zimbra {
const target_data = { type: 'cos', identifier: c };
let grant = null;
if (revoke) {
grant = this.api.revokeRight(target_data, grantee_data, 'assignCos');
grant = this.api.revokeRight(target_data, grantee_data, 'assignCos');
} else {
grant = this.api.grantRight(target_data, grantee_data, 'assignCos');
}
......@@ -58,6 +59,15 @@ class Domain extends Zimbra {
return requests;
}
checkAliasDomain() {
this.isAliasDomain = this.attrs.zimbraDomainType === 'alias' ? true : false;
if (this.isAliasDomain) {
const masterDomain = this.attrs.zimbraMailCatchAllForwardingAddress;
this.masterDomainName = masterDomain.split(/@/)[1];
}
return true;
}
// TODO: Fix this fucking ugly code
getAdmins(callback) {
const that = this;
......
......@@ -384,6 +384,26 @@
describe('Domain tests', function() {
this.timeout(5000);
it('Should return if the domain is an alias Domain', function(done){
let api = new ZimbraAdminApi(auth_data);
api.getDomain('reseller.alias', function(err, data){
if (err) return console.log(err);
expect(data.isAliasDomain).to.be.true;
expect(data.masterDomainName).to.be.equal('reseller.dev');
done();
});
});
it('Should return false if the domain is not an alias Domain', function(done){
let api = new ZimbraAdminApi(auth_data);
api.getDomain('reseller.dev', function(err, data){
if (err) return console.log(err);
expect(data.isAliasDomain).to.be.false;
expect(data.masterDomainName).to.be.undefined;
done();
});
});
it('should create and return Domain', function(done){
let resource_name = Date.now() + '.dev';
let resource_attributes = {};
......@@ -523,7 +543,6 @@
it('addAdmin should add Admin', function(done){
let api = new ZimbraAdminApi(auth_data);
let domain_admin = Date.now() + '@customer.dev';
let resource_name = Date.now() + '.dev';
api.createAccount(domain_admin, '12dda.222', {}, function(err, account){
......
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