[git] GPGME - branch, master, updated. gpgme-1.11.1-290-g7f14958

by Maximilian Krambach cvs at cvs.gnupg.org
Wed Sep 19 10:58:40 CEST 2018


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, master has been updated
       via  7f149586062ebae8114f64078771cb25579f5003 (commit)
      from  362caaf02f3a25b7e626572aa30b87771c2c8f4d (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 7f149586062ebae8114f64078771cb25579f5003
Author: Maximilian Krambach <maximilian.krambach at intevation.de>
Date:   Wed Sep 19 10:56:36 2018 +0200

    js: add configuration option on startup
    
    --
    
    * src/index.js: Added an optional configuration object for the startup.
    
    * configuration: timeout - the initial check for a connection ran into
      timeouts on slower testing machines. 500ms for initial startup is
      not sufficient everywhere. The default timeout was raised to 1000ms,
      and as an option this timeout can be increased even further.
    
    * BrowsertestExtension: Set the initial connection timeouts to 2
      seconds, to be able to test on slower machines.

diff --git a/lang/js/BrowserTestExtension/tests/KeyImportExport.js b/lang/js/BrowserTestExtension/tests/KeyImportExport.js
index f57877f..b3d95bb 100644
--- a/lang/js/BrowserTestExtension/tests/KeyImportExport.js
+++ b/lang/js/BrowserTestExtension/tests/KeyImportExport.js
@@ -32,7 +32,7 @@ describe('Key importing', function () {
 
     let context = null;
     before(function (done){
-        const prm = Gpgmejs.init();
+        const prm = Gpgmejs.init({ timeout: 2000 });
         prm.then(function (gpgmejs){
             context = gpgmejs;
             context.Keyring.getKeys({ pattern: fpr }).then(
diff --git a/lang/js/BrowserTestExtension/tests/KeyInfos.js b/lang/js/BrowserTestExtension/tests/KeyInfos.js
index 553aedb..d122958 100644
--- a/lang/js/BrowserTestExtension/tests/KeyInfos.js
+++ b/lang/js/BrowserTestExtension/tests/KeyInfos.js
@@ -27,7 +27,7 @@
 describe('Key information', function () {
     let context = null;
     before(function (done){
-        const prm = Gpgmejs.init();
+        const prm = Gpgmejs.init({ timeout: 2000 });
         prm.then(function (gpgmejs){
             context = gpgmejs;
             done();
diff --git a/lang/js/BrowserTestExtension/tests/decryptTest.js b/lang/js/BrowserTestExtension/tests/decryptTest.js
index 61a3fab..5817eb4 100644
--- a/lang/js/BrowserTestExtension/tests/decryptTest.js
+++ b/lang/js/BrowserTestExtension/tests/decryptTest.js
@@ -29,7 +29,7 @@ describe('Decryption', function () {
     const good_fpr = inputvalues.encrypt.good.fingerprint;
 
     before(function (done){
-        const prm = Gpgmejs.init();
+        const prm = Gpgmejs.init({ timeout:2000 });
         prm.then(function (gpgmejs){
             context = gpgmejs;
             done();
diff --git a/lang/js/BrowserTestExtension/tests/encryptDecryptTest.js b/lang/js/BrowserTestExtension/tests/encryptDecryptTest.js
index c10c5d0..b4e4f3f 100644
--- a/lang/js/BrowserTestExtension/tests/encryptDecryptTest.js
+++ b/lang/js/BrowserTestExtension/tests/encryptDecryptTest.js
@@ -29,7 +29,7 @@ describe('Encryption and Decryption', function (){
     let good_fpr = inputvalues.encrypt.good.fingerprint;
 
     before(function (done){
-        const prm = Gpgmejs.init();
+        const prm = Gpgmejs.init({ timeout: 2000 });
         prm.then(function (gpgmejs){
             context = gpgmejs;
             done();
diff --git a/lang/js/BrowserTestExtension/tests/encryptTest.js b/lang/js/BrowserTestExtension/tests/encryptTest.js
index d97b458..1017d71 100644
--- a/lang/js/BrowserTestExtension/tests/encryptTest.js
+++ b/lang/js/BrowserTestExtension/tests/encryptTest.js
@@ -28,7 +28,7 @@ describe('Encryption', function () {
     let context = null;
     const good_fpr = inputvalues.encrypt.good.fingerprint;
     before(function (done){
-        const prm = Gpgmejs.init();
+        const prm = Gpgmejs.init({ timeout: 2000 });
         prm.then(function (gpgmejs){
             context = gpgmejs;
             done();
diff --git a/lang/js/BrowserTestExtension/tests/longRunningTests.js b/lang/js/BrowserTestExtension/tests/longRunningTests.js
index f28a6e7..534a95a 100644
--- a/lang/js/BrowserTestExtension/tests/longRunningTests.js
+++ b/lang/js/BrowserTestExtension/tests/longRunningTests.js
@@ -27,7 +27,7 @@ describe('Long running Encryption/Decryption', function () {
     let context = null;
     const good_fpr = inputvalues.encrypt.good.fingerprint;
     before(function (done){
-        const prm = Gpgmejs.init();
+        const prm = Gpgmejs.init({ timeout: 2000 });
         prm.then(function (gpgmejs){
             context = gpgmejs;
             done();
diff --git a/lang/js/BrowserTestExtension/tests/signTest.js b/lang/js/BrowserTestExtension/tests/signTest.js
index bd8db80..1e269e6 100644
--- a/lang/js/BrowserTestExtension/tests/signTest.js
+++ b/lang/js/BrowserTestExtension/tests/signTest.js
@@ -29,7 +29,7 @@ describe('Signing', function () {
     const good_fpr = inputvalues.encrypt.good.fingerprint;
 
     before(function (done){
-        const prm = Gpgmejs.init();
+        const prm = Gpgmejs.init({ timeout: 2000 });
         prm.then(function (gpgmejs){
             context = gpgmejs;
             done();
diff --git a/lang/js/BrowserTestExtension/tests/startup.js b/lang/js/BrowserTestExtension/tests/startup.js
index cf5b099..e7c7478 100644
--- a/lang/js/BrowserTestExtension/tests/startup.js
+++ b/lang/js/BrowserTestExtension/tests/startup.js
@@ -25,7 +25,7 @@
 
 describe('GPGME context', function (){
     it('Starting a GpgME instance', function (done){
-        let prm = Gpgmejs.init();
+        let prm = Gpgmejs.init({ timeout: 2000 });
         const input = inputvalues.someInputParameter;
         prm.then(
             function (context){
diff --git a/lang/js/BrowserTestExtension/tests/verifyTest.js b/lang/js/BrowserTestExtension/tests/verifyTest.js
index 04c7a77..c63f684 100644
--- a/lang/js/BrowserTestExtension/tests/verifyTest.js
+++ b/lang/js/BrowserTestExtension/tests/verifyTest.js
@@ -28,7 +28,7 @@
 describe('Verifying data', function () {
     let context = null;
     before(function (done){
-        const prm = Gpgmejs.init();
+        const prm = Gpgmejs.init({ timeout: 2000 });
         prm.then(function (gpgmejs){
             context = gpgmejs;
             done();
diff --git a/lang/js/src/Connection.js b/lang/js/src/Connection.js
index 4055da6..d43d55f 100644
--- a/lang/js/src/Connection.js
+++ b/lang/js/src/Connection.js
@@ -74,11 +74,15 @@ export class Connection{
      * Retrieves the information about the backend.
      * @param {Boolean} details (optional) If set to false, the promise will
      *  just return if a connection was successful.
+     * @param {Number} timeout (optional)
      * @returns {Promise<backEndDetails>|Promise<Boolean>} Details from the
      * backend
      * @async
      */
-    checkConnection (details = true){
+    checkConnection (details = true, timeout = 1000){
+        if (typeof timeout !== 'number' && timeout <= 0) {
+            timeout = 1000;
+        }
         const msg = createMessage('version');
         if (details === true) {
             return this.post(msg);
@@ -90,7 +94,7 @@ export class Connection{
                     new Promise(function (resolve, reject){
                         setTimeout(function (){
                             reject(gpgme_error('CONN_TIMEOUT'));
-                        }, 500);
+                        }, timeout);
                     })
                 ]).then(function (){ // success
                     resolve(true);
diff --git a/lang/js/src/index.js b/lang/js/src/index.js
index c52460c..b8e4274 100644
--- a/lang/js/src/index.js
+++ b/lang/js/src/index.js
@@ -31,13 +31,17 @@ import { Connection } from './Connection';
  * connection once, and then offers the available functions as method of the
  * response object.
  * An unsuccessful attempt will reject as a GPGME_Error.
+ * @param {Object} config (optional) configuration options
+ * @param {Number} config.timeout set the timeout for the initial connection
+ * check. On some machines and operating systems a default timeout of 500 ms is
+ * too low, so a higher number might be attempted.
  * @returns {Promise<GpgME>}
  * @async
  */
-function init (){
+function init ({ timeout = 500 } = {}){
     return new Promise(function (resolve, reject){
         const connection = new Connection;
-        connection.checkConnection(false).then(
+        connection.checkConnection(false, timeout).then(
             function (result){
                 if (result === true) {
                     resolve(new GpgME());
diff --git a/lang/js/unittests.js b/lang/js/unittests.js
index de06320..f28be76 100644
--- a/lang/js/unittests.js
+++ b/lang/js/unittests.js
@@ -34,34 +34,38 @@ import { GPGME_Message, createMessage } from './src/Message';
 mocha.setup('bdd');
 const expect = chai.expect;
 chai.config.includeStack = true;
+const connectionTimeout = 2000;
 
 function unittests (){
     describe('Connection testing', function (){
 
         it('Connecting', function (done) {
             let conn0 = new Connection;
-            conn0.checkConnection().then(function (answer) {
-                expect(answer).to.not.be.empty;
-                expect(answer.gpgme).to.not.be.undefined;
-                expect(answer.gpgme).to.be.a('string');
-                expect(answer.info).to.be.an('Array');
-                expect(conn0.disconnect).to.be.a('function');
-                expect(conn0.post).to.be.a('function');
-                done();
-            });
+            conn0.checkConnection(true, connectionTimeout).then(
+                function (answer) {
+                    expect(answer).to.not.be.empty;
+                    expect(answer.gpgme).to.not.be.undefined;
+                    expect(answer.gpgme).to.be.a('string');
+                    expect(answer.info).to.be.an('Array');
+                    expect(conn0.disconnect).to.be.a('function');
+                    expect(conn0.post).to.be.a('function');
+                    done();
+                });
 
         });
 
         it('Disconnecting', function (done) {
             let conn0 = new Connection;
-            conn0.checkConnection(false).then(function (answer) {
-                expect(answer).to.be.true;
-                conn0.disconnect();
-                conn0.checkConnection(false).then(function (result) {
-                    expect(result).to.be.false;
-                    done();
+            conn0.checkConnection(false, connectionTimeout).then(
+                function (answer) {
+                    expect(answer).to.be.true;
+                    conn0.disconnect();
+                    conn0.checkConnection(false, connectionTimeout).then(
+                        function (result) {
+                            expect(result).to.be.false;
+                            done();
+                        });
                 });
-            });
         });
     });
 

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

Summary of changes:
 .../BrowserTestExtension/tests/KeyImportExport.js  |  2 +-
 lang/js/BrowserTestExtension/tests/KeyInfos.js     |  2 +-
 lang/js/BrowserTestExtension/tests/decryptTest.js  |  2 +-
 .../tests/encryptDecryptTest.js                    |  2 +-
 lang/js/BrowserTestExtension/tests/encryptTest.js  |  2 +-
 .../BrowserTestExtension/tests/longRunningTests.js |  2 +-
 lang/js/BrowserTestExtension/tests/signTest.js     |  2 +-
 lang/js/BrowserTestExtension/tests/startup.js      |  2 +-
 lang/js/BrowserTestExtension/tests/verifyTest.js   |  2 +-
 lang/js/src/Connection.js                          |  8 +++--
 lang/js/src/index.js                               |  8 +++--
 lang/js/unittests.js                               | 36 ++++++++++++----------
 12 files changed, 41 insertions(+), 29 deletions(-)


hooks/post-receive
-- 
GnuPG Made Easy
http://git.gnupg.org




More information about the Gnupg-commits mailing list