Fix key validation tests
This commit is contained in:
parent
5801169432
commit
8783caa828
|
@ -2725,7 +2725,7 @@ describe('Key', function() {
|
||||||
|
|
||||||
it("validate() - don't throw if key parameters correspond", async function() {
|
it("validate() - don't throw if key parameters correspond", async function() {
|
||||||
const { key } = await openpgp.generateKey({ userIds: {}, curve: 'ed25519' });
|
const { key } = await openpgp.generateKey({ userIds: {}, curve: 'ed25519' });
|
||||||
expect(key.validate()).to.not.be.rejected;
|
await expect(key.validate()).to.not.be.rejected;
|
||||||
});
|
});
|
||||||
|
|
||||||
it("validate() - throw if all-gnu-dummy key", async function() {
|
it("validate() - throw if all-gnu-dummy key", async function() {
|
||||||
|
@ -2735,17 +2735,17 @@ describe('Key', function() {
|
||||||
|
|
||||||
it("validate() - gnu-dummy primary key with signing subkey", async function() {
|
it("validate() - gnu-dummy primary key with signing subkey", async function() {
|
||||||
const { keys: [key] } = await openpgp.key.readArmored(gnuDummyKeySigningSubkey);
|
const { keys: [key] } = await openpgp.key.readArmored(gnuDummyKeySigningSubkey);
|
||||||
expect(key.validate()).to.not.be.rejected;
|
await expect(key.validate()).to.not.be.rejected;
|
||||||
});
|
});
|
||||||
|
|
||||||
it("validate() - gnu-dummy primary key with encryption subkey", async function() {
|
it("validate() - gnu-dummy primary key with encryption subkey", async function() {
|
||||||
const { keys: [key] } = await openpgp.key.readArmored(dsaGnuDummyKeyWithElGamalSubkey);
|
const { keys: [key] } = await openpgp.key.readArmored(dsaGnuDummyKeyWithElGamalSubkey);
|
||||||
expect(key.validate()).to.not.be.rejected;
|
await expect(key.validate()).to.not.be.rejected;
|
||||||
});
|
});
|
||||||
|
|
||||||
it("validate() - curve ed25519 (eddsa) cannot be used for ecdsa", async function() {
|
it("validate() - curve ed25519 (eddsa) cannot be used for ecdsa", async function() {
|
||||||
const { keys: [key] } = await openpgp.key.readArmored(eddsaKeyAsEcdsa);
|
const { keys: [key] } = await openpgp.key.readArmored(eddsaKeyAsEcdsa);
|
||||||
expect(key.validate()).to.be.rejectedWith('Key is invalid');
|
await expect(key.validate()).to.be.rejectedWith('Key is invalid');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('clearPrivateParams() - check that private key can no longer be used', async function() {
|
it('clearPrivateParams() - check that private key can no longer be used', async function() {
|
||||||
|
@ -2755,13 +2755,15 @@ describe('Key', function() {
|
||||||
await expect(key.validate()).to.be.rejectedWith('Key is not decrypted');
|
await expect(key.validate()).to.be.rejectedWith('Key is not decrypted');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('clearPrivateParams() - check that private key parameters were removed', async function() {
|
it('clearPrivateParams() - detect that private key parameters were removed', async function() {
|
||||||
const { keys: [key] } = await openpgp.key.readArmored(priv_key_rsa);
|
const { keys: [key] } = await openpgp.key.readArmored(priv_key_rsa);
|
||||||
await key.decrypt('hello world');
|
await key.decrypt('hello world');
|
||||||
const params = key.primaryKey.params;
|
const params = key.primaryKey.params;
|
||||||
await key.clearPrivateParams();
|
await key.clearPrivateParams();
|
||||||
key.primaryKey.isEncrypted = false;
|
key.primaryKey.isEncrypted = false;
|
||||||
key.primaryKey.params = params;
|
key.primaryKey.params = params;
|
||||||
|
key.subKeys[0].keyPacket.isEncrypted = false;
|
||||||
|
key.subKeys[0].keyPacket.params = params;
|
||||||
await expect(key.validate()).to.be.rejectedWith('Missing key parameters');
|
await expect(key.validate()).to.be.rejectedWith('Missing key parameters');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -2772,10 +2774,9 @@ describe('Key', function() {
|
||||||
await key.clearPrivateParams();
|
await key.clearPrivateParams();
|
||||||
key.primaryKey.isEncrypted = false;
|
key.primaryKey.isEncrypted = false;
|
||||||
key.primaryKey.params = params;
|
key.primaryKey.params = params;
|
||||||
const use_nativeVal = openpgp.config.use_native;
|
key.subKeys[0].keyPacket.isEncrypted = false;
|
||||||
openpgp.config.use_native = false;
|
key.subKeys[0].keyPacket.params = params;
|
||||||
expect(key.validate()).to.be.rejectedWith('Key is invalid');
|
await expect(key.validate()).to.be.rejectedWith('Key is invalid');
|
||||||
openpgp.config.use_native = use_nativeVal;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('update() - throw error if fingerprints not equal', async function() {
|
it('update() - throw error if fingerprints not equal', async function() {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user