add xpcshell tests for opengpg messages
Categories
(MailNews Core :: Security: OpenPGP, task)
Tracking
(thunderbird_esr78+ fixed)
People
(Reporter: mkmelin, Assigned: lasana)
Details
Attachments
(1 file, 2 obsolete files)
18.94 KB,
patch
|
mkmelin
:
review+
wsmwk
:
approval-comm-esr78+
|
Details | Diff | Splinter Review |
In bug 1011625 we added tests for S/MIME. We should add similar tests for OpenPGP.
See https://hg.mozilla.org/comm-central/rev/5d7419c95b2b
Updated•4 years ago
|
Assignee | ||
Updated•4 years ago
|
Assignee | ||
Comment 1•4 years ago
|
||
Attaching this for feedback.
I think I finally adapted the test enough to test with openpgp. There is some clean up and additional assertions to add but I wanted to get some feedback before I continue.
Reporter | ||
Comment 2•4 years ago
|
||
Comment on attachment 9185321 [details] [diff] [review] bug1651490.patch Review of attachment 9185321 [details] [diff] [review]: ----------------------------------------------------------------- ::: mailnews/mime/test/unit/head_mime.js @@ +98,5 @@ > } > } > > + msgWindow = > + msgWindow != null only check falsy/truthy if (!msgWindow) { msgWindow = ..... } ::: mailnews/mime/test/unit/test_openpgp_decrypt.js @@ +49,5 @@ > + > +let gInbox; > +let openPGPEmailDir = "../../../data/openpgp/"; > + > +let headerSink = { So this is simulating Enigmail.hdrView.headerPane? Please add a code comment of what it is. Could be useful to put this functionality in OpenPGPTestUtils? @@ +165,5 @@ > + }, > +]; > + > +let gCopyWaiter = PromiseUtils.defer(); > + I think you don't need this. You have two "tasks" now, but they are just async helper functions @@ +299,5 @@ > +function run_test() { > + gInbox = configure_message_injection({ > + mode: "local", > + }); > + run_next_test(); I think it's easier to not use the run_test() version, but just add_task as you go, from top as needed
Assignee | ||
Comment 3•4 years ago
|
||
Updated the tests to use the status flags since I was more or less using them anyway and there are so many. Also included a test for the keyId though it's not always available. In future I'd like to also test the email but looks like that isn't passed to updateSecurityStatus()
. I'll file a bug for that.
These need the patch from bug 1675325 to work.
Reporter | ||
Comment 4•4 years ago
|
||
Comment on attachment 9186318 [details] [diff] [review] bug1651490v2.patch Review of attachment 9186318 [details] [diff] [review]: ----------------------------------------------------------------- ::: mailnews/mime/test/unit/head_mime.js @@ +97,5 @@ > ); > } > } > > + msgWindow = msgWindow would just do if (!msgWindow) { msgWindow = Cc["@mozilla.org/messenger/msgwindow;1"].createInstance(Ci.nsIMsgWindow); } or msgWindow = msgWIndow || Cc["@mozilla.org/messenger/msgwindow;1"].createInstance(Ci.nsIMsgWindow); ::: mailnews/mime/test/unit/test_openpgp_decrypt.js @@ +34,5 @@ > + "EnigmailCore" > +); > + > +/* import-globals-from ../../../test/resources/asyncTestUtils.js */ > +load("../../../resources/asyncTestUtils.js"); This is an old framework you should not use... it predates async and promises which is the new way. I don't see you using it directly... but maybe I didn't check closely enough. @@ +132,5 @@ > + * @type Test[] > + */ > +const tests = [ > + { > + filename: would be good to for each test add a description property that says what it's testing @@ +155,5 @@ > + "unsigned-encrypted-to-0xf231550c4f47e38e-from-0xfbfcc82a015e7330-with-key.eml", > + contents, > + from: "bob@openpgp.example", > + // keyId: OpenPGPTestUtils.BOB_KEY_ID, > + // ^keyId is not passed when message is not signed, should it? No, if it's not signed there is no key that signed. @@ +306,5 @@ > + * status flags the test specifies. > + */ > +add_task(async function testMimeDecryptOpenPGPMessages() { > + let hdrIndex = 0; > + for (let test of tests) { ... and here info(``Running test: ${test.description}`) @@ +307,5 @@ > + */ > +add_task(async function testMimeDecryptOpenPGPMessages() { > + let hdrIndex = 0; > + for (let test of tests) { > + if (test.skip) { and here also output an info that the test is being skipped
Assignee | ||
Comment 5•4 years ago
|
||
This is an old framework you should not use...
It's needed by the messageInjection.js
script.
Reporter | ||
Comment 6•4 years ago
|
||
I see. Let's go with this then. Filed bug 1676114.
Assignee | ||
Comment 7•4 years ago
|
||
Added description properties to tests.
Assignee | ||
Comment 8•4 years ago
|
||
Try run on the way, I cleaned up the linting issues in the patch attached:
https://treeherder.mozilla.org/jobs?repo=try-comm-central&selectedTaskRun=FlQ8v1lHR8SgkXdBeBYM7A.0
Reporter | ||
Comment 9•4 years ago
|
||
Comment on attachment 9186608 [details] [diff] [review] bug1651490v3.patch Review of attachment 9186608 [details] [diff] [review]: ----------------------------------------------------------------- LGTM, r=mkmelin
Reporter | ||
Updated•4 years ago
|
Comment 10•4 years ago
|
||
Pushed by thunderbird@calypsoblue.org:
https://hg.mozilla.org/comm-central/rev/8fd1b44855a3
Add mime xpcshell tests for openpgp. r=mkmelin
Comment 11•4 years ago
|
||
Pushed by mkmelin@iki.fi: https://hg.mozilla.org/comm-central/rev/9e145e871c4c followup to make the new OpenPGP xpcshell tests work after bug 1664701. rs=bustage-fix
Assignee | ||
Comment 12•4 years ago
|
||
^ Did some thing break? Can I put that change you made in an ensureOpenPGP()
function instead of executing when the module is imported?
xpcshell tests would then do:
add_task(async function(){ await OpenPGPTestUtils.ensureOpenPGP() })
Reporter | ||
Comment 13•4 years ago
|
||
Yes the push before yours changed module initialization for openpgp... which broke the test. https://treeherder.mozilla.org/jobs?repo=comm-central&revision=8fd1b44855a35346818ca6878759dfb3f1cccd05
I'm not sure any changes are needed. This would only ever be a problem in xpcshell tests, and there I think it will be fairly clear what needs doing. Maybe.
Assignee | ||
Comment 14•4 years ago
|
||
There are other things that need to be initialized before OpenPGPTestUtils
can be used in an xpcshell test, probably related to the bug for that push. It wasn't really clear at first touch.
I think they can all go in a method on OpenPGPTestUtils
. My opinion is that code should not be executed when a library style module is imported, takes control away from the importing module and leaves room for bugs.
Reporter | ||
Comment 15•4 years ago
|
||
Agreed.
Reporter | ||
Comment 16•4 years ago
|
||
Please request uplifts for this and related tests so 78 test coverage is improved.
Assignee | ||
Comment 17•4 years ago
|
||
Comment on attachment 9186608 [details] [diff] [review]
bug1651490v3.patch
[Approval Request Comment]
Regression caused by (bug #): None. Adds more tests for OpenPGP.
User impact if declined: None really.
Testing completed (on c-c, etc.): c-c
Risk to taking this patch (and alternatives if risky): None that I can think of. This makes testing OpenPGP support less manual.
Comment 18•3 years ago
|
||
Comment on attachment 9186608 [details] [diff] [review]
bug1651490v3.patch
[Triage Comment]
Approved for esr78
Comment 19•3 years ago
|
||
Description
•