#nitrokey #test #env-var #pro-storage

macro nitrokey-test

Supporting test infrastructure for the nitrokey crate and others using it

9 unstable releases (4 breaking)

0.5.0 Mar 21, 2021
0.4.0 Jul 18, 2020
0.3.2 Oct 31, 2019
0.3.1 Aug 14, 2019
0.1.1 Jan 7, 2019

#8 in #nitrokey

Download history 36/week @ 2024-07-19 45/week @ 2024-07-26 46/week @ 2024-08-02 39/week @ 2024-08-09 33/week @ 2024-08-16 33/week @ 2024-08-23 38/week @ 2024-08-30 31/week @ 2024-09-06 40/week @ 2024-09-13 65/week @ 2024-09-20 48/week @ 2024-09-27 443/week @ 2024-10-04 70/week @ 2024-10-11 105/week @ 2024-10-18 105/week @ 2024-10-25 48/week @ 2024-11-01

336 downloads per month
Used in 2 crates

GPL-3.0-or-later

32KB
520 lines

pipeline crates.io Docs rustc license

nitrokey-test

nitrokey-test is a crate providing more convenient testing capabilities for the nitrokey crate and projects building on top of it.


lib.rs:

A crate providing supporting testing infrastructure for the nitrokey crate and its users.

The crate simplifies test creation by providing an attribute macro that generates code for running a test on up to three devices ( Nitrokey Pro, Nitrokey Storage, and Librem Key), takes care of serializing all tests tagged with this attribute, and causes them to be skipped if the respective device is not present.

It also provides support for running tests belonging to a certain group. There are four groups: "nodev" (representing tests that run when no device is present), "librem" (comprised of all tests that can run on the Librem Key), "pro" (encompassing tests eligible to run on the Nitrokey Pro), and "storage" (for tests running against a Nitrokey Storage device). Running tests of a specific group (and only those) can be accomplished by setting the NITROKEY_TEST_GROUP environment variable to the group of interest. Note that in this mode tests will fail if the respective device is not present.

Right now we make a few simplifying assumptions that, although not changing what can be expressed and tested, can lead to unexpected error messages when not known:

  • the parameter has to be an owned object, not a reference
  • parameter types are pattern matched against "Storage", "Pro", and "DeviceWrapper"; that means use ... as declarations will not work properly

Dependencies

~1.5MB
~37K SLoC