| Commit message (Collapse) | Author | Age |
|
|
|
|
|
|
|
|
|
| |
If possible, check specific error codes instead of `is_err()`. This
makes the code more readable and catches bugs resulting in the wrong
error code. Also, using the assert_*_err and assert_ok macros yields
error messages containing the expected and the actual value.
To be able to use these macros with the `get_password_safe` method, we
also have to implement `Debug` for `PasswordSafe` and `Device`.
|
|
|
|
|
|
|
| |
The UnexpectedError variant is used when a libnitrokey function returns
a value that violates the function’s contract, for example if a function
returns a null pointer although it guarantees to never return null.
Previously, we returned a CommandError::Unspecified in these cases.
|
|
|
|
|
|
| |
Previously, library errors were part of the CommandError enum. As
command errors and library errors are two different error types, they
should be split into two enums.
|
|
|
|
|
|
|
| |
An error code can not only indiciate a command error, but also a library
or device communication error. Therefore, the variant for an unknown
error code should be placed in the top-level Error enum instead of the
CommandError enum.
|
|
|
|
|
|
|
|
|
| |
These macros allow easier comparisions using the new error type. This
patch fixes all tests and updates nitrokey-test to 0.2.0 so that it
integrates with the new error structure.
Some tests may still fail until CommunicationError::NotConnected is
actually returned.
|
|
|
|
|
|
|
|
|
|
|
|
| |
Until the last commit, all empty strings returned by the library were
interepreted as errors. As the PWS functions return empty strings for
unprogrammed slots, the methods to access the PWS data returned an error
when querying a slot that is not programmed. Since the last commit,
they return an empty string instead.
This patch restores the old behavior by returning an error instead of an
empty string. Yet we change the error variant: SlotNotProgrammed
instead of Undefined.
|
|
|
|
|
|
|
|
|
|
| |
We experienced various problems running the tests and while they may or
may not be caused by local setup issues, it is helpful to have more
information than just an indication that an assertion (true/false) was
violated.
To that end, this change adjusts some of the assert!(<func>().is_ok())
to compare against Ok(()) instead. This way, if the result is not the Ok
variant, the error code will get printed.
|
|
|
|
| |
This change adjusts the PWS tests to use the nitrokey-test crate.
|
|
|
|
|
|
|
|
|
|
| |
The CommandError::Unknown variant, which is used whenever a reported
error code is not known, makes it close to impossible to determine the
root cause of, say, a one-off error, because all information explaining
what went wrong is discarded.
With this change we adjust the Unknown variant to include the error
report. In addition, we introduce a new CommandError variant, Undefined,
that is used when no error code is available.
|
| |
|
|
Newer Rust versions support integration tests in a top-level tests
directory. This patch refactors the existing unit tests into
integration tests.
|