Skip to content

Runnable tests

Rory Jefferson requested to merge roryjson/rustykey:dependency-injection into trunk

#11

A few things here:

  1. A scripted e2e run of format and open in test.sh
  2. A software mock of the yubikey and tests verifying its HMAC-SHA1 implementation matches an independent crate
  3. A (breaking) refactor of the library to use traits, mocks+tests covering low-level read/write behaviour
  4. Examples of mockall working

I've removed the documented tests since all but one are now captured by automated tests.

The mocking wasn't as fiddly as expected, but does result in more boxes.

Some notes:

  • the manager module wasn't exposed. I kept the mocks+tests in the same file instead of exposing it.
  • keeping some functionality out of the handle wrapper would have been preferable, but I ran into various Rust constraints, like functions with an associated generic type (wait) not being allowed in a trait object. I've kept some of the old manager functions around to keep some inversion of control, but that's not needed for the current tests.
  • I haven't tested the Windows-specific code in the library, though it looks simple.
  • the test that's still manual is running with a yubikey slot that's not configured. This would require further changes to the library. ykman handles this case by checking the key config before writing a calculate command, and I couldn't see a way to tell just from reading the calculate response.
Edited by Rory Jefferson

Merge request reports