Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add back test for algorithm preferences of newly generated keys #192

Merged
merged 1 commit into from
Dec 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion test/key/utils.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from 'chai';
import { revokeKey, sign, createMessage } from '../../lib/openpgp';
import { revokeKey, sign, createMessage, enums } from '../../lib/openpgp';
import {
isExpiredKey,
isRevokedKey,
Expand Down Expand Up @@ -43,6 +43,17 @@ describe('key utils', () => {
expect(Math.abs(+privateKey.getCreationTime() - +now) < 24 * 3600).to.be.true;
});

it('generateKey - it includes the BE-expected algorithm preferences', async () => {
const { privateKey } = await generateKey({
userIDs: [{ name: 'name', email: 'email@test.com' }],
format: 'object'
});
const { selfCertification } = await privateKey.getPrimaryUser();
expect(selfCertification.preferredSymmetricAlgorithms).to.include(enums.symmetric.aes256);
expect(selfCertification.preferredHashAlgorithms).to.include(enums.hash.sha256);
expect(selfCertification.preferredCompressionAlgorithms).to.include(enums.compression.zlib);
});

it('reformatKey - it reformats a key using the key creation time', async () => {
const date = new Date(0);
const { privateKey } = await generateKey({
Expand Down