Commit 9ab231e7 authored by Patricio Bruna's avatar Patricio Bruna

Delete the password and secret after authentication

parent 24f3d7f8
...@@ -19193,6 +19193,8 @@ var ZimbraAdminApi = ...@@ -19193,6 +19193,8 @@ var ZimbraAdminApi =
}; };
var that = this; var that = this;
this.client.auth(auth_object, function (err, response) { this.client.auth(auth_object, function (err, response) {
that.secret = null;
that.password = null;
if (err) return (callback || that.handleError)(err); if (err) return (callback || that.handleError)(err);
return (callback || that.handleResponse)(null, response); return (callback || that.handleResponse)(null, response);
}); });
...@@ -19298,8 +19300,18 @@ var ZimbraAdminApi = ...@@ -19298,8 +19300,18 @@ var ZimbraAdminApi =
} }
}, { }, {
key: 'getAccount', key: 'getAccount',
value: function getAccount(account, callback) { value: function getAccount(identifier, callback) {
this.get('Account', account, callback); this.get('Account', identifier, callback);
}
}, {
key: 'getDomain',
value: function getDomain(identifier, callback) {
this.get('Domain', identifier, callback);
}
}, {
key: 'getDistributionList',
value: function getDistributionList(identifier, callback) {
this.get('DistributionList', identifier, callback);
} }
}, { }, {
key: 'getAllDomains', key: 'getAllDomains',
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -71,6 +71,8 @@ class ZimbraAdminApi { ...@@ -71,6 +71,8 @@ class ZimbraAdminApi {
}; };
let that = this; let that = this;
this.client.auth(auth_object, function(err, response){ this.client.auth(auth_object, function(err, response){
that.secret = null;
that.password = null;
if (err) return (callback || that.handleError)(err); if (err) return (callback || that.handleError)(err);
return (callback || that.handleResponse)(null, response); return (callback || that.handleResponse)(null, response);
}); });
...@@ -162,8 +164,16 @@ class ZimbraAdminApi { ...@@ -162,8 +164,16 @@ class ZimbraAdminApi {
} }
} }
getAccount(account, callback) { getAccount(identifier, callback) {
this.get('Account', account, callback); this.get('Account', identifier, callback);
}
getDomain(identifier, callback) {
this.get('Domain', identifier, callback);
}
getDistributionList(identifier, callback) {
this.get('DistributionList', identifier, callback);
} }
getAllDomains(callback) { getAllDomains(callback) {
......
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
expect(error.title).to.equal('Internal Server Error'); expect(error.title).to.equal('Internal Server Error');
expect(error.extra.code).to.equal('account.AUTH_FAILED'); expect(error.extra.code).to.equal('account.AUTH_FAILED');
done(); done();
} };
api.login(callback); api.login(callback);
}); });
...@@ -56,6 +56,16 @@ ...@@ -56,6 +56,16 @@
let callback = function(err, response) { let callback = function(err, response) {
expect(api.client.token).to.exist; expect(api.client.token).to.exist;
done(); done();
};
api.login(callback);
});
it('should delete the password after authentication', function(done) {
let api = new ZimbraAdminApi(auth_data);
let callback = function(err, response) {
expect(api.secret).not.to.exist;
expect(api.password).not.to.exist;
done();
} }
api.login(callback); api.login(callback);
}); });
...@@ -106,6 +116,22 @@ ...@@ -106,6 +116,22 @@
}); });
}); });
it('should return an error if domain not found', function(done){
let api = new ZimbraAdminApi(auth_data);
api.getDomain('nuncajams.com', function(err, data){
expect(err.extra.code).to.equal('account.NO_SUCH_DOMAIN');
done();
});
});
it('should return the DL', function(done){
let api = new ZimbraAdminApi(auth_data);
api.getDistributionList('abierta@customer.dev', function(err, data){
expect(data.name).to.equal('abierta@customer.dev');
done();
});
});
// it('should get and return with name or id', function(done){ // it('should get and return with name or id', function(done){
// let api = new ZimbraAdminApi(auth_data); // let api = new ZimbraAdminApi(auth_data);
// let account_id = null; // let account_id = null;
......
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