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)

defect

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.
Blocks: 1311601
Assignee: nobody → cykesiopka.bmo
Status: NEW → ASSIGNED
Priority: -- → P1
Whiteboard: [psm-cleanup] → [psm-assigned]
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 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 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 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.
keeler: See comment 11.
Flags: needinfo?(dkeeler)
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)
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
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)
(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.
Flags: needinfo?(cykesiopka.bmo)
(In reply to :Cykesiopka from comment #11) > I'll file a follow-up bug later. Bug 1316293.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: