aboutsummaryrefslogtreecommitdiffstats
path: root/lang/js/BrowserTestExtension/tests
diff options
context:
space:
mode:
authorMaximilian Krambach <[email protected]>2018-08-20 13:12:01 +0000
committerMaximilian Krambach <[email protected]>2018-08-20 13:12:01 +0000
commitdd32daad0bb21e3d5567326d0b2e548ff8510431 (patch)
treebbefa811b727f1246fee17a26c9f1c4440609003 /lang/js/BrowserTestExtension/tests
parentjs: revert changes to class read/write restriction (diff)
downloadgpgme-dd32daad0bb21e3d5567326d0b2e548ff8510431.tar.gz
gpgme-dd32daad0bb21e3d5567326d0b2e548ff8510431.zip
js: add and apply eslint rules
-- * mainly spacing, see .eslintrc.json for details
Diffstat (limited to '')
-rw-r--r--lang/js/BrowserTestExtension/tests/KeyImportExport.js46
-rw-r--r--lang/js/BrowserTestExtension/tests/KeyInfos.js12
-rw-r--r--lang/js/BrowserTestExtension/tests/decryptTest.js14
-rw-r--r--lang/js/BrowserTestExtension/tests/encryptDecryptTest.js6
-rw-r--r--lang/js/BrowserTestExtension/tests/encryptTest.js10
-rw-r--r--lang/js/BrowserTestExtension/tests/inputvalues.js16
-rw-r--r--lang/js/BrowserTestExtension/tests/longRunningTests.js6
-rw-r--r--lang/js/BrowserTestExtension/tests/signTest.js4
-rw-r--r--lang/js/BrowserTestExtension/tests/startup.js6
-rw-r--r--lang/js/BrowserTestExtension/tests/verifyTest.js14
10 files changed, 67 insertions, 67 deletions
diff --git a/lang/js/BrowserTestExtension/tests/KeyImportExport.js b/lang/js/BrowserTestExtension/tests/KeyImportExport.js
index 6d0ba106..f52b790a 100644
--- a/lang/js/BrowserTestExtension/tests/KeyImportExport.js
+++ b/lang/js/BrowserTestExtension/tests/KeyImportExport.js
@@ -31,16 +31,16 @@ describe('Key importing', function () {
const changedKey = ImportablePublicKey.keyChangedUserId;
let context = null;
- before(function(done){
+ before(function (done){
const prm = Gpgmejs.init();
- prm.then(function(gpgmejs){
+ prm.then(function (gpgmejs){
context = gpgmejs;
context.Keyring.getKeys(fpr).then(
- function(result){
+ function (result){
if (result.length === 1) {
- result[0].delete().then(function(){
+ result[0].delete().then(function (){
done();
- },function(){
+ },function (){
done();
});
} else {
@@ -50,14 +50,14 @@ describe('Key importing', function () {
});
});
- afterEach(function(done){
+ afterEach(function (done){
// delete the test key if still present
context.Keyring.getKeys(fpr).then(
- function(result){
+ function (result){
if (result.length === 1) {
- result[0].delete().then(function(){
+ result[0].delete().then(function (){
done();
- },function(){
+ },function (){
done();
});
} else {
@@ -67,10 +67,10 @@ describe('Key importing', function () {
});
it('Importing Key', function (done) {
- context.Keyring.getKeys(fpr).then(function(result){
+ context.Keyring.getKeys(fpr).then(function (result){
expect(result).to.be.an('array');
expect(result.length).to.equal(0);
- context.Keyring.importKey(pubKey).then(function(result){
+ context.Keyring.importKey(pubKey).then(function (result){
expect(result.Keys).to.be.an('array');
expect(result.Keys[0]).to.not.be.undefined;
expect(result.Keys[0].key).to.be.an('object');
@@ -83,12 +83,12 @@ describe('Key importing', function () {
});
});
- it('Updating Key', function(done){
+ it('Updating Key', function (done){
context.Keyring.importKey(pubKey)
- .then(function(result){
+ .then(function (result){
expect(result.Keys[0].key).to.not.be.undefined;
expect(result.Keys[0].status).to.equal('newkey');
- context.Keyring.importKey(changedKey).then(function(res){
+ context.Keyring.importKey(changedKey).then(function (res){
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');
@@ -101,24 +101,24 @@ describe('Key importing', function () {
});
});
- it('Deleting Key', function(done) {
- context.Keyring.importKey(pubKey).then(function(result){
+ it('Deleting Key', function (done) {
+ context.Keyring.importKey(pubKey).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){
+ result.Keys[0].key.delete().then(function (result){
expect(result).to.be.true;
done();
});
});
});
- it('Import result feedback', function(done){
- context.Keyring.importKey(pubKey, true).then(function(result){
+ it('Import result feedback', function (done){
+ context.Keyring.importKey(pubKey, true).then(function (result){
expect(result).to.be.an('object');
expect(result.Keys[0]).to.be.an('object');
expect(result.Keys[0].key.fingerprint).to.equal(fpr);
expect(result.Keys[0].status).to.equal('newkey');
- result.Keys[0].key.getArmor().then(function(armor){
+ result.Keys[0].key.getArmor().then(function (armor){
expect(armor).to.be.a('string');
done();
});
@@ -126,8 +126,8 @@ describe('Key importing', function () {
});
it('exporting armored Key with getKeysArmored', function (done) {
- context.Keyring.importKey(pubKey).then(function(){
- context.Keyring.getKeysArmored(fpr).then(function(result){
+ context.Keyring.importKey(pubKey).then(function (){
+ context.Keyring.getKeysArmored(fpr).then(function (result){
expect(result).to.be.an('object');
expect(result.armored).to.be.a('string');
expect(result.secret_fprs).to.be.undefined;
@@ -138,7 +138,7 @@ describe('Key importing', function () {
it('Exporting Key (including secret fingerprints)', function (done) {
const key_secret = inputvalues.encrypt.good.fingerprint;
- context.Keyring.getKeysArmored(key_secret, true).then(function(result){
+ context.Keyring.getKeysArmored(key_secret, true).then(function (result){
expect(result).to.be.an('object');
expect(result.armored).to.be.a('string');
expect(result.secret_fprs).to.be.an('array');
diff --git a/lang/js/BrowserTestExtension/tests/KeyInfos.js b/lang/js/BrowserTestExtension/tests/KeyInfos.js
index 1829f227..e1caabe1 100644
--- a/lang/js/BrowserTestExtension/tests/KeyInfos.js
+++ b/lang/js/BrowserTestExtension/tests/KeyInfos.js
@@ -26,17 +26,17 @@
describe('Key information', function () {
let context = null;
- before(function(done){
+ before(function (done){
const prm = Gpgmejs.init();
- prm.then(function(gpgmejs){
+ prm.then(function (gpgmejs){
context = gpgmejs;
done();
});
});
- it('A fingerprint is consistently returned upper case hex', function(done){
+ it('A fingerprint is consistently returned upper case hex', function (done){
const mixedCase = inputvalues.encrypt.good.fingerprint_mixedcase;
- context.Keyring.getKeys(mixedCase).then(function(result){
+ context.Keyring.getKeys(mixedCase).then(function (result){
expect(result).to.be.an('array');
expect(result.length).to.equal(1);
expect(result[0].fingerprint).to.equal(mixedCase.toUpperCase());
@@ -44,9 +44,9 @@ describe('Key information', function () {
});
});
- it('A userId keeps their encoding', function(done){
+ it('A userId keeps their encoding', function (done){
context.Keyring.importKey(inputvalues.publicKeyNonAscii.key, true)
- .then(function(result){
+ .then(function (result){
expect(result.Keys[0]).to.be.an('object');
const user = result.Keys[0].key.get('userids')[0];
expect(user.get('name')).to.equal(
diff --git a/lang/js/BrowserTestExtension/tests/decryptTest.js b/lang/js/BrowserTestExtension/tests/decryptTest.js
index c6b3a3c5..a3f48daa 100644
--- a/lang/js/BrowserTestExtension/tests/decryptTest.js
+++ b/lang/js/BrowserTestExtension/tests/decryptTest.js
@@ -28,9 +28,9 @@ describe('Decryption', function () {
let context = null;
const good_fpr = inputvalues.encrypt.good.fingerprint;
- before(function(done){
+ before(function (done){
const prm = Gpgmejs.init();
- prm.then(function(gpgmejs){
+ prm.then(function (gpgmejs){
context = gpgmejs;
done();
});
@@ -39,8 +39,8 @@ describe('Decryption', function () {
it('Decryption of random string fails', function (done) {
let data = bigString(20 * 1024);
context.decrypt(data).then(
- function(){},
- function(error){
+ function (){},
+ function (error){
expect(error).to.be.an('error');
expect(error.code).to.equal('GNUPG_ERROR');
done();
@@ -49,10 +49,10 @@ describe('Decryption', function () {
it('Decryption of slightly corrupted message fails', function (done) {
const data = bigString(10000);
- context.encrypt(data, good_fpr).then(function(enc){
+ context.encrypt(data, good_fpr).then(function (enc){
context.decrypt(sabotageMsg(enc.data)).then(
- function(){},
- function(error){
+ function (){},
+ function (error){
expect(error).to.be.an('error');
expect(error.code).to.equal('GNUPG_ERROR');
done();
diff --git a/lang/js/BrowserTestExtension/tests/encryptDecryptTest.js b/lang/js/BrowserTestExtension/tests/encryptDecryptTest.js
index 80b293d2..28c98d98 100644
--- a/lang/js/BrowserTestExtension/tests/encryptDecryptTest.js
+++ b/lang/js/BrowserTestExtension/tests/encryptDecryptTest.js
@@ -24,13 +24,13 @@
/* global describe, it, expect, before, Gpgmejs */
/* global inputvalues, encryptedData, bigString, bigBoringString */
-describe('Encryption and Decryption', function () {
+describe('Encryption and Decryption', function (){
let context = null;
let good_fpr = inputvalues.encrypt.good.fingerprint;
- before(function(done){
+ before(function (done){
const prm = Gpgmejs.init();
- prm.then(function(gpgmejs){
+ prm.then(function (gpgmejs){
context = gpgmejs;
done();
});
diff --git a/lang/js/BrowserTestExtension/tests/encryptTest.js b/lang/js/BrowserTestExtension/tests/encryptTest.js
index 3ead8153..a242af5f 100644
--- a/lang/js/BrowserTestExtension/tests/encryptTest.js
+++ b/lang/js/BrowserTestExtension/tests/encryptTest.js
@@ -27,9 +27,9 @@
describe('Encryption', function () {
let context = null;
const good_fpr = inputvalues.encrypt.good.fingerprint;
- before(function(done){
+ before(function (done){
const prm = Gpgmejs.init();
- prm.then(function(gpgmejs){
+ prm.then(function (gpgmejs){
context = gpgmejs;
done();
});
@@ -64,7 +64,7 @@ describe('Encryption', function () {
const data = inputvalues.encrypt.good.data;
context.encrypt(data,null).then(function (answer) {
expect(answer).to.be.undefined;
- }, function(error){
+ }, function (error){
expect(error).to.be.an('Error');
expect(error.code).to.equal('MSG_INCOMPLETE');
done();
@@ -86,7 +86,7 @@ describe('Encryption', function () {
const bad_fpr = inputvalues.encrypt.bad.fingerprint;
context.encrypt(data, bad_fpr).then(function (answer) {
expect(answer).to.be.undefined;
- }, function(error){
+ }, function (error){
expect(error).to.be.an('Error');
expect(error.code).to.not.be.undefined;
expect(error.code).to.equal('GNUPG_ERROR');
@@ -98,7 +98,7 @@ describe('Encryption', function () {
const data = fixedLengthString(65);
context.encrypt(data, good_fpr).then(function (answer) {
expect(answer).to.be.undefined;
- }, function(error){
+ }, function (error){
expect(error).to.be.an.instanceof(Error);
// TODO: there is a 64 MB hard limit at least in chrome at:
// chromium//extensions/renderer/messaging_util.cc:
diff --git a/lang/js/BrowserTestExtension/tests/inputvalues.js b/lang/js/BrowserTestExtension/tests/inputvalues.js
index b33d985b..f84ac955 100644
--- a/lang/js/BrowserTestExtension/tests/inputvalues.js
+++ b/lang/js/BrowserTestExtension/tests/inputvalues.js
@@ -126,7 +126,7 @@ const inputvalues = {// eslint-disable-line no-unused-vars
};
// (Pseudo-)Random String covering all of utf8.
-function bigString(length){// eslint-disable-line no-unused-vars
+function bigString (length){// eslint-disable-line no-unused-vars
let arr = [];
for (let i= 0; i < length; i++){
arr.push(String.fromCharCode(
@@ -136,7 +136,7 @@ function bigString(length){// eslint-disable-line no-unused-vars
return arr.join('');
}
-function fixedLengthString(megabytes){// eslint-disable-line no-unused-vars
+function fixedLengthString (megabytes){// eslint-disable-line no-unused-vars
let maxlength = 1024 * 1024 * megabytes / 2;
let uint = new Uint8Array(maxlength);
for (let i = 0; i < maxlength; i++){
@@ -148,7 +148,7 @@ function fixedLengthString(megabytes){// eslint-disable-line no-unused-vars
}
// (Pseudo-)Random Uint8Array, given size in Megabytes
-function bigUint8(megabytes){// eslint-disable-line no-unused-vars
+function bigUint8 (megabytes){// eslint-disable-line no-unused-vars
let maxlength = 1024 * 1024 * megabytes;
let uint = new Uint8Array(maxlength);
for (let i= 0; i < maxlength; i++){
@@ -159,7 +159,7 @@ function bigUint8(megabytes){// eslint-disable-line no-unused-vars
// (Pseudo-)Random string with very limited charset
// (ascii only, no control chars)
-function bigBoringString(megabytes){// eslint-disable-line no-unused-vars
+function bigBoringString (megabytes){// eslint-disable-line no-unused-vars
let maxlength = 1024 * 1024 * megabytes;
let string = [];
let chars =
@@ -173,7 +173,7 @@ function bigBoringString(megabytes){// eslint-disable-line no-unused-vars
// Some String with simple chars, with different characteristics, but still
// expected to occur in an averag message
// eslint-disable-next-line no-unused-vars
-function slightlyLessBoringString(megabytes, set){
+function slightlyLessBoringString (megabytes, set){
let maxlength = 1024 * 1024 * megabytes;
let string = [];
let chars = '';
@@ -291,13 +291,13 @@ const ImportablePublicKey = {// eslint-disable-line no-unused-vars
* preserve) header/footer
*/
// eslint-disable-next-line no-unused-vars
-function sabotageMsg(msg, rate = 0.01, p= [35,35]){
+function sabotageMsg (msg, rate = 0.01, p= [35,35]){
const iterations = Math.floor(Math.random() * msg.length * rate) + 1;
const base64_set =
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/';
for (let i=0; i < iterations; i++){
let str0, str1, str2;
- const chosePosition = function(){
+ const chosePosition = function (){
let position =
Math.floor( Math.random() * (msg.length - p[0] + p[1]))
+ p[0];
@@ -310,7 +310,7 @@ function sabotageMsg(msg, rate = 0.01, p= [35,35]){
}
};
chosePosition();
- let new1 = function(){
+ let new1 = function (){
let n = base64_set[Math.floor(Math.random() * 64)];
return (n === str1) ? new1() : n;
};
diff --git a/lang/js/BrowserTestExtension/tests/longRunningTests.js b/lang/js/BrowserTestExtension/tests/longRunningTests.js
index 03f0390c..240a6b93 100644
--- a/lang/js/BrowserTestExtension/tests/longRunningTests.js
+++ b/lang/js/BrowserTestExtension/tests/longRunningTests.js
@@ -26,9 +26,9 @@
describe('Long running Encryption/Decryption', function () {
let context = null;
const good_fpr = inputvalues.encrypt.good.fingerprint;
- before(function(done){
+ before(function (done){
const prm = Gpgmejs.init();
- prm.then(function(gpgmejs){
+ prm.then(function (gpgmejs){
context = gpgmejs;
done();
});
@@ -43,7 +43,7 @@ describe('Long running Encryption/Decryption', function () {
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.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);
diff --git a/lang/js/BrowserTestExtension/tests/signTest.js b/lang/js/BrowserTestExtension/tests/signTest.js
index 2763dadf..f5bd9c1d 100644
--- a/lang/js/BrowserTestExtension/tests/signTest.js
+++ b/lang/js/BrowserTestExtension/tests/signTest.js
@@ -28,9 +28,9 @@ describe('Signing', function () {
let context = null;
const good_fpr = inputvalues.encrypt.good.fingerprint;
- before(function(done){
+ before(function (done){
const prm = Gpgmejs.init();
- prm.then(function(gpgmejs){
+ prm.then(function (gpgmejs){
context = gpgmejs;
done();
});
diff --git a/lang/js/BrowserTestExtension/tests/startup.js b/lang/js/BrowserTestExtension/tests/startup.js
index 63358aa9..cf5b0999 100644
--- a/lang/js/BrowserTestExtension/tests/startup.js
+++ b/lang/js/BrowserTestExtension/tests/startup.js
@@ -23,12 +23,12 @@
/* global describe, it, expect, Gpgmejs, inputvalues */
-describe('GPGME context', function(){
- it('Starting a GpgME instance', function(done){
+describe('GPGME context', function (){
+ it('Starting a GpgME instance', function (done){
let prm = Gpgmejs.init();
const input = inputvalues.someInputParameter;
prm.then(
- function(context){
+ function (context){
expect(context).to.be.an('object');
expect(context.encrypt).to.be.a('function');
expect(context.decrypt).to.be.a('function');
diff --git a/lang/js/BrowserTestExtension/tests/verifyTest.js b/lang/js/BrowserTestExtension/tests/verifyTest.js
index 1617e2dc..82aaf564 100644
--- a/lang/js/BrowserTestExtension/tests/verifyTest.js
+++ b/lang/js/BrowserTestExtension/tests/verifyTest.js
@@ -27,16 +27,16 @@
describe('Verifying data', function () {
let context = null;
- before(function(done){
+ before(function (done){
const prm = Gpgmejs.init();
- prm.then(function(gpgmejs){
+ prm.then(function (gpgmejs){
context = gpgmejs;
done();
});
});
it('Successful verify message', function (done) {
const message = inputvalues.signedMessage.good;
- context.verify(message).then(function(result){
+ context.verify(message).then(function (result){
expect(result.data).to.be.a('string');
expect(result.all_valid).to.be.true;
expect(result.count).to.equal(1);
@@ -50,7 +50,7 @@ describe('Verifying data', function () {
it('Successfully recognize changed cleartext', function (done) {
const message = inputvalues.signedMessage.bad;
- context.verify(message).then(function(result){
+ context.verify(message).then(function (result){
expect(result.data).to.be.a('string');
expect(result.all_valid).to.be.false;
expect(result.count).to.equal(1);
@@ -65,9 +65,9 @@ describe('Verifying data', function () {
it('Encrypt-Sign-Verify random message', function (done) {
const message = bigString(2000);
let fpr = inputvalues.encrypt.good.fingerprint;
- context.encrypt(message, fpr).then(function(message_enc){
- context.sign(message_enc.data, fpr).then(function(message_encsign){
- context.verify(message_encsign.data).then(function(result){
+ context.encrypt(message, fpr).then(function (message_enc){
+ context.sign(message_enc.data, fpr).then(function (message_encsign){
+ context.verify(message_encsign.data).then(function (result){
expect(result.data).to.equal(message_enc.data);
expect(result.data).to.be.a('string');
expect(result.all_valid).to.be.true;