From c755287ba845c4cbbf1d50e5aafecb2e687c7ac9 Mon Sep 17 00:00:00 2001 From: Maximilian Krambach Date: Thu, 3 May 2018 18:03:22 +0200 Subject: js: Added browser testing for unit tests -- * Added unittests to be run inside a Browser. To be able to access the non-exposed functions and classes, a testing bundle will be created, containing the tests (unittests.js) and the items to be tested. * src/Helpelpers, src/Key, src/Keyring: fixed some errors found during testing. --- lang/js/src/Key.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'lang/js/src/Key.js') diff --git a/lang/js/src/Key.js b/lang/js/src/Key.js index 1e0d3195..6d3cf17d 100644 --- a/lang/js/src/Key.js +++ b/lang/js/src/Key.js @@ -61,6 +61,9 @@ export class GPGME_Key { } get connection(){ + if (!this._fingerprint){ + return gpgme_error('KEY_INVALID'); + } if (!this._connection instanceof Connection){ return gpgme_error('CONN_NO_CONNECT'); } else { @@ -75,6 +78,9 @@ export class GPGME_Key { } get fingerprint(){ + if (!this._fingerprint){ + return gpgme_error('KEY_INVALID'); + } return this._fingerprint; } @@ -125,7 +131,7 @@ export class GPGME_Key { let msg = createMessage ('export_key'); msg.setParameter('armor', true); if (msg instanceof Error){ - return gpgme_error('INVALID_KEY'); + return gpgme_error('KEY_INVALID'); } this.connection.post(msg).then(function(result){ return result.data; @@ -203,6 +209,9 @@ export class GPGME_Key { * TODO: check if Promise.then(return) */ checkKey(property){ + if (!this._fingerprint){ + return gpgme_error('KEY_INVALID'); + } return gpgme_error('NOT_YET_IMPLEMENTED'); // TODO: async is not what is to be ecpected from Key information :( if (!property || typeof(property) !== 'string' || -- cgit v1.2.3