|
@ -68,7 +68,6 @@ test03recoverKeys() { |
|
|
PASS2=1234567890 |
|
|
PASS2=1234567890 |
|
|
|
|
|
|
|
|
# make a user and check they exist |
|
|
# make a user and check they exist |
|
|
echo "create..." |
|
|
|
|
|
KEY=$(echo $PASS1 | ${EXE} new $USER -o json) |
|
|
KEY=$(echo $PASS1 | ${EXE} new $USER -o json) |
|
|
if ! assertTrue "created $USER" $?; then return 1; fi |
|
|
if ! assertTrue "created $USER" $?; then return 1; fi |
|
|
if [ -n "$DEBUG" ]; then echo $KEY; echo; fi |
|
|
if [ -n "$DEBUG" ]; then echo $KEY; echo; fi |
|
@ -79,13 +78,11 @@ test03recoverKeys() { |
|
|
assertTrue "${EXE} get $USER > /dev/null" |
|
|
assertTrue "${EXE} get $USER > /dev/null" |
|
|
|
|
|
|
|
|
# let's delete this key |
|
|
# let's delete this key |
|
|
echo "delete..." |
|
|
|
|
|
assertFalse "echo foo | ${EXE} delete $USER > /dev/null" |
|
|
assertFalse "echo foo | ${EXE} delete $USER > /dev/null" |
|
|
assertTrue "echo $PASS1 | ${EXE} delete $USER > /dev/null" |
|
|
assertTrue "echo $PASS1 | ${EXE} delete $USER > /dev/null" |
|
|
assertFalse "${EXE} get $USER > /dev/null" |
|
|
assertFalse "${EXE} get $USER > /dev/null" |
|
|
|
|
|
|
|
|
# fails on short password |
|
|
# fails on short password |
|
|
echo "recover..." |
|
|
|
|
|
assertFalse "echo foo; echo $SEED | ${EXE} recover $USER2 -o json > /dev/null" |
|
|
assertFalse "echo foo; echo $SEED | ${EXE} recover $USER2 -o json > /dev/null" |
|
|
# fails on bad seed |
|
|
# fails on bad seed |
|
|
assertFalse "echo $PASS2; echo \"silly white whale tower bongo\" | ${EXE} recover $USER2 -o json > /dev/null" |
|
|
assertFalse "echo $PASS2; echo \"silly white whale tower bongo\" | ${EXE} recover $USER2 -o json > /dev/null" |
|
@ -106,6 +103,40 @@ test03recoverKeys() { |
|
|
assertTrue "${EXE} get $USER2 > /dev/null" |
|
|
assertTrue "${EXE} get $USER2 > /dev/null" |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
# try recovery with secp256k1 keys |
|
|
|
|
|
test03recoverSecp() { |
|
|
|
|
|
USER=dings |
|
|
|
|
|
PASS1=Sbub-U9byS7hso |
|
|
|
|
|
|
|
|
|
|
|
USER2=booms |
|
|
|
|
|
PASS2=1234567890 |
|
|
|
|
|
|
|
|
|
|
|
KEY=$(echo $PASS1 | ${EXE} new $USER -o json -t secp256k1) |
|
|
|
|
|
if ! assertTrue "created $USER" $?; then return 1; fi |
|
|
|
|
|
if [ -n "$DEBUG" ]; then echo $KEY; echo; fi |
|
|
|
|
|
|
|
|
|
|
|
SEED=$(echo $KEY | jq .seed | tr -d \") |
|
|
|
|
|
ADDR=$(echo $KEY | jq .key.address | tr -d \") |
|
|
|
|
|
PUBKEY=$(echo $KEY | jq .key.pubkey | tr -d \") |
|
|
|
|
|
assertTrue "${EXE} get $USER > /dev/null" |
|
|
|
|
|
|
|
|
|
|
|
# now we got it |
|
|
|
|
|
KEY2=$((echo $PASS2; echo $SEED) | ${EXE} recover $USER2 -o json) |
|
|
|
|
|
if ! assertTrue "recovery failed: $KEY2" $?; then return 1; fi |
|
|
|
|
|
if [ -n "$DEBUG" ]; then echo $KEY2; echo; fi |
|
|
|
|
|
|
|
|
|
|
|
# make sure it looks the same |
|
|
|
|
|
NAME2=$(echo $KEY2 | jq .name | tr -d \") |
|
|
|
|
|
ADDR2=$(echo $KEY2 | jq .address | tr -d \") |
|
|
|
|
|
PUBKEY2=$(echo $KEY2 | jq .pubkey | tr -d \") |
|
|
|
|
|
assertEquals "wrong username" "$USER2" "$NAME2" |
|
|
|
|
|
assertEquals "address doesn't match" "$ADDR" "$ADDR2" |
|
|
|
|
|
assertEquals "pubkey doesn't match" "$PUBKEY" "$PUBKEY2" |
|
|
|
|
|
|
|
|
|
|
|
# and we can find the info |
|
|
|
|
|
assertTrue "${EXE} get $USER2 > /dev/null" |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
# load and run these tests with shunit2! |
|
|
# load and run these tests with shunit2! |
|
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" #get this files directory |
|
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" #get this files directory |
|
|
. $DIR/shunit2 |
|
|
. $DIR/shunit2 |