mirror of
https://github.com/moparisthebest/mail
synced 2024-11-22 17:02:17 -05:00
add bad test case
This commit is contained in:
parent
95f815de91
commit
d6ed270c02
@ -51,6 +51,7 @@ define(function(require) {
|
|||||||
|
|
||||||
// unlock and import private key
|
// unlock and import private key
|
||||||
if (!openpgp.keyring.importPrivateKey(options.privateKeyArmored, options.passphrase)) {
|
if (!openpgp.keyring.importPrivateKey(options.privateKeyArmored, options.passphrase)) {
|
||||||
|
openpgp.keyring.init();
|
||||||
callback({
|
callback({
|
||||||
errMsg: 'Incorrect passphrase!'
|
errMsg: 'Incorrect passphrase!'
|
||||||
});
|
});
|
||||||
@ -81,19 +82,21 @@ define(function(require) {
|
|||||||
var publicKey, privateKey;
|
var publicKey, privateKey;
|
||||||
|
|
||||||
privateKey = openpgp.keyring.exportPrivateKey(0);
|
privateKey = openpgp.keyring.exportPrivateKey(0);
|
||||||
publicKey = openpgp.keyring.getPublicKeysForKeyId(privateKey.keyId)[0];
|
if (privateKey && privateKey.keyId) {
|
||||||
|
publicKey = openpgp.keyring.getPublicKeysForKeyId(privateKey.keyId)[0];
|
||||||
|
}
|
||||||
|
|
||||||
if (privateKey && privateKey.keyId && privateKey.armored && publicKey && publicKey.armored) {
|
if (!privateKey || !privateKey.keyId || !privateKey.armored || !publicKey || !publicKey.armored) {
|
||||||
callback(null, {
|
callback({
|
||||||
keyId: util.hexstrdump(privateKey.keyId).toUpperCase(),
|
errMsg: 'Could not export keys!'
|
||||||
privateKeyArmored: privateKey.armored,
|
|
||||||
publicKeyArmored: publicKey.armored
|
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
callback({
|
callback(null, {
|
||||||
errMsg: 'Could not export keys!'
|
keyId: util.hexstrdump(privateKey.keyId).toUpperCase(),
|
||||||
|
privateKeyArmored: privateKey.armored,
|
||||||
|
publicKeyArmored: publicKey.armored
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -83,6 +83,21 @@ define(function(require) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('Import/Export key pair', function() {
|
describe('Import/Export key pair', function() {
|
||||||
|
it('should fail', function(done) {
|
||||||
|
pgp.importKeys({
|
||||||
|
passphrase: 'asd',
|
||||||
|
privateKeyArmored: privkey,
|
||||||
|
publicKeyArmored: pubkey
|
||||||
|
}, function(err) {
|
||||||
|
expect(err).to.exist;
|
||||||
|
|
||||||
|
pgp.exportKeys(function(err, keys) {
|
||||||
|
expect(err).to.exist;
|
||||||
|
expect(keys).to.not.exist;
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
it('should work', function(done) {
|
it('should work', function(done) {
|
||||||
pgp.importKeys({
|
pgp.importKeys({
|
||||||
passphrase: passphrase,
|
passphrase: passphrase,
|
||||||
|
Loading…
Reference in New Issue
Block a user