aboutsummaryrefslogtreecommitdiff
path: root/src/tests
Commit message (Collapse)AuthorAge
* Introduce builder-inspired way for configuring Nitrocli instanceDaniel Mueller2020-08-24
| | | | | | | | In the future we would like to provide more ways for tests to create a Nitrocli instance. In order to prevent explosion of with_XXX methods for each possible combination of arguments, this change allows for an easier configuration of an existing object with builder-pattern-inspired modifier methods.
* Remove Nitrocli::model methodDaniel Mueller2020-09-05
| | | | | | | | While the Nitrocli::model() method was well intentioned, we do not actually need it because we create a Nitrocli instance from the model passed to the individual test. We can just reuse this model instead. With this patch we do exactly that, allowing us to get rid of Nitrocli::model() all together.
* Adjust copyright & license specification to comply with REUSE 3.0Daniel Mueller2020-09-02
| | | | | | | | With this change we switch to using a REUSE compliant way of specifying the copyright & license of the program. To be fully in conformance we also add additional license specifications for the remaining files in the project. Lastly, a new CI pipeline rule takes care of verifying compliance on an ongoing basis.
* Adjust copyright string to refer to The Nitrocli DevelopersDaniel Mueller2020-09-01
| | | | | This change adjusts the copyright header in all files to no longer mention individuals but refer to The Nitrocli Developers in general.
* Merge ExecCtx and RunCtx into ContextRobin Krahl2020-09-05
| | | | | | | Since we moved the model, no_cache and verbosity fields from ExecCtx into Config and added a Config field to both ExecCtx and RunCtx, RunCtx and ExecCtx are identical. Therefore this patch merges the ExecCtx and RunCtx structs into the new Context struct.
* Add config test case and example config fileRobin Krahl2020-09-05
| | | | | | | | This patch adds a simple configuration file that demonstrates the syntax and contains some documentation. We suggest to ship this file together with nitrocli and to install it e.g., in the /usr/share/doc/nitrocli directory. This patch also adds a simple test case that makes sure that the example file is parsed correctly.
* Implement configuration handlingRobin Krahl2020-09-05
| | | | | | | | | This patch implements basic configuration handling that reads a configuration file and stores the parsed data in the ExecCtx and RunCtx structs. It supports three configuration items: - model (previously only --model) - no_cache (previously only NITROCLI_NO_CACHE) - verbosity (previously only --verbose)
* Remove application global Result definitionDaniel Mueller2020-08-31
| | | | | | | In the past we were using an application global custom Result type definition. This makes less sense now that we switched over to using anyhow's Error and Result types. We kept that for the time being, but with this change we remove the type and use anyhow::Result instead.
* Use anyhow for error handlingDaniel Mueller2020-08-28
| | | | | | | | | | | This patch changes our error handling approach from the ground up: instead of having a globally used Error enum that contains variants for all possible errors, we now use anyhow's Error type. This approach is more dynamic (and not statically typed), but it allows for more fine grained error messages and overall more user-friendly error reporting. Overall it also is a net simplification. While we have one dynamic cast now, in order to be able to handle erroneous password/PIN entries correctly, that is considered a reasonable compromise.
* Remove UnwrapError test traitDaniel Mueller2020-07-09
| | | | | | This change wraps up the removal of the UnwrapError test trait. This step prepares us for the subsequent removal of the application's global Error enum type, in favor of the usage of anyhow's Error type.
* Remove unwrap_lib_err method from UnwrapError test traitDaniel Mueller2020-07-09
| | | | | This change marks the next step in getting rid of the UnwrapError test trait. Specifically, it removes its unwrap_lib_err method.
* Remove unwrap_str_err method from UnwrapError test traitDaniel Mueller2020-07-08
| | | | | | | | | | With upcoming changes we intend to move towards a model where we do not distinguish the individual error variants the program deals with in a global enum. In preparation of such a change, this patch marks a first step in removing the UnwrapError test trait, which relies on the existence of exactly such typed errors. In particular, we remove the unwrap_str_err method from it, basically falling back to just working with strings.
* Change default OTP format to base32Daniel Mueller2020-07-07
| | | | | | | | | | | An arguably unrepresentative survey of services (GitHub, Google Authenticator, and Bitbucket) seems to suggests that the base32 format is the de-facto standard format for OTP secrets. Given that it's not necessarily obvious what format a secret is in and that most services refrain from mentioning it explicitly, having the correct default format is fairly important. With this change we switch the default format from hexadecimal to base32 to accommodate for this finding.
* Rename arg_defs.rs to args.rsDaniel Mueller2020-04-11
| | | | | | We have never been fully satisfied with the name arg_defs. Now that we have gotten rid of the formerly used args module, this change renames arg_defs to args.
* Merge remaining bits of args.rs into main.rsDaniel Mueller2020-04-11
| | | | | | This change removes the args module by moving all remaining functionality in it into main.rs. The result is arguably a nice consolidation of all context related definitions in a single module.
* Factor out arg_defs.rs for argument parsing related typesDaniel Mueller2020-04-01
| | | | | | | | This change marks the first step in a restructuring of the argument handling code, the ultimate goal of which is a separation of the type definitions as used by structopt from the logic associated with it. This change in particular introduces a new module, arg_defs, that contains all those type definitions that previously resided in the args module.
* Provide correct mutual exclusion between config set -o and -O optionsDaniel Mueller2020-01-24
| | | | | | | | | | The -o/--otp-pin and -O/--no-otp-pin options to the config set command are supposed to be mutually exclusive, with wrong usage detected by structopt. That is not the case currently, however, because the argument to structopt's conflicts_with attribute is supposed to be the resulting option and not the name of the variable capturing the result. This change fixes the problem by changing the string accordingly.
* Add unit tests for the list commandRobin Krahl2020-01-14
|
* Bump nitrokey dependency to version 0.5.1Robin Krahl2020-01-14
| | | | | | This change updates the version of the nitrokey crate that we use to 0.5.1. As part of that, it replaces occurrences of Storage::get_status with Storage::get_storage_status as the method has been renamed.
* Replace argparse with structoptRobin Krahl2020-01-07
| | | | | | | | | | | | This patch changes the argument handling code to use structopt instead of argparse using the data structures we introduced in the last patch. As part of that transition we replace the old Error::ArgparseError variant with ClapError that stores a structopt::clap::Error. Because of that replacement, the format of the help messages changed, breaking some of the tests. Hence, this change adapts them accordingly. Also clap currently prints the version output to stdout, so we ignore the version_option test case for now.
* Move nitrocli source code into repository rootDaniel Mueller2020-04-04
Now that all vendored dependencies have been removed, this change moves the program's source code from the nitrocli/ directory into the root of the repository.