tests
This commit is contained in:
parent
eb96d44298
commit
2f351985c4
|
@ -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() {
|
it('Generate key - multi userid', function() {
|
||||||
const userId1 = 'test <a@b.com>';
|
const userId1 = 'test <a@b.com>';
|
||||||
const userId2 = 'test <b@c.com>';
|
const userId2 = 'test <b@c.com>';
|
||||||
|
|
|
@ -483,10 +483,12 @@ describe('OpenPGP.js public api tests', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have default params set', function() {
|
it('should have default params set', function() {
|
||||||
|
const now = new Date();
|
||||||
const opt = {
|
const opt = {
|
||||||
userIds: { name: 'Test User', email: 'text@example.com' },
|
userIds: { name: 'Test User', email: 'text@example.com' },
|
||||||
passphrase: 'secret',
|
passphrase: 'secret',
|
||||||
unlocked: true
|
unlocked: true,
|
||||||
|
date: now
|
||||||
};
|
};
|
||||||
return openpgp.generateKey(opt).then(function(newKey) {
|
return openpgp.generateKey(opt).then(function(newKey) {
|
||||||
expect(keyGenStub.withArgs({
|
expect(keyGenStub.withArgs({
|
||||||
|
@ -495,7 +497,8 @@ describe('OpenPGP.js public api tests', function() {
|
||||||
numBits: 2048,
|
numBits: 2048,
|
||||||
unlocked: true,
|
unlocked: true,
|
||||||
keyExpirationTime: 0,
|
keyExpirationTime: 0,
|
||||||
curve: ""
|
curve: "",
|
||||||
|
date: now
|
||||||
}).calledOnce).to.be.true;
|
}).calledOnce).to.be.true;
|
||||||
expect(newKey.key).to.exist;
|
expect(newKey.key).to.exist;
|
||||||
expect(newKey.privateKeyArmored).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() {
|
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({
|
expect(keyGenStub.withArgs({
|
||||||
userIds: [],
|
userIds: [],
|
||||||
passphrase: undefined,
|
passphrase: undefined,
|
||||||
numBits: 2048,
|
numBits: 2048,
|
||||||
unlocked: false,
|
unlocked: false,
|
||||||
keyExpirationTime: 0,
|
keyExpirationTime: 0,
|
||||||
curve: ""
|
curve: "",
|
||||||
|
date: now
|
||||||
}).calledOnce).to.be.true;
|
}).calledOnce).to.be.true;
|
||||||
expect(newKey.key).to.exist;
|
expect(newKey.key).to.exist;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user