TT#5036 Add method removeAllTokens

Change-Id: Ieb34cdfac19e9bb5a0aec6799c4ccc175d7864f5
changes/18/9218/1
Hans-Peter Herzog 10 years ago
parent 53d1c92e7b
commit cfeaecd642

@ -98,3 +98,11 @@ Methods (token based authentication)
}).catch((err)=>{
...
});
### Remove all tokens
adminClient.removeAllTokens().then((res)=>{
...
}).catch((err)=>{
...
});

@ -229,6 +229,22 @@ class Admin {
});
}
removeAllTokens() {
return new Promise((resolve, reject)=>{
this.listTokens().then((res)=>{
var tokenRemovePromises = [];
_.forEach(res.tokens, (token)=>{
tokenRemovePromises.push(this.removeToken(token.token));
});
return Promise.all(tokenRemovePromises);
}).then(()=>{
resolve();
}).catch((err)=>{
reject(err);
});
});
}
}
module.exports.JanusAdmin = Admin;

@ -176,7 +176,15 @@ describe('Admin', function() {
});
it('should remove a token', function(done){
adminClient.removeToken(exampleToken).then((res)=>{
adminClient.removeToken(exampleToken).then(()=>{
done();
}).catch((err)=>{
done(err);
});
});
it('should remove all tokens', function(done){
adminClient.removeAllTokens().then(()=>{
done();
}).catch((err)=>{
done(err);

Loading…
Cancel
Save