diff options
-rwxr-xr-x | otp.bash | 4 | ||||
-rw-r--r-- | pass-otp.1 | 5 | ||||
-rwxr-xr-x | test/insert.t | 18 |
3 files changed, 24 insertions, 3 deletions
@@ -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 @@ -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 |