clean up tests
This commit is contained in:
parent
adb0148ca1
commit
8f01d4b0b5
|
@ -55,7 +55,7 @@ describe('Brainpool Cryptography', function () {
|
||||||
'=uGZP',
|
'=uGZP',
|
||||||
'-----END PGP PRIVATE KEY BLOCK-----'
|
'-----END PGP PRIVATE KEY BLOCK-----'
|
||||||
].join('\n'),
|
].join('\n'),
|
||||||
message: 'test message',
|
message: 'test message\n',
|
||||||
message_encrypted: [
|
message_encrypted: [
|
||||||
'-----BEGIN PGP MESSAGE-----',
|
'-----BEGIN PGP MESSAGE-----',
|
||||||
'',
|
'',
|
||||||
|
@ -110,18 +110,19 @@ describe('Brainpool Cryptography', function () {
|
||||||
'=3Dct',
|
'=3Dct',
|
||||||
'-----END PGP PRIVATE KEY BLOCK-----'
|
'-----END PGP PRIVATE KEY BLOCK-----'
|
||||||
].join('\n'),
|
].join('\n'),
|
||||||
message: 'second test message',
|
message: 'second test message\n',
|
||||||
message_signed: [
|
message_signed: [
|
||||||
'-----BEGIN PGP SIGNED MESSAGE-----',
|
'-----BEGIN PGP SIGNED MESSAGE-----',
|
||||||
'Hash: SHA512',
|
'Hash: SHA512',
|
||||||
'',
|
'',
|
||||||
'second test message',
|
'second test message',
|
||||||
|
'',
|
||||||
'-----BEGIN PGP SIGNATURE-----',
|
'-----BEGIN PGP SIGNATURE-----',
|
||||||
'',
|
'',
|
||||||
'iHUEARMKAB0WIQQi1GdXVRHGK/mAm7434WqYa4r5ngUCWq8vXQAKCRA34WqYa4r5',
|
'wl4EARMKABAFAltbE34JEDfhaphrivmeAABaXQD+LzOhFxTqz8+IcaD3xzww',
|
||||||
'nuLcAP9PvP2XRqhybqRLwa2OCKyAOmUogvx/xLWDwT4HYQDurwD/dnhMrzBQ6kJg',
|
'EjEn0u7qgCFem9PHPD4wqAcA/1WQE3N7DIwRG45HFd+ZBo4vcuRkWK+Q6CHl',
|
||||||
'jpFFbWyAqJavhedwBsFXCUoLH0/BA8w=',
|
'upbAEX7k',
|
||||||
'=XwF/',
|
'=obwy',
|
||||||
'-----END PGP SIGNATURE-----'
|
'-----END PGP SIGNATURE-----'
|
||||||
].join('\n')
|
].join('\n')
|
||||||
}
|
}
|
||||||
|
@ -166,20 +167,20 @@ describe('Brainpool Cryptography', function () {
|
||||||
const msg = openpgp.cleartext.readArmored(data.juliet.message_signed);
|
const msg = openpgp.cleartext.readArmored(data.juliet.message_signed);
|
||||||
return openpgp.verify({publicKeys: [pub], message: msg}).then(function(result) {
|
return openpgp.verify({publicKeys: [pub], message: msg}).then(function(result) {
|
||||||
expect(result).to.exist;
|
expect(result).to.exist;
|
||||||
expect(result.data.trim()).to.equal(data.juliet.message);
|
expect(result.data).to.equal(data.juliet.message);
|
||||||
expect(result.signatures).to.have.length(1);
|
expect(result.signatures).to.have.length(1);
|
||||||
expect(result.signatures[0].valid).to.be.true;
|
expect(result.signatures[0].valid).to.be.true;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it('Sign message', async function () {
|
it('Sign message', async function () {
|
||||||
const romeoPrivate = await load_priv_key('romeo');
|
const romeoPrivate = await load_priv_key('romeo');
|
||||||
const signed = await openpgp.sign({privateKeys: [romeoPrivate], data: data.romeo.message + "\n"});
|
const signed = await openpgp.sign({privateKeys: [romeoPrivate], data: data.romeo.message});
|
||||||
const romeoPublic = load_pub_key('romeo');
|
const romeoPublic = load_pub_key('romeo');
|
||||||
const msg = openpgp.cleartext.readArmored(signed.data);
|
const msg = openpgp.cleartext.readArmored(signed.data);
|
||||||
const result = await openpgp.verify({publicKeys: [romeoPublic], message: msg});
|
const result = await openpgp.verify({publicKeys: [romeoPublic], message: msg});
|
||||||
|
|
||||||
expect(result).to.exist;
|
expect(result).to.exist;
|
||||||
expect(result.data.trim()).to.equal(data.romeo.message);
|
expect(result.data).to.equal(data.romeo.message);
|
||||||
expect(result.signatures).to.have.length(1);
|
expect(result.signatures).to.have.length(1);
|
||||||
expect(result.signatures[0].valid).to.be.true;
|
expect(result.signatures[0].valid).to.be.true;
|
||||||
});
|
});
|
||||||
|
@ -190,15 +191,14 @@ describe('Brainpool Cryptography', function () {
|
||||||
const result = await openpgp.decrypt({privateKeys: romeo, publicKeys: [juliet], message: msg});
|
const result = await openpgp.decrypt({privateKeys: romeo, publicKeys: [juliet], message: msg});
|
||||||
|
|
||||||
expect(result).to.exist;
|
expect(result).to.exist;
|
||||||
// trim required because https://github.com/openpgpjs/openpgpjs/issues/311
|
expect(result.data).to.equal(data.romeo.message);
|
||||||
expect(result.data.trim()).to.equal(data.romeo.message);
|
|
||||||
expect(result.signatures).to.have.length(1);
|
expect(result.signatures).to.have.length(1);
|
||||||
expect(result.signatures[0].valid).to.be.true;
|
expect(result.signatures[0].valid).to.be.true;
|
||||||
});
|
});
|
||||||
it('Encrypt and sign message', async function () {
|
it('Encrypt and sign message', async function () {
|
||||||
const romeoPrivate = await load_priv_key('romeo');
|
const romeoPrivate = await load_priv_key('romeo');
|
||||||
const julietPublic = load_pub_key('juliet');
|
const julietPublic = load_pub_key('juliet');
|
||||||
const encrypted = await openpgp.encrypt({publicKeys: [julietPublic], privateKeys: [romeoPrivate], data: data.romeo.message + "\n"});
|
const encrypted = await openpgp.encrypt({publicKeys: [julietPublic], privateKeys: [romeoPrivate], data: data.romeo.message});
|
||||||
|
|
||||||
const message = openpgp.message.readArmored(encrypted.data);
|
const message = openpgp.message.readArmored(encrypted.data);
|
||||||
const romeoPublic = load_pub_key('romeo');
|
const romeoPublic = load_pub_key('romeo');
|
||||||
|
@ -206,7 +206,7 @@ describe('Brainpool Cryptography', function () {
|
||||||
const result = await openpgp.decrypt({privateKeys: julietPrivate, publicKeys: [romeoPublic], message: message});
|
const result = await openpgp.decrypt({privateKeys: julietPrivate, publicKeys: [romeoPublic], message: message});
|
||||||
|
|
||||||
expect(result).to.exist;
|
expect(result).to.exist;
|
||||||
expect(result.data.trim()).to.equal(data.romeo.message);
|
expect(result.data).to.equal(data.romeo.message);
|
||||||
expect(result.signatures).to.have.length(1);
|
expect(result.signatures).to.have.length(1);
|
||||||
expect(result.signatures[0].valid).to.be.true;
|
expect(result.signatures[0].valid).to.be.true;
|
||||||
});
|
});
|
||||||
|
|
|
@ -53,7 +53,7 @@ describe('Elliptic Curve Cryptography', function () {
|
||||||
'=C3TW',
|
'=C3TW',
|
||||||
'-----END PGP PRIVATE KEY BLOCK-----'
|
'-----END PGP PRIVATE KEY BLOCK-----'
|
||||||
].join('\n'),
|
].join('\n'),
|
||||||
message: 'Shall I hear more, or shall I speak at this?'
|
message: 'Shall I hear more, or shall I speak at this?\n'
|
||||||
},
|
},
|
||||||
juliet: {
|
juliet: {
|
||||||
id: '64116021959bdfe0',
|
id: '64116021959bdfe0',
|
||||||
|
@ -98,19 +98,21 @@ describe('Elliptic Curve Cryptography', function () {
|
||||||
'=QvXN',
|
'=QvXN',
|
||||||
'-----END PGP PRIVATE KEY BLOCK-----'
|
'-----END PGP PRIVATE KEY BLOCK-----'
|
||||||
].join('\n'),
|
].join('\n'),
|
||||||
message: 'O Romeo, Romeo! Wherefore art thou Romeo?',
|
message: 'O Romeo, Romeo! Wherefore art thou Romeo?\n',
|
||||||
message_signed: [
|
message_signed: [
|
||||||
'-----BEGIN PGP SIGNED MESSAGE-----',
|
'-----BEGIN PGP SIGNED MESSAGE-----',
|
||||||
'Hash: SHA256',
|
'Hash: SHA256',
|
||||||
'',
|
'',
|
||||||
'O Romeo, Romeo! Wherefore art thou Romeo?',
|
'O Romeo, Romeo! Wherefore art thou Romeo?',
|
||||||
|
'',
|
||||||
'-----BEGIN PGP SIGNATURE-----',
|
'-----BEGIN PGP SIGNATURE-----',
|
||||||
'Version: GnuPG v2',
|
'Version: GnuPG v2',
|
||||||
'Comment: GnuPG v2.1+libgcrypt-1.7',
|
'Comment: GnuPG v2.1+libgcrypt-1.7',
|
||||||
'',
|
'',
|
||||||
'iF4EARMIAAYFAlYxF8oACgkQZBFgIZWb3+BfTwD/b1yKtFnKrRjELuD6/gOH9/er',
|
'wl4EARMIABAFAltbFFMJEGQRYCGVm9/gAAAjugD/W/OZ++qiNlhy08OOflAN',
|
||||||
'6yc7nzn1FBYFzMz8aFIA/3FlcIvR+eLvRTVmfiEatB6IU6JviBnzxR1gA/SOdyS2',
|
'rjjX3rknSZyUkr96HD4VWVsBAPL9QjyHI3714cdkQmwYGiG8TVrtPetnqHho',
|
||||||
'=GCiR',
|
'Ppmby7/I',
|
||||||
|
'=IyBz',
|
||||||
'-----END PGP SIGNATURE-----'
|
'-----END PGP SIGNATURE-----'
|
||||||
].join('\n'),
|
].join('\n'),
|
||||||
message_encrypted: [
|
message_encrypted: [
|
||||||
|
@ -177,20 +179,20 @@ describe('Elliptic Curve Cryptography', function () {
|
||||||
const msg = openpgp.cleartext.readArmored(data.juliet.message_signed);
|
const msg = openpgp.cleartext.readArmored(data.juliet.message_signed);
|
||||||
return openpgp.verify({publicKeys: [pub], message: msg}).then(function(result) {
|
return openpgp.verify({publicKeys: [pub], message: msg}).then(function(result) {
|
||||||
expect(result).to.exist;
|
expect(result).to.exist;
|
||||||
expect(result.data.trim()).to.equal(data.juliet.message);
|
expect(result.data).to.equal(data.juliet.message);
|
||||||
expect(result.signatures).to.have.length(1);
|
expect(result.signatures).to.have.length(1);
|
||||||
expect(result.signatures[0].valid).to.be.true;
|
expect(result.signatures[0].valid).to.be.true;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it('Sign message', async function () {
|
it('Sign message', async function () {
|
||||||
const romeoPrivate = await load_priv_key('romeo');
|
const romeoPrivate = await load_priv_key('romeo');
|
||||||
const signed = await openpgp.sign({privateKeys: [romeoPrivate], data: data.romeo.message + "\n"});
|
const signed = await openpgp.sign({privateKeys: [romeoPrivate], data: data.romeo.message});
|
||||||
const romeoPublic = load_pub_key('romeo');
|
const romeoPublic = load_pub_key('romeo');
|
||||||
const msg = openpgp.cleartext.readArmored(signed.data);
|
const msg = openpgp.cleartext.readArmored(signed.data);
|
||||||
const result = await openpgp.verify({publicKeys: [romeoPublic], message: msg});
|
const result = await openpgp.verify({publicKeys: [romeoPublic], message: msg});
|
||||||
|
|
||||||
expect(result).to.exist;
|
expect(result).to.exist;
|
||||||
expect(result.data.trim()).to.equal(data.romeo.message);
|
expect(result.data).to.equal(data.romeo.message);
|
||||||
expect(result.signatures).to.have.length(1);
|
expect(result.signatures).to.have.length(1);
|
||||||
expect(result.signatures[0].valid).to.be.true;
|
expect(result.signatures[0].valid).to.be.true;
|
||||||
});
|
});
|
||||||
|
@ -201,15 +203,14 @@ describe('Elliptic Curve Cryptography', function () {
|
||||||
const result = await openpgp.decrypt({privateKeys: romeo, publicKeys: [juliet], message: msg});
|
const result = await openpgp.decrypt({privateKeys: romeo, publicKeys: [juliet], message: msg});
|
||||||
|
|
||||||
expect(result).to.exist;
|
expect(result).to.exist;
|
||||||
// trim required because https://github.com/openpgpjs/openpgpjs/issues/311
|
expect(result.data).to.equal(data.juliet.message);
|
||||||
expect(result.data.trim()).to.equal(data.juliet.message);
|
|
||||||
expect(result.signatures).to.have.length(1);
|
expect(result.signatures).to.have.length(1);
|
||||||
expect(result.signatures[0].valid).to.be.true;
|
expect(result.signatures[0].valid).to.be.true;
|
||||||
});
|
});
|
||||||
it('Encrypt and sign message', async function () {
|
it('Encrypt and sign message', async function () {
|
||||||
const romeoPrivate = await load_priv_key('romeo');
|
const romeoPrivate = await load_priv_key('romeo');
|
||||||
const julietPublic = load_pub_key('juliet');
|
const julietPublic = load_pub_key('juliet');
|
||||||
const encrypted = await openpgp.encrypt({publicKeys: [julietPublic], privateKeys: [romeoPrivate], data: data.romeo.message + "\n"});
|
const encrypted = await openpgp.encrypt({publicKeys: [julietPublic], privateKeys: [romeoPrivate], data: data.romeo.message});
|
||||||
|
|
||||||
const message = openpgp.message.readArmored(encrypted.data);
|
const message = openpgp.message.readArmored(encrypted.data);
|
||||||
const romeoPublic = load_pub_key('romeo');
|
const romeoPublic = load_pub_key('romeo');
|
||||||
|
@ -217,7 +218,7 @@ describe('Elliptic Curve Cryptography', function () {
|
||||||
const result = await openpgp.decrypt({privateKeys: julietPrivate, publicKeys: [romeoPublic], message: message});
|
const result = await openpgp.decrypt({privateKeys: julietPrivate, publicKeys: [romeoPublic], message: message});
|
||||||
|
|
||||||
expect(result).to.exist;
|
expect(result).to.exist;
|
||||||
expect(result.data.trim()).to.equal(data.romeo.message);
|
expect(result.data).to.equal(data.romeo.message);
|
||||||
expect(result.signatures).to.have.length(1);
|
expect(result.signatures).to.have.length(1);
|
||||||
expect(result.signatures[0].valid).to.be.true;
|
expect(result.signatures[0].valid).to.be.true;
|
||||||
});
|
});
|
||||||
|
|
|
@ -287,7 +287,7 @@ DECl1Qu4QyeXin29uEXWiekMpNlZVsEuc8icCw6ABhIZ
|
||||||
-----END PGP PRIVATE KEY BLOCK-----`;
|
-----END PGP PRIVATE KEY BLOCK-----`;
|
||||||
|
|
||||||
const passphrase = 'hello world';
|
const passphrase = 'hello world';
|
||||||
const plaintext = input.createSomeMessage() + '\n한국어/조선말';
|
const plaintext = input.createSomeMessage();
|
||||||
const password1 = 'I am a password';
|
const password1 = 'I am a password';
|
||||||
const password2 = 'I am another password';
|
const password2 = 'I am another password';
|
||||||
const password3 = 'I am a third password';
|
const password3 = 'I am a third password';
|
||||||
|
@ -756,7 +756,7 @@ describe('OpenPGP.js public api tests', function() {
|
||||||
openpgp.initWorker({path: '../dist/openpgp.worker.js', workers, n: 2});
|
openpgp.initWorker({path: '../dist/openpgp.worker.js', workers, n: 2});
|
||||||
|
|
||||||
const workerTest = (_, index) => {
|
const workerTest = (_, index) => {
|
||||||
const plaintext = input.createSomeMessage() + index + '\n한국어/조선말';
|
const plaintext = input.createSomeMessage() + index;
|
||||||
return openpgp.encrypt({
|
return openpgp.encrypt({
|
||||||
publicKeys: publicKey.keys,
|
publicKeys: publicKey.keys,
|
||||||
data: plaintext
|
data: plaintext
|
||||||
|
|
|
@ -46,18 +46,19 @@ describe('X25519 Cryptography', function () {
|
||||||
'=wo91',
|
'=wo91',
|
||||||
'-----END PGP PRIVATE KEY BLOCK-----'
|
'-----END PGP PRIVATE KEY BLOCK-----'
|
||||||
].join('\n'),
|
].join('\n'),
|
||||||
message: 'Hi, Light wrote this!',
|
message: 'Hi, Light wrote this!\n',
|
||||||
message_signed: [
|
message_signed: [
|
||||||
'-----BEGIN PGP SIGNED MESSAGE-----',
|
'-----BEGIN PGP SIGNED MESSAGE-----',
|
||||||
'Hash: SHA256',
|
'Hash: SHA512',
|
||||||
'',
|
'',
|
||||||
'Hi, Light wrote this!',
|
'Hi, Light wrote this!',
|
||||||
|
'',
|
||||||
'-----BEGIN PGP SIGNATURE-----',
|
'-----BEGIN PGP SIGNATURE-----',
|
||||||
'',
|
'',
|
||||||
'iIAEARYIACgWIQSGS0GuVELT3Rs0wocezfAmwCRYMAUCWkyVkAocbGlnaHRAc3Vu',
|
'wl4EARYKABAFAltbFNAJEB7N8CbAJFgwAAAhcAEA5b2MIQNxQYj8TAMyuhZJ',
|
||||||
'AAoJEB7N8CbAJFgwdqAA/RwTsy9Nt5HEJLnokUNgHVX8wNr7Ef9wfAG1RaMgMMWs',
|
'UvxEgPS8DU59Kxw5F9+oldQBAN4mA+SOJyTxEx4oyyLh+8RD27dqyeDpmXju',
|
||||||
'AP9KEEohpHqaj8smb1oLjYU9DgOugE40LrkujvnWNbOZBQ==',
|
'xqMRN8oE',
|
||||||
'=T9p+',
|
'=siSU',
|
||||||
'-----END PGP SIGNATURE-----'
|
'-----END PGP SIGNATURE-----'
|
||||||
].join('\n')
|
].join('\n')
|
||||||
},
|
},
|
||||||
|
@ -97,7 +98,7 @@ describe('X25519 Cryptography', function () {
|
||||||
'=NDSU',
|
'=NDSU',
|
||||||
'-----END PGP PRIVATE KEY BLOCK-----'
|
'-----END PGP PRIVATE KEY BLOCK-----'
|
||||||
].join('\n'),
|
].join('\n'),
|
||||||
message: 'Oh hi, this is a private message from Light to Night!',
|
message: 'Oh hi, this is a private message from Light to Night!\n',
|
||||||
message_encrypted: [
|
message_encrypted: [
|
||||||
'-----BEGIN PGP MESSAGE-----',
|
'-----BEGIN PGP MESSAGE-----',
|
||||||
'',
|
'',
|
||||||
|
@ -162,7 +163,7 @@ describe('X25519 Cryptography', function () {
|
||||||
const msg = openpgp.cleartext.readArmored(data[name].message_signed);
|
const msg = openpgp.cleartext.readArmored(data[name].message_signed);
|
||||||
return openpgp.verify({ publicKeys: [pub], message: msg }).then(function(result) {
|
return openpgp.verify({ publicKeys: [pub], message: msg }).then(function(result) {
|
||||||
expect(result).to.exist;
|
expect(result).to.exist;
|
||||||
expect(result.data.trim()).to.equal(data[name].message);
|
expect(result.data).to.equal(data[name].message);
|
||||||
expect(result.signatures).to.have.length(1);
|
expect(result.signatures).to.have.length(1);
|
||||||
expect(result.signatures[0].valid).to.be.true;
|
expect(result.signatures[0].valid).to.be.true;
|
||||||
});
|
});
|
||||||
|
@ -190,8 +191,7 @@ describe('X25519 Cryptography', function () {
|
||||||
const result = await openpgp.decrypt({ privateKeys: night, publicKeys: [light], message: msg });
|
const result = await openpgp.decrypt({ privateKeys: night, publicKeys: [light], message: msg });
|
||||||
|
|
||||||
expect(result).to.exist;
|
expect(result).to.exist;
|
||||||
// trim required because https://github.com/openpgpjs/openpgpjs/issues/311
|
expect(result.data).to.equal(data.night.message);
|
||||||
expect(result.data.trim()).to.equal(data.night.message);
|
|
||||||
expect(result.signatures).to.have.length(1);
|
expect(result.signatures).to.have.length(1);
|
||||||
expect(result.signatures[0].valid).to.be.true;
|
expect(result.signatures[0].valid).to.be.true;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user