This commit is contained in:
Sanjana Rajan 2018-03-19 18:55:30 -07:00
parent eb96d44298
commit 2f351985c4
2 changed files with 27 additions and 4 deletions

View File

@ -1076,6 +1076,23 @@ describe('Key', function() {
});
});
it('Generate key - setting date to the past', function() {
const past = new Date(0);
const opt = {
userIds: { name: 'Test User', email: 'text@example.com' },
passphrase: 'secret',
unlocked: true,
date: past
};
return openpgp.generateKey(opt).then(function(newKey) {
expect(newKey.key).to.exist;
expect(+newKey.key.primaryKey.created).to.equal(+past);
expect(+newKey.key.subKeys[0].subKey.created).to.equal(+past);
expect(+newKey.key.subKeys[0].bindingSignatures[0].created).to.equal(+past);
});
})
it('Generate key - multi userid', function() {
const userId1 = 'test <a@b.com>';
const userId2 = 'test <b@c.com>';

View File

@ -483,10 +483,12 @@ describe('OpenPGP.js public api tests', function() {
});
it('should have default params set', function() {
const now = new Date();
const opt = {
userIds: { name: 'Test User', email: 'text@example.com' },
passphrase: 'secret',
unlocked: true
unlocked: true,
date: now
};
return openpgp.generateKey(opt).then(function(newKey) {
expect(keyGenStub.withArgs({
@ -495,7 +497,8 @@ describe('OpenPGP.js public api tests', function() {
numBits: 2048,
unlocked: true,
keyExpirationTime: 0,
curve: ""
curve: "",
date: now
}).calledOnce).to.be.true;
expect(newKey.key).to.exist;
expect(newKey.privateKeyArmored).to.exist;
@ -504,14 +507,17 @@ describe('OpenPGP.js public api tests', function() {
});
it('should work for no params', function() {
return openpgp.generateKey().then(function(newKey) {
const now = new Date();
return openpgp.generateKey({date: now}).then(function(newKey) {
expect(keyGenStub.withArgs({
userIds: [],
passphrase: undefined,
numBits: 2048,
unlocked: false,
keyExpirationTime: 0,
curve: ""
curve: "",
date: now
}).calledOnce).to.be.true;
expect(newKey.key).to.exist;
});