From 6328ba84dba608209cece19dd08a1af76bd57fe8 Mon Sep 17 00:00:00 2001 From: Morten Linderud Date: Sun, 2 Dec 2018 16:02:15 +0100 Subject: Added docs, test and completion --- otp.bash | 4 ++-- pass-otp.1 | 5 ++++- test/insert.t | 18 ++++++++++++++++++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/otp.bash b/otp.bash index 174b37f..15bd012 100755 --- a/otp.bash +++ b/otp.bash @@ -152,7 +152,7 @@ Usage: If put on the clipboard, it will be cleared in $CLIP_TIME seconds. $PROGRAM otp insert [--force,-f] [--echo,-e] - [[--secret, -s] [--issuer,-i issuer] [--account,-a account]] + [[--secret, -s] [--issuer,-i issuer] [--account,-a account] [--path,-p path-name]] [pass-name] Prompt for and insert a new OTP key. @@ -208,7 +208,7 @@ cmd_otp_insert() { --) shift; break ;; esac done - [[ $err -ne 0 ]] && die "Usage: $PROGRAM $COMMAND insert [--force,-f] [--echo,-e] [--secret, -s] [--issuer,-i issuer] [--account,-a account] [--path,-p path] [pass-name]" + [[ $err -ne 0 ]] && die "Usage: $PROGRAM $COMMAND insert [--force,-f] [--echo,-e] [--secret, -s] [--issuer,-i issuer] [--account,-a account] [--path,-p path-name] [pass-name]" local prompt path uri if [[ $# -eq 1 ]]; then diff --git a/pass-otp.1 b/pass-otp.1 index 0450850..bef89f7 100644 --- a/pass-otp.1 +++ b/pass-otp.1 @@ -39,7 +39,8 @@ seconds. This command is alternatively named \fBshow\fP. .TP \fBotp insert\fP [ \fI--force\fP, \fI-f\fP ] [ \fI--echo\fP, \fI-e\fP ] \ [ [ \fI--secret\fP, \fI-s\fP ] [ \fI--issuer\fP, \fI-i\fP \fIissuer\fP ] \ -[ \fI--account\fP, \fI-a\fP \fIaccount\fP ] ] [ \fIpass-name\fP ] +[ \fI--account\fP, \fI-a\fP \fIaccount\fP ] [ \fI--path\fP, \fI-p\fP \fIpath-name\fP ] ] \ +[ \fIpass-name\fP ] Prompt for and insert a new OTP secret into the password store at \fIpass-name\fP. @@ -60,6 +61,8 @@ convert the \fIissuer:accountname\fP URI label to a path in the form of \fI--force\fP or \fI-f\fP is specified. This command is alternatively named \fBadd\fP. +\fI--path\fP specifies a path prefix to the generated path from the URI label. + .TP \fBotp append\fP [ \fI--force\fP, \fI-f\fP ] [ \fI--echo\fP, \fI-e\fP ] \ [ [ \fI--secret\fP, \fI-s\fP ] [ \fI--issuer\fP, \fI-i\fP \fIissuer\fP ] \ diff --git a/test/insert.t b/test/insert.t index a8c6458..938a6dd 100755 --- a/test/insert.t +++ b/test/insert.t @@ -139,4 +139,22 @@ test_expect_success 'Tolerates padding in secret' ' echo [[ $("$PASS" show Example/alice@google.com) == "$uri" ]] ' +test_expect_success 'Allow path prefixes in insert' ' + secret="JBSWY3DPEHPK3PXP==" + uri="otpauth://totp/Example:alice@google.com?secret=JBSWY3DPEHPK3PXP&issuer=Example" + + test_pass_init && + "$PASS" otp insert -s -p totp -i Example -a alice@google.com <<< "$secret" && + echo [[ $("$PASS" show totp/Example/alice@google.com) == "$uri" ]] +' + +test_expect_success 'Allow multiple levels in path prefix' ' + secret="JBSWY3DPEHPK3PXP==" + uri="otpauth://totp/Example:alice@google.com?secret=JBSWY3DPEHPK3PXP&issuer=Example" + + test_pass_init && + "$PASS" otp insert -s -p totp/pass-test -i Example -a alice@google.com <<< "$secret" && + echo [[ $("$PASS" show totp/pass-test/Example/alice@google.com) == "$uri" ]] +' + test_done -- cgit v1.2.3