aboutsummaryrefslogtreecommitdiffstats
path: root/lang/js/BrowserTestExtension/tests/encryptDecryptTest.js
diff options
context:
space:
mode:
authorMaximilian Krambach <[email protected]>2018-08-22 16:37:46 +0000
committerMaximilian Krambach <[email protected]>2018-08-22 16:37:46 +0000
commitf0409bbdafcbd4f8b0be099a6b3ce0d5352c9bcd (patch)
treefc94d23b0abef3c9e7c73d8a0165262f16e575e7 /lang/js/BrowserTestExtension/tests/encryptDecryptTest.js
parentjs: improve decryption performance (diff)
downloadgpgme-f0409bbdafcbd4f8b0be099a6b3ce0d5352c9bcd.tar.gz
gpgme-f0409bbdafcbd4f8b0be099a6b3ce0d5352c9bcd.zip
js: make method parameters objects
-- * As requested by using parties, the options to be passed into the methods are now objects, with the objects' properties better describing what they do, and to avoid the need to type several nulls in a method call if one wants the last parameter. - src/Keyring.js, src/gpgme.js: Changed parameters and their validations - BrowserTest/*.js Had to adapt quite some calls to the new format
Diffstat (limited to 'lang/js/BrowserTestExtension/tests/encryptDecryptTest.js')
-rw-r--r--lang/js/BrowserTestExtension/tests/encryptDecryptTest.js160
1 files changed, 83 insertions, 77 deletions
diff --git a/lang/js/BrowserTestExtension/tests/encryptDecryptTest.js b/lang/js/BrowserTestExtension/tests/encryptDecryptTest.js
index 28c98d98..1efdf5cf 100644
--- a/lang/js/BrowserTestExtension/tests/encryptDecryptTest.js
+++ b/lang/js/BrowserTestExtension/tests/encryptDecryptTest.js
@@ -38,25 +38,25 @@ describe('Encryption and Decryption', function (){
it('Successful encrypt and decrypt simple string', function (done) {
let data = inputvalues.encrypt.good.data;
- context.encrypt(data, good_fpr).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(
- inputvalues.encrypt.good.data);
- done();
+ context.encrypt({ data: data, publicKeys: good_fpr }).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({ data: 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);
+ done();
+ });
});
- });
});
it('Decrypt simple non-ascii', function (done) {
let data = encryptedData;
- context.decrypt(data).then(function (result) {
+ context.decrypt({ data: data }).then(function (result) {
expect(result).to.not.be.empty;
expect(result.data).to.be.a('string');
expect(result.data).to.equal(
@@ -67,77 +67,81 @@ describe('Encryption and Decryption', function (){
it('Trailing whitespace and different line endings', function (done) {
const data = 'Keks. \rKeks \n Keks \r\n';
- context.encrypt(data, good_fpr).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.encrypt({ data: data, publicKeys: good_fpr }).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();
+ context.decrypt({ data: 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(5000);
it('Random data, as string', function (done) {
let data = bigString(1000);
- context.encrypt(data, good_fpr).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();
+ context.encrypt({ data:data, publicKeys: good_fpr }).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({ data: 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('Data, input as base64', function (done) {
let data = inputvalues.encrypt.good.data;
let b64data = btoa(data);
- context.encrypt(b64data, good_fpr, true).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) {
+ context.encrypt({ data: b64data, publicKeys: good_fpr, base64: true })
+ .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({ data: answer.data }).then(function (result) {
expect(result).to.not.be.empty;
expect(result.data).to.be.a('string');
- expect(data).to.equal(data);
+ expect(result.data).to.equal(data);
done();
});
- });
+ });
}).timeout(3000);
it('Random data, input as base64', function (done) {
let data = bigBoringString(0.001);
let b64data = btoa(data);
- context.encrypt(b64data, good_fpr, true).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(b64data);
- done();
- });
- });
+ context.encrypt(
+ { data: b64data, publicKeys: good_fpr, base64: true })
+ .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({ data: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);
for (let j = 0; j < inputvalues.encrypt.good.data_nonascii_32.length; j++){
@@ -151,20 +155,22 @@ describe('Encryption and Decryption', function (){
for (let i=0; i < 34 * 1024; i++){
data += input;
}
- context.encrypt(data,good_fpr).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();
+ context.encrypt({ data: data, publicKeys: good_fpr })
+ .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({ data: 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(5000);
}
});