From f1b99d429a3293e781ed103104194724214c5b1c Mon Sep 17 00:00:00 2001 From: Adam Spofford <93943719+adamspofford-dfinity@users.noreply.github.com> Date: Thu, 23 Mar 2023 12:50:29 -0700 Subject: [PATCH] fix: Don't read auth in `quill generate` (#181) Stops quill from trying to read the provided pem file when running `quill generate`. Fixes #178. --- CHANGELOG.md | 1 + src/main.rs | 6 +++++- tests/commands/generate.sh | 4 ++++ tests/outputs/generate.txt | 2 ++ 4 files changed, 12 insertions(+), 1 deletion(-) create mode 100755 tests/commands/generate.sh create mode 100644 tests/outputs/generate.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index d1a0b48f..0422424e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +- Fixed `quill generate` requiring authentication. (#181) - Require an additional `--already-transferred` flag for the single-message form of `quill neuron-stake`. (#173) - Added `--disburse-amount` and `--disburse-to` to `quill neuron-manage`. (#171) - Accepts bare principals and ICRC-1 account IDs in `quill account-balance` and `quill transfer`. (#168) diff --git a/src/main.rs b/src/main.rs index 3bebe4ff..e6e47336 100755 --- a/src/main.rs +++ b/src/main.rs @@ -81,7 +81,11 @@ fn main() -> AnyhowResult { let opts = CliOpts::parse(); let qr = opts.global_opts.qr; let fetch_root_key = opts.global_opts.fetch_root_key; - let auth = get_auth(opts.global_opts)?; + let auth = if let commands::Command::Generate(_) = &opts.command { + AuthInfo::NoAuth + } else { + get_auth(opts.global_opts)? + }; commands::dispatch(&auth, opts.command, fetch_root_key, qr)?; Ok(()) } diff --git a/tests/commands/generate.sh b/tests/commands/generate.sh new file mode 100755 index 00000000..544cdf5f --- /dev/null +++ b/tests/commands/generate.sh @@ -0,0 +1,4 @@ +p=$(mktemp) +err=$(mktemp) +"$QUILL" generate --phrase "tornado allow zero warm have deer wool finish tiger ski dynamic strong" --seed-file /dev/null --overwrite-seed-file --pem-file "$p" --overwrite-pem-file &> "$err" || { cat "$err" >&2 && exit 1 ; } +"$QUILL" public-ids --pem-file "$p" diff --git a/tests/outputs/generate.txt b/tests/outputs/generate.txt new file mode 100644 index 00000000..e7a0fade --- /dev/null +++ b/tests/outputs/generate.txt @@ -0,0 +1,2 @@ +Principal id: beckf-r6bg7-t6ju6-s7k45-b5jtj-mcm57-zjaie-svgrr-7ekzs-55v75-sae +Account id: ffc463646a2c92dce58d1179d26c64d4ccbaf1079a6edc5628cedc0d4b3b1866