js: importKey feedback refactor
-- * src/Keyring.js: An empty result should no longer cause an error, the import feedback summary has been refactored slightly * Browsertests to reflect import feedback change
This commit is contained in:
parent
d65a392670
commit
90cb4a6842
@ -71,10 +71,13 @@ describe('Key importing', function () {
|
||||
expect(result).to.be.an('array');
|
||||
expect(result.length).to.equal(0);
|
||||
context.Keyring.importKey(pubKey).then(function(result){
|
||||
expect(result[0]).to.not.be.undefined;
|
||||
expect(result[0].key).to.be.an('object');
|
||||
expect(result[0].key.fingerprint).to.equal(fpr);
|
||||
expect(result[0].status).to.equal('newkey');
|
||||
expect(result.Keys).to.be.an('array');
|
||||
expect(result.Keys[0]).to.not.be.undefined;
|
||||
expect(result.Keys[0].key).to.be.an('object');
|
||||
expect(result.Keys[0].key.fingerprint).to.equal(fpr);
|
||||
expect(result.Keys[0].status).to.equal('newkey');
|
||||
expect(result.summary.considered).to.equal(1);
|
||||
expect(result.summary.imported).to.equal(1);
|
||||
done();
|
||||
});
|
||||
});
|
||||
@ -83,15 +86,16 @@ describe('Key importing', function () {
|
||||
it('Updating Key', function(done){
|
||||
context.Keyring.importKey(pubKey)
|
||||
.then(function(result){
|
||||
expect(result[0].key).to.not.be.undefined;
|
||||
expect(result[0].status).to.equal('newkey');
|
||||
expect(result.Keys[0].key).to.not.be.undefined;
|
||||
expect(result.Keys[0].status).to.equal('newkey');
|
||||
context.Keyring.importKey(changedKey).then(function(res){
|
||||
expect(res[0].key).to.be.an('object');
|
||||
expect(res[0].key.fingerprint).to.equal(fpr);
|
||||
expect(res[0].status).to.equal('change');
|
||||
expect(res[0].changes.userId).to.be.true;
|
||||
expect(res[0].changes.subkey).to.be.false;
|
||||
expect(res[0].changes.signature).to.be.true;
|
||||
expect(res.Keys[0].key).to.be.an('object');
|
||||
expect(res.Keys[0].key.fingerprint).to.equal(fpr);
|
||||
expect(res.Keys[0].status).to.equal('change');
|
||||
expect(res.Keys[0].changes.userId).to.be.true;
|
||||
expect(res.Keys[0].changes.subkey).to.be.false;
|
||||
expect(res.Keys[0].changes.signature).to.be.true;
|
||||
expect(res.summary.considered).to.equal(1);
|
||||
done();
|
||||
});
|
||||
});
|
||||
@ -99,9 +103,9 @@ describe('Key importing', function () {
|
||||
|
||||
it('Deleting Key', function(done) {
|
||||
context.Keyring.importKey(pubKey).then(function(result){
|
||||
expect(result[0].key).to.be.an('object');
|
||||
expect(result[0].key.fingerprint).to.equal(fpr);
|
||||
result[0].key.delete().then(function(result){
|
||||
expect(result.Keys[0].key).to.be.an('object');
|
||||
expect(result.Keys[0].key.fingerprint).to.equal(fpr);
|
||||
result.Keys[0].key.delete().then(function(result){
|
||||
expect(result).to.be.true;
|
||||
done();
|
||||
});
|
||||
|
@ -274,6 +274,17 @@ export class GPGME_Keyring {
|
||||
msg.post().then(function(response){
|
||||
let infos = {};
|
||||
let fprs = [];
|
||||
let summary = {};
|
||||
for (let i=0; i < feedbackValues.length; i++ ){
|
||||
summary[feedbackValues[i]] =
|
||||
response.result[feedbackValues[i]];
|
||||
}
|
||||
if (!response.result.hasOwnProperty('imports') ||
|
||||
response.result.imports.length === 0
|
||||
){
|
||||
resolve({Keys:[],summary: summary});
|
||||
return;
|
||||
}
|
||||
for (let res=0; res<response.result.imports.length; res++){
|
||||
let result = response.result.imports[res];
|
||||
let status = '';
|
||||
@ -307,15 +318,7 @@ export class GPGME_Keyring {
|
||||
status: infos[result[i].fingerprint].status
|
||||
});
|
||||
}
|
||||
let summary = {};
|
||||
for (let i=0; i < feedbackValues.length; i++ ){
|
||||
summary[feedbackValues[i]] =
|
||||
response[feedbackValues[i]];
|
||||
}
|
||||
resolve({
|
||||
Keys:resultset,
|
||||
summary: summary
|
||||
});
|
||||
resolve({Keys:resultset,summary: summary});
|
||||
}, function(error){
|
||||
reject(error);
|
||||
});
|
||||
@ -327,15 +330,7 @@ export class GPGME_Keyring {
|
||||
status: infos[fprs[i]].status
|
||||
});
|
||||
}
|
||||
let summary = {};
|
||||
for (let i=0; i < feedbackValues.length; i++ ){
|
||||
summary[feedbackValues[i]] =
|
||||
response[feedbackValues[i]];
|
||||
}
|
||||
resolve({
|
||||
Keys:resultset,
|
||||
summary:summary
|
||||
});
|
||||
resolve({Keys:resultset,summary:summary});
|
||||
}
|
||||
|
||||
}, function(error){
|
||||
|
Loading…
Reference in New Issue
Block a user