Closed
Bug 1260626
Opened 10 years ago
Closed 9 years ago
Add mechanism to allow tests to opt out of pkcs11testmodule's cyclic token insertions and removals
Categories
(Core :: Security: PSM, defect, P1)
Core
Security: PSM
Tracking
()
RESOLVED
FIXED
mozilla52
| Tracking | Status | |
|---|---|---|
| firefox52 | --- | fixed |
People
(Reporter: Cykesiopka, Assigned: Cykesiopka)
References
()
Details
(Whiteboard: [psm-assigned])
Attachments
(3 files)
The "pkcs11testmodule" is a testing PKCS #11 module that simulates a token being inserted and removed from a slot every 50ms. This behaviour is useful for what it was originally introduced for (see Bug 1038913 and test_pkcs11_insert_remove.js) and for other tests such as test_pkcs11_no_events_after_removal.js, but is annoying for other PKCS #11 tests.
Some examples:
- https://hg.mozilla.org/mozilla-central/file/cdcc256acea1/security/manager/ssl/tests/unit/test_pkcs11_slot.js#l38
- https://hg.mozilla.org/mozilla-central/file/cdcc256acea1/security/manager/ssl/tests/unit/test_pkcs11_insert_remove.js#l35
If possible, changes should be made to allow tests that don't want this cyclic behaviour to avoid it somehow, such as:
(Dana Keeler [:keeler] (use needinfo?) from Bug 1259149 comment #2)
> In another patch (that probably won't get merged since I went with another
> approach) I explored making this setup a bit easier to work with. I think we
> could essentially control whether or not the test module pretends the token
> has been inserted/removed via an environment variable. That way, the tests
> that aren't interested in this aspect don't have to deal with it.
| Assignee | ||
Updated•9 years ago
|
Assignee: nobody → cykesiopka.bmo
Status: NEW → ASSIGNED
Priority: -- → P1
Whiteboard: [psm-cleanup] → [psm-assigned]
| Comment hidden (mozreview-request) |
| Comment hidden (mozreview-request) |
| Comment hidden (mozreview-request) |
Comment 5•9 years ago
|
||
| mozreview-review | ||
Comment on attachment 8805770 [details]
Bug 1260626 - Add extra slot and token to pkcs11testmodule that is always present.
https://reviewboard.mozilla.org/r/89428/#review88960
LGTM, but see the comment below (in particular, that might require a follow-up bug).
::: security/manager/ssl/tests/unit/pkcs11testmodule/pkcs11testmodule.cpp:81
(Diff revision 1)
> if (!pulCount) {
> return CKR_ARGUMENTS_BAD;
> }
>
> if (pSlotList) {
> + if (*pulCount < 2) {
Shouldn't this check depend on the same logic that determined the value of pulCount from the previous call? (Although, now that I think about it, there's nothing that prevents tokenPresent from changing between two successive calls to this function, which might be an issue we need to address.)
Attachment #8805770 -
Flags: review?(dkeeler) → review+
Comment 6•9 years ago
|
||
| mozreview-review | ||
Comment on attachment 8805771 [details]
Bug 1260626 - Add helper function in head_psm.js to load and unload the test PKCS11 module.
https://reviewboard.mozilla.org/r/89430/#review89032
Cool - r=me. Just the one suggestion.
::: security/manager/ssl/tests/unit/head_psm.js:813
(Diff revision 1)
> + let pkcs11 = Cc["@mozilla.org/security/pkcs11;1"].getService(Ci.nsIPKCS11);
> + do_register_cleanup(() => {
> + try {
> + pkcs11.deleteModule("PKCS11 Test Module");
> + } catch (e) {
> + // The test module may have already been deleted prior to this cleanup
Looks like half of the tests that will be calling this are expecting deleteModule to succeed (and the other half are expecting it to maybe fail or to be unnecessary). Perhaps we should add a parameter to loadPKCS1TestModule to enable both scenarios?
Attachment #8805771 -
Flags: review?(dkeeler) → review+
Comment 7•9 years ago
|
||
| mozreview-review | ||
Comment on attachment 8805772 [details]
Bug 1260626 - Take advantage of the always present test token.
https://reviewboard.mozilla.org/r/89432/#review89036
Great - r=me.
Attachment #8805772 -
Flags: review?(dkeeler) → review+
| Comment hidden (mozreview-request) |
| Comment hidden (mozreview-request) |
| Comment hidden (mozreview-request) |
| Assignee | ||
Comment 11•9 years ago
|
||
| mozreview-review-reply | ||
Comment on attachment 8805770 [details]
Bug 1260626 - Add extra slot and token to pkcs11testmodule that is always present.
https://reviewboard.mozilla.org/r/89428/#review88960
> Shouldn't this check depend on the same logic that determined the value of pulCount from the previous call? (Although, now that I think about it, there's nothing that prevents tokenPresent from changing between two successive calls to this function, which might be an issue we need to address.)
I think I addressed this, but it would be good if you could take another look.
I'll file a follow-up bug later.
Comment 13•9 years ago
|
||
Yes, that looks correct to me. In any case, I don't think it matters for the moment, because NSS always calls that function with limitToTokensPresent set to false (in the lib node, not necessarily the cmd code, but that shouldn't affect this). If that ever changes, though, there might be an issue.
Flags: needinfo?(dkeeler)
| Assignee | ||
Comment 14•9 years ago
|
||
Thanks!
https://treeherder.mozilla.org/#/jobs?repo=try&revision=7f39fdc04b559451a987fec1a11a8357197ea79e
The failures look unrelated.
Keywords: checkin-needed
Comment 15•9 years ago
|
||
Pushed by cbook@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/851d4bd145a4
Add extra slot and token to pkcs11testmodule that is always present. r=keeler
https://hg.mozilla.org/integration/autoland/rev/34bca938935a
Add helper function in head_psm.js to load and unload the test PKCS11 module. r=keeler
https://hg.mozilla.org/integration/autoland/rev/e3ced3657d49
Take advantage of the always present test token. r=keeler
Keywords: checkin-needed
Comment 16•9 years ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/851d4bd145a4
https://hg.mozilla.org/mozilla-central/rev/34bca938935a
https://hg.mozilla.org/mozilla-central/rev/e3ced3657d49
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
status-firefox52:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla52
Comment 17•9 years ago
|
||
Hi Cykesiopka,
I cannot compile m-c after this patch was landed, the error is:
> c:/mozilla-source/gecko/security/manager/ssl/tests/unit/pkcs11testmodule/pkcs11testmodule.cpp(104): error C2001: newline in constant
> c:/mozilla-source/gecko/security/manager/ssl/tests/unit/pkcs11testmodule/pkcs11testmodule.cpp(106): error C2146: syntax error: missing ';' before identifier 'CK_RV'```
Looks like encoding problem?
The platform I'm using is Windows 7 x64 (Traditional Chinese).
Flags: needinfo?(cykesiopka.bmo)
| Assignee | ||
Comment 18•9 years ago
|
||
(In reply to Gary Chen [:xeonchen] from comment #17)
> Hi Cykesiopka,
>
> I cannot compile m-c after this patch was landed, the error is:
>
> > c:/mozilla-source/gecko/security/manager/ssl/tests/unit/pkcs11testmodule/pkcs11testmodule.cpp(104): error C2001: newline in constant
> > c:/mozilla-source/gecko/security/manager/ssl/tests/unit/pkcs11testmodule/pkcs11testmodule.cpp(106): error C2146: syntax error: missing ';' before identifier 'CK_RV'```
>
> Looks like encoding problem?
> The platform I'm using is Windows 7 x64 (Traditional Chinese).
Looks like this is filed as Bug 1315152 now.
| Assignee | ||
Updated•9 years ago
|
Flags: needinfo?(cykesiopka.bmo)
| Assignee | ||
Comment 19•9 years ago
|
||
You need to log in
before you can comment on or make changes to this bug.
Description
•