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
|
||||
if (!openpgp.keyring.importPrivateKey(options.privateKeyArmored, options.passphrase)) {
|
||||
openpgp.keyring.init();
|
||||
callback({
|
||||
errMsg: 'Incorrect passphrase!'
|
||||
});
|
||||
@ -81,19 +82,21 @@ define(function(require) {
|
||||
var publicKey, privateKey;
|
||||
|
||||
privateKey = openpgp.keyring.exportPrivateKey(0);
|
||||
if (privateKey && privateKey.keyId) {
|
||||
publicKey = openpgp.keyring.getPublicKeysForKeyId(privateKey.keyId)[0];
|
||||
}
|
||||
|
||||
if (privateKey && privateKey.keyId && privateKey.armored && publicKey && publicKey.armored) {
|
||||
callback(null, {
|
||||
keyId: util.hexstrdump(privateKey.keyId).toUpperCase(),
|
||||
privateKeyArmored: privateKey.armored,
|
||||
publicKeyArmored: publicKey.armored
|
||||
if (!privateKey || !privateKey.keyId || !privateKey.armored || !publicKey || !publicKey.armored) {
|
||||
callback({
|
||||
errMsg: 'Could not export keys!'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
callback({
|
||||
errMsg: 'Could not export keys!'
|
||||
callback(null, {
|
||||
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() {
|
||||
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) {
|
||||
pgp.importKeys({
|
||||
passphrase: passphrase,
|
||||
|
Loading…
Reference in New Issue
Block a user