blob: 095cdd5b04273c3648fc84009a9595392ed03d64 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
#!/usr/bin/env bash
export test_description='Tests pass otp code generation'
. ./setup.sh
test_expect_success 'Generates TOTP code' '
uri="otpauth://totp/Example:alice@google.com?secret=JBSWY3DPEHPK3PXP&issuer=Example"
test_pass_init &&
"$PASS" otp insert "$uri" passfile &&
code=$("$PASS" otp passfile) &&
[[ ${#code} -eq 6 ]]
'
test_expect_success 'Generates HOTP code and increments counter' '
uri="otpauth://hotp/Example:alice@google.com?secret=JBSWY3DPEHPK3PXP&counter=10&issuer=Example"
inc="otpauth://hotp/Example:alice@google.com?secret=JBSWY3DPEHPK3PXP&counter=11&issuer=Example"
test_pass_init &&
"$PASS" otp insert "$uri" passfile &&
code=$("$PASS" otp passfile) &&
[[ ${#code} -eq 6 ]] &&
[[ $("$PASS" otp uri passfile) == "$inc" ]]
'
test_done
|