aboutsummaryrefslogtreecommitdiffstats
path: root/lang/js/BrowserTestExtension/tests/encryptTest.js
diff options
context:
space:
mode:
Diffstat (limited to 'lang/js/BrowserTestExtension/tests/encryptTest.js')
-rw-r--r--lang/js/BrowserTestExtension/tests/encryptTest.js113
1 files changed, 60 insertions, 53 deletions
diff --git a/lang/js/BrowserTestExtension/tests/encryptTest.js b/lang/js/BrowserTestExtension/tests/encryptTest.js
index a16f993c..2cb4e58b 100644
--- a/lang/js/BrowserTestExtension/tests/encryptTest.js
+++ b/lang/js/BrowserTestExtension/tests/encryptTest.js
@@ -16,7 +16,14 @@
* 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, fixedLengthString */
+
describe('Encryption', function () {
it('Successful encrypt', function (done) {
let prm = Gpgmejs.init();
@@ -24,12 +31,12 @@ describe('Encryption', function () {
context.encrypt(
inputvalues.encrypt.good.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');
- done();
- });
+ 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');
+ done();
+ });
});
});
@@ -40,12 +47,12 @@ describe('Encryption', function () {
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');
- done();
- });
+ 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');
+ done();
+ });
});
}).timeout(10000);
@@ -56,12 +63,12 @@ describe('Encryption', function () {
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');
- done();
- });
+ 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');
+ done();
+ });
});
}).timeout(20000);
@@ -72,12 +79,12 @@ describe('Encryption', function () {
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');
- done();
- });
+ 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');
+ done();
+ });
});
}).timeout(20000);
@@ -87,12 +94,12 @@ describe('Encryption', function () {
context.encrypt(
inputvalues.encrypt.good.data,
null).then(function (answer) {
- expect(answer).to.be.undefined;
- }, function(error){
- expect(error).to.be.an('Error');
- expect(error.code).to.equal('MSG_INCOMPLETE');
- done();
- });
+ expect(answer).to.be.undefined;
+ }, function(error){
+ expect(error).to.be.an('Error');
+ expect(error.code).to.equal('MSG_INCOMPLETE');
+ done();
+ });
});
});
@@ -101,12 +108,12 @@ describe('Encryption', function () {
prm.then(function (context) {
context.encrypt(
null, inputvalues.encrypt.good.keyid).then(function (answer) {
- expect(answer).to.be.undefined;
- }, function (error) {
- expect(error).to.be.an.instanceof(Error);
- expect(error.code).to.equal('MSG_INCOMPLETE');
- done();
- });
+ expect(answer).to.be.undefined;
+ }, function (error) {
+ expect(error).to.be.an.instanceof(Error);
+ expect(error.code).to.equal('MSG_INCOMPLETE');
+ done();
+ });
});
});
@@ -116,15 +123,15 @@ describe('Encryption', function () {
context.encrypt(
inputvalues.encrypt.good.data,
inputvalues.encrypt.bad.fingerprint).then(function (answer) {
- expect(answer).to.be.undefined;
- }, function(error){
- expect(error).to.be.an('Error');
- expect(error.code).to.not.be.undefined;
- expect(error.code).to.equal('GNUPG_ERROR');
- done();
- });
+ expect(answer).to.be.undefined;
+ }, function(error){
+ expect(error).to.be.an('Error');
+ expect(error.code).to.not.be.undefined;
+ expect(error.code).to.equal('GNUPG_ERROR');
+ done();
+ });
});
- }).timeout(5000);;
+ }).timeout(5000);
it('Overly large message ( > 65MB) is rejected', function (done) {
let prm = Gpgmejs.init();
@@ -132,15 +139,15 @@ describe('Encryption', function () {
context.encrypt(
fixedLengthString(65),
inputvalues.encrypt.good.fingerprint).then(function (answer) {
- expect(answer).to.be.undefined;
- }, function(error){
- expect(error).to.be.an.instanceof(Error);
- // expect(error.code).to.equal('GNUPG_ERROR');
- // TODO: there is a 64 MB hard limit at least in chrome at:
- // chromium//extensions/renderer/messaging_util.cc:
- // kMaxMessageLength
- done();
- });
+ expect(answer).to.be.undefined;
+ }, function(error){
+ expect(error).to.be.an.instanceof(Error);
+ // expect(error.code).to.equal('GNUPG_ERROR');
+ // TODO: there is a 64 MB hard limit at least in chrome at:
+ // chromium//extensions/renderer/messaging_util.cc:
+ // kMaxMessageLength
+ done();
+ });
});
}).timeout(8000);