Bug 1721668 - Test for importing an OpenPGP ASCII key block with Unicode comments. r=mkmelin
Differential Revision: https://phabricator.services.mozilla.com/D163485 --HG-- extra : rebase_source : 15cffb0bd90e30903edef0526098f18056fa8f51
This commit is contained in:
Родитель
5403a2b46a
Коммит
242558aa4d
|
@ -15,6 +15,9 @@ const { EnigmailKeyRing } = ChromeUtils.import(
|
|||
const { OpenPGPTestUtils } = ChromeUtils.import(
|
||||
"resource://testing-common/mozmill/OpenPGPTestUtils.jsm"
|
||||
);
|
||||
const { MailStringUtils } = ChromeUtils.import(
|
||||
"resource:///modules/MailStringUtils.jsm"
|
||||
);
|
||||
|
||||
const keyDir = "../../../../../test/browser/openpgp/data/keys";
|
||||
|
||||
|
@ -80,3 +83,62 @@ add_task(async function testStripSignatures() {
|
|||
// The imported stripped key should have only the self signature.
|
||||
Assert.equal(sigs[0].sigList.length, 1);
|
||||
});
|
||||
|
||||
add_task(async function testKeyWithUnicodeComment() {
|
||||
let keyFile = do_get_file(
|
||||
`${keyDir}/key-with-utf8-comment.asc`
|
||||
);
|
||||
let keyBlock = await IOUtils.readUTF8(keyFile.path);
|
||||
|
||||
let errorObj = {};
|
||||
let fingerPrintObj = {};
|
||||
let result = await EnigmailKeyRing.importKeyAsync(
|
||||
null,
|
||||
false,
|
||||
keyBlock,
|
||||
false,
|
||||
null,
|
||||
errorObj,
|
||||
fingerPrintObj,
|
||||
false,
|
||||
[],
|
||||
false,
|
||||
false
|
||||
);
|
||||
Assert.equal(result, 0);
|
||||
|
||||
let fpr = "72514F43D0060FC588E80238852C55E6D2AFD7EF";
|
||||
let foundKeys = await RNP.getKeys(["0x" + fpr]);
|
||||
|
||||
Assert.equal(foundKeys.length, 1);
|
||||
});
|
||||
|
||||
add_task(async function testBinaryKey() {
|
||||
let keyFile = do_get_file(
|
||||
`${keyDir}/key-binary.gpg`
|
||||
);
|
||||
let keyData = await IOUtils.read(keyFile.path);
|
||||
let keyBlock = MailStringUtils.uint8ArrayToByteString(keyData);
|
||||
|
||||
let errorObj = {};
|
||||
let fingerPrintObj = {};
|
||||
let result = await EnigmailKeyRing.importKeyAsync(
|
||||
null,
|
||||
false,
|
||||
keyBlock,
|
||||
true,
|
||||
null,
|
||||
errorObj,
|
||||
fingerPrintObj,
|
||||
false,
|
||||
[],
|
||||
false,
|
||||
false
|
||||
);
|
||||
Assert.equal(result, 0);
|
||||
|
||||
let fpr = "683F775BA2E5F0ADEBB29697A2D1B914F722004E";
|
||||
let foundKeys = await RNP.getKeys(["0x" + fpr]);
|
||||
|
||||
Assert.equal(foundKeys.length, 1);
|
||||
});
|
||||
|
|
Двоичный файл не отображается.
|
@ -0,0 +1,15 @@
|
|||
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||
Comment: 💌 (unicode symbol: love letter)
|
||||
Comment: 😀 (unicode symbol: smiley)
|
||||
|
||||
mDMEY4d9vRYJKwYBBAHaRw8BAQdAhoLFPAnuWEK0GKQqJfZLeIMJ8mzzo0Bxm47G
|
||||
04P6qHC0H3Rlc3QgPHRlc3QtdW5pY29kZUBleGFtcGxlLmNvbT6IkwQTFggAOxYh
|
||||
BHJRT0PQBg/FiOgCOIUsVebSr9fvBQJjh329AhsDBQsJCAcCAiICBhUKCQgLAgQW
|
||||
AgMBAh4HAheAAAoJEIUsVebSr9fvSqIA/1I5cpEa2UdGGKVXndz3HFoUq5TrRVZd
|
||||
1el8bq177HbaAQDkJlNvBxwcjW3yDVo4+nxoqm8nK1b8yPwQet2NXobcArg4BGOH
|
||||
fb0SCisGAQQBl1UBBQEBB0CqqMW7jKUygeB9+DmqMWBoWPZXiSLe4imAGj3t+h/c
|
||||
JgMBCAeIeAQYFggAIBYhBHJRT0PQBg/FiOgCOIUsVebSr9fvBQJjh329AhsMAAoJ
|
||||
EIUsVebSr9fvRbwA/ApVf9/S9YjFEcR74W/R5G+PVaL15ERHfiR0f7AYqDgiAPsG
|
||||
N+POP/0TWKb+uT/jz2QYhjxbdQsELGvWQePLhOb0Aw==
|
||||
=pPjp
|
||||
-----END PGP PUBLIC KEY BLOCK-----
|
Загрузка…
Ссылка в новой задаче