aboutsummaryrefslogtreecommitdiffstats
path: root/lang/js/BrowserTestExtension/tests/encryptDecryptTest.js
diff options
context:
space:
mode:
authorMaximilian Krambach <[email protected]>2018-06-06 11:05:53 +0000
committerMaximilian Krambach <[email protected]>2018-06-06 11:05:53 +0000
commitbfd3799d39df265882deedeee083fd5246a2f35d (patch)
treebfee0a85d6373fa578de075cbce4d26ddced14e4 /lang/js/BrowserTestExtension/tests/encryptDecryptTest.js
parentjs: implement import/delete Key, some fixes (diff)
downloadgpgme-bfd3799d39df265882deedeee083fd5246a2f35d.tar.gz
gpgme-bfd3799d39df265882deedeee083fd5246a2f35d.zip
js: code cleanup (eslint)
-- * trying to stick to eslint from now on for readability * As some attribution was lost in previous git confusions, I added my name into some of the licence headers
Diffstat (limited to 'lang/js/BrowserTestExtension/tests/encryptDecryptTest.js')
-rw-r--r--lang/js/BrowserTestExtension/tests/encryptDecryptTest.js91
1 files changed, 50 insertions, 41 deletions
diff --git a/lang/js/BrowserTestExtension/tests/encryptDecryptTest.js b/lang/js/BrowserTestExtension/tests/encryptDecryptTest.js
index e5c2f749..a84be27c 100644
--- a/lang/js/BrowserTestExtension/tests/encryptDecryptTest.js
+++ b/lang/js/BrowserTestExtension/tests/encryptDecryptTest.js
@@ -1,4 +1,3 @@
-
/* gpgme.js - Javascript integration for gpgme
* Copyright (C) 2018 Bundesamt für Sicherheit in der Informationstechnik
*
@@ -17,23 +16,31 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, see <http://www.gnu.org/licenses/>.
* SPDX-License-Identifier: LGPL-2.1+
+ *
+ * Author(s):
+ * Maximilian Krambach <[email protected]>
*/
+/* global describe, it, expect, Gpgmejs */
+/* global inputvalues, encryptedData, bigString, bigBoringString */
+
describe('Encryption and Decryption', function () {
it('Successful encrypt and decrypt simple string', function (done) {
let prm = Gpgmejs.init();
prm.then(function (context) {
context.encrypt(
inputvalues.encrypt.good.data,
- inputvalues.encrypt.good.fingerprint).then(function (answer) {
+ inputvalues.encrypt.good.fingerprint).then(
+ function (answer) {
expect(answer).to.not.be.empty;
- expect(answer.data).to.be.a("string");
+ expect(answer.data).to.be.a('string');
expect(answer.data).to.include('BEGIN PGP MESSAGE');
expect(answer.data).to.include('END PGP MESSAGE');
context.decrypt(answer.data).then(function (result) {
expect(result).to.not.be.empty;
expect(result.data).to.be.a('string');
- expect(result.data).to.equal(inputvalues.encrypt.good.data);
+ expect(result.data).to.equal(
+ inputvalues.encrypt.good.data);
done();
});
});
@@ -51,7 +58,7 @@ describe('Encryption and Decryption', function () {
expect(result.data).to.equal(
'¡Äußerste µ€ før ñoquis@hóme! Добрый день\n');
done();
- });
+ });
});
}).timeout(3000);
@@ -64,7 +71,7 @@ describe('Encryption and Decryption', function () {
inputvalues.encrypt.good.fingerprint).then(
function (answer) {
expect(answer).to.not.be.empty;
- expect(answer.data).to.be.a("string");
+ expect(answer.data).to.be.a('string');
expect(answer.data).to.include(
'BEGIN PGP MESSAGE');
expect(answer.data).to.include(
@@ -79,39 +86,41 @@ describe('Encryption and Decryption', function () {
});
});
});
- }).timeout(5000);
+ }).timeout(5000);
for (let j = 0; j < inputvalues.encrypt.good.data_nonascii_32.length; j++){
- it('Roundtrip with >1MB non-ascii input meeting default chunksize (' + (j + 1) + '/' + inputvalues.encrypt.good.data_nonascii_32.length + ')',
- function (done) {
- let input = inputvalues.encrypt.good.data_nonascii_32[j];
- expect(input).to.have.length(32);
- let prm = Gpgmejs.init();
- prm.then(function (context) {
- let data = '';
- for (let i=0; i < 34 * 1024; i++){
- data += input;
- }
- context.encrypt(data,
- inputvalues.encrypt.good.fingerprint).then(
- function (answer) {
- expect(answer).to.not.be.empty;
- expect(answer.data).to.be.a("string");
- expect(answer.data).to.include(
- 'BEGIN PGP MESSAGE');
- expect(answer.data).to.include(
- 'END PGP MESSAGE');
- context.decrypt(answer.data).then(
- function (result) {
- expect(result).to.not.be.empty;
- expect(result.data).to.be.a('string');
- expect(result.data).to.equal(data);
- done();
- });
- });
- });
+ it('Roundtrip with >1MB non-ascii input meeting default chunksize (' +
+ (j + 1) + '/'
+ + inputvalues.encrypt.good.data_nonascii_32.length + ')',
+ function (done) {
+ let input = inputvalues.encrypt.good.data_nonascii_32[j];
+ expect(input).to.have.length(32);
+ let prm = Gpgmejs.init();
+ prm.then(function (context) {
+ let data = '';
+ for (let i=0; i < 34 * 1024; i++){
+ data += input;
+ }
+ context.encrypt(data,
+ inputvalues.encrypt.good.fingerprint).then(
+ function (answer) {
+ expect(answer).to.not.be.empty;
+ expect(answer.data).to.be.a('string');
+ expect(answer.data).to.include(
+ 'BEGIN PGP MESSAGE');
+ expect(answer.data).to.include(
+ 'END PGP MESSAGE');
+ context.decrypt(answer.data).then(
+ function (result) {
+ expect(result).to.not.be.empty;
+ expect(result.data).to.be.a('string');
+ expect(result.data).to.equal(data);
+ done();
+ });
+ });
+ });
}).timeout(3000);
- };
+ }
it('Random data, as string', function (done) {
let data = bigString(1000);
@@ -121,7 +130,7 @@ describe('Encryption and Decryption', function () {
inputvalues.encrypt.good.fingerprint).then(
function (answer) {
expect(answer).to.not.be.empty;
- expect(answer.data).to.be.a("string");
+ expect(answer.data).to.be.a('string');
expect(answer.data).to.include(
'BEGIN PGP MESSAGE');
expect(answer.data).to.include(
@@ -143,10 +152,10 @@ describe('Encryption and Decryption', function () {
let prm = Gpgmejs.init();
prm.then(function (context) {
context.encrypt(b64data,
- inputvalues.encrypt.good.fingerprint,).then(
+ inputvalues.encrypt.good.fingerprint).then(
function (answer) {
expect(answer).to.not.be.empty;
- expect(answer.data).to.be.a("string");
+ expect(answer.data).to.be.a('string');
expect(answer.data).to.include(
'BEGIN PGP MESSAGE');
expect(answer.data).to.include(
@@ -171,7 +180,7 @@ describe('Encryption and Decryption', function () {
inputvalues.encrypt.good.fingerprint, true).then(
function (answer) {
expect(answer).to.not.be.empty;
- expect(answer.data).to.be.a("string");
+ expect(answer.data).to.be.a('string');
expect(answer.data).to.include(
'BEGIN PGP MESSAGE');
expect(answer.data).to.include(
@@ -196,7 +205,7 @@ describe('Encryption and Decryption', function () {
inputvalues.encrypt.good.fingerprint).then(
function (answer) {
expect(answer).to.not.be.empty;
- expect(answer.data).to.be.a("string");
+ expect(answer.data).to.be.a('string');
expect(answer.data).to.include(
'BEGIN PGP MESSAGE');