[git] GPGME - branch, javascript-binding, updated. gpgme-1.11.1-93-g90cb4a6

[email protected] (by Maximilian Krambach)
Newsgroups gmane.comp.encryption.gpg.cvs
Message-ID <[email protected]>
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GnuPG Made Easy".

The branch, javascript-binding has been updated
       via  90cb4a684211fe5630f209ba61510e8be3129eae (commit)
      from  d65a392670888f86071ca629266ec14b7afb0e46 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 90cb4a684211fe5630f209ba61510e8be3129eae
Author: Maximilian Krambach <[email protected]>
Date:   Thu Aug 16 17:58:11 2018 +0200

    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

diff --git a/lang/js/BrowserTestExtension/tests/KeyImportExport.js b/lang/js/BrowserTestExtension/tests/KeyImportExport.js
index d2fa2d3..6d0ba10 100644
--- a/lang/js/BrowserTestExtension/tests/KeyImportExport.js
+++ b/lang/js/BrowserTestExtension/tests/KeyImportExport.js
@@ -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();
             });
diff --git a/lang/js/src/Keyring.js b/lang/js/src/Keyring.js
index eb4f60f..a678798 100644
--- a/lang/js/src/Keyring.js
+++ b/lang/js/src/Keyring.js
@@ -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){

-----------------------------------------------------------------------

Summary of changes:
 .../BrowserTestExtension/tests/KeyImportExport.js  | 34 ++++++++++++----------
 lang/js/src/Keyring.js                             | 31 +++++++++-----------
 2 files changed, 32 insertions(+), 33 deletions(-)


hooks/post-receive
-- 
GnuPG Made Easy
http://git.gnupg.org
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.