last perl tests migrated to unittests.sh

This commit is contained in:
Thomas von Dein
2016-10-25 21:33:16 +02:00
parent 2cb91c93e0
commit 9c78f3ad63
11 changed files with 188 additions and 183 deletions

View File

@@ -1,7 +1,7 @@
Installation Instructions Installation Instructions
************************* *************************
Copyright (C) 1994-1996, 1999-2002, 2004-2012 Free Software Foundation, Copyright (C) 1994-1996, 1999-2002, 2004-2013 Free Software Foundation,
Inc. Inc.
Copying and distribution of this file, with or without modification, Copying and distribution of this file, with or without modification,
@@ -12,8 +12,8 @@ without warranty of any kind.
Basic Installation Basic Installation
================== ==================
Briefly, the shell commands `./configure; make; make install' should Briefly, the shell command `./configure && make && make install'
configure, build, and install this package. The following should configure, build, and install this package. The following
more-detailed instructions are generic; see the `README' file for more-detailed instructions are generic; see the `README' file for
instructions specific to this package. Some packages provide this instructions specific to this package. Some packages provide this
`INSTALL' file but do not implement all of the features documented `INSTALL' file but do not implement all of the features documented

2
TODO
View File

@@ -1,3 +1,5 @@
JSON output has \0 always appended check from where this comes
pcpstream.c: use static tmp buffers, avoid alloc mem during each iteration pcpstream.c: use static tmp buffers, avoid alloc mem during each iteration
detach keysig generation from pub key export, so that an existing detach keysig generation from pub key export, so that an existing

View File

@@ -148,9 +148,6 @@
*/ */
#undef LT_OBJDIR #undef LT_OBJDIR
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
#undef NO_MINUS_C_MINUS_O
/* Name of package */ /* Name of package */
#undef PACKAGE #undef PACKAGE

View File

@@ -107,8 +107,8 @@ jsontest:
./unittests.sh jsonunittests.cfg $(CHECK) ./unittests.sh jsonunittests.cfg $(CHECK)
stresstest: check stresstest: check
./unittests.pl stresstests.cfg ./unittests.sh stresstests.cfg
iotest: check iotest: check
./unittests.pl iotests.cfg ./unittests.sh iotests.cfg
sudo umount -f env sudo umount -f env

View File

@@ -2,31 +2,31 @@
# #
# test the c++ api # test the c++ api
check-cpp-crypto () { check_cpp_crypto () {
cmd="./cpptest 0" cmd="./cpptest 0"
expect=/ok/ expect=/ok/
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-cpp-vault () { check_cpp_vault () {
cmd="./cpptest 1" cmd="./cpptest 1"
expect=/ok/ expect=/ok/
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-cpp-import-pub () { check_cpp_import_pub () {
cmd="./cpptest 2" cmd="./cpptest 2"
expect=/ok/ expect=/ok/
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-cpp-signature () { check_cpp_signature () {
cmd="./cpptest 3" cmd="./cpptest 3"
expect=/ok/ expect=/ok/
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-buffer () { check_buffer () {
cmd="./cpptest 4" cmd="./cpptest 4"
expect=/ok/ expect=/ok/
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"

View File

@@ -1,8 +1,8 @@
# -*-html-*- # -*-sh-*-
# #
# This file is part of Pretty Curved Privacy (pcp1). # This file is part of Pretty Curved Privacy (pcp1).
# #
# Copyright (C) 2013 T.Linden. # Copyright (C) 2013-2016 T.v.Dein.
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@@ -20,27 +20,29 @@
# You can contact me by mail: <tlinden AT cpan DOT org>. # You can contact me by mail: <tlinden AT cpan DOT org>.
# #
pcp = ../src/pcp1 pcp=../src/pcp1
vault = v1 vault=v1
passwd = xxx passwd=xxx
md5msg = 66b8c4ca9e5d2a7e3c0559c3cdea3d50 md5msg=66b8c4ca9e5d2a7e3c0559c3cdea3d50
include keys.cfg . ./keys.cfg
<test check-dependencies> check_dependencies_shell () {
<test check-dependencies-shell> cmd="which mdmfs"
cmd = which mdmfs expect="/mdmfs/"
expect = /mdmfs/ check "$cmd" "$expect" "$input"
</test> }
<test check-dependencies-pcp>
cmd = ls $pcp check_dependencies_pcp () {
expect = /pcp/ cmd="ls $pcp"
</test> expect="/pcp/"
</test> check "$cmd" "$expect" "$input"
}
# this one only works on freebsd for my user. sorrry # this one only works on freebsd for my user. sorrry
<test check-vault-disk-full> check_vault_disk_full () {
prepare = sudo mdmfs -s 1M -w 1001:1001 md env && dd if=/dev/zero of=env/b bs=1024 count=700 sudo mdmfs -s 1M -w 1001:1001 md env && dd if=/dev/zero of=env/b bs=1024 count=700
cmd = ./jot 100 | while read N; do if ! (echo a; echo b) | $pcp -V env/v1 -k -x x; then break; fi; done cmd="./jot 100 | while read N; do if ! (echo a; echo b) | $pcp -V env/v1 -k -x x; then break; fi; done"
expect = /Failed to copy/ expect="/Failed to copy/"
</test> check "$cmd" "$expect" "$input"
}

View File

@@ -24,72 +24,73 @@ pcp=../src/pcp1
passwd=xxx passwd=xxx
verbose=1 verbose=1
. keys.cfg . ./keys.cfg
check-json-support () { check_json_support () {
cmd="$pcp -V vja -t -j" cmd="$pcp -V vja -t -j"
expect="\"keyvaultfile\"" expect="\"keyvaultfile\""
check "$cmd" "$expect" check "$cmd" "$expect"
} }
check-json-export-public () { check_json_export_public () {
cmd="$pcp -V vja -p -j -x a -O testkeyvjapub.json" cmd="$pcp -V vja -p -j -x a -O testkeyvjapub.json"
expectfile="testkeyvjapub.json" expectfile="testkeyvjapub.json"
expect="/\"Alicia\"/" expect="/\"Alicia\"/"
check "$cmd" "$expect" "$input" "$expectfile" check "$cmd" "$expect" "$input" "$expectfile"
} }
check-json-export-secret () { check_json_export_secret () {
cmd="$pcp -V vja -s -j -x a -O testkeyvjasec.json" cmd="$pcp -V vja -s -j -x a -O testkeyvjasec.json"
expectfile="testkeyvjasec.json" expectfile="testkeyvjasec.json"
check "$cmd" "$expect" "$input" "$expectfile" check "$cmd" "$expect" "$input" "$expectfile"
} }
check-json-export-secret-isjson () {
check_json_export_secret_isjson () {
cmd="cat testkeyvjasec.json" cmd="cat testkeyvjasec.json"
expect="/\"Alicia\"/" expect="/\"Alicia\"/"
check "$cmd" "$expect" "$input" "$expectfile" check "$cmd" "$expect" "$input" ""
} }
check-json-import-public () { check_json_import_public () {
cmd="$pcp -V vjb -K -I testkeyvjapub.json -j" cmd="$pcp -V vjb -K -I testkeyvjapub.json -j"
expect="/added/" expect="/added/"
check "$cmd" "$expect" "$input" "$expectfile" check "$cmd" "$expect" "$input" ""
} }
check-json-import-public-open () { check_json_import_public_open () {
cmd="$pcp -V vjb -l" cmd="$pcp -V vjb -l"
expect="/Alicia/" expect="/Alicia/"
check "$cmd" "$expect" "$input" "$expectfile" check "$cmd" "$expect" "$input" ""
} }
check-json-import-secret () { check_json_import_secret () {
cmd="$pcp -V vjc -K -I testkeyvjasec.json -x a -j" cmd="$pcp -V vjc -K -I testkeyvjasec.json -x a -j"
expect="/added/" expect="/added/"
check "$cmd" "$expect" "$input" "$expectfile" check "$cmd" "$expect" "$input" ""
} }
check-json-import-secret-open () { check_json_import_secret_open () {
cmd="$pcp -V vjc -l" cmd="$pcp -V vjc -l"
expect="/Alicia/" expect="/Alicia/"
check "$cmd" "$expect" "$input" "$expectfile" check "$cmd" "$expect" "$input" ""
} }
check-json-text-vault () { check_json_text_vault () {
cmd="$pcp -V vjb -t -j" cmd="$pcp -V vjb -t -j"
expect="/\"Alicia\"/" expect="/\"Alicia\"/"
check "$cmd" "$expect" "$input" "$expectfile" check "$cmd" "$expect" "$input" ""
} }
check-json-text-public () { check_json_text_public () {
cmd="$pcp -V vjb -t -j -i ${idalicia}" cmd="$pcp -V vjb -t -j -i ${idalicia}"
expect="/\"Alicia\"/" expect="/\"Alicia\"/"
check "$cmd" "$expect" "$input" "$expectfile" check "$cmd" "$expect" "$input" ""
} }
check-json-text-secret () { check_json_text_secret () {
cmd="$pcp -V vjb -t -j -i ${idbobby}" cmd="$pcp -V vjb -t -j -i ${idbobby}"
expect="/\"Bobby\"/" expect="/\"Bobby\"/"
check "$cmd" "$expect" "$input" "$expectfile" check "$cmd" "$expect" "$input" ""
} }

View File

@@ -22,42 +22,42 @@
py=./pytest.py py=./pytest.py
py-import-keys () { py_import_keys () {
cmd="$py impkeys" cmd="$py impkeys"
expect=/ok/ expect=/ok/
} }
py-encrypt-asym-armor () { py_encrypt_asym_armor () {
cmd="$py asymarmor" cmd="$py asymarmor"
expect=/ok/ expect=/ok/
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
py-encrypt-asym-raw () { py_encrypt_asym_raw () {
cmd="$py asymraw" cmd="$py asymraw"
expect=/ok/ expect=/ok/
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
py-encrypt-asym-sign () { py_encrypt_asym_sign () {
cmd="$py asymsign" cmd="$py asymsign"
expect=/ok/ expect=/ok/
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
py-encrypt-asym-anon () { py_encrypt_asym_anon () {
cmd="$py asymanon" cmd="$py asymanon"
expect=/ok/ expect=/ok/
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
py-encrypt-sym-armor () { py_encrypt_sym_armor () {
cmd="$py symarmor" cmd="$py symarmor"
expect=/ok/ expect=/ok/
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
py-encrypt-sym-raw () { py_encrypt_sym_raw () {
cmd="$py symraw" cmd="$py symraw"
expect=/ok/ expect=/ok/
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"

View File

@@ -1,7 +1,8 @@
# -*-sh-*-
# #
# This file is part of Pretty Curved Privacy (pcp1). # This file is part of Pretty Curved Privacy (pcp1).
# #
# Copyright (C) 2013 T.Linden. # Copyright (C) 2013-2016 T.v.Dein.
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@@ -22,31 +23,33 @@
# #
# stress tests # stress tests
confirm = Stress tests will take some time, continue? confirm=Stress tests will take some time, continue?
pcp = ../src/pcp1 pcp=../src/pcp1
outdir = stresstest outdir =stresstest
vault = $outdir/stresstestin vault=$outdir/stresstestin
pvault = $outdir/stresstestout pvault=$outdir/stresstestout
numkeys = 100 numkeys=100
verbose = 1 verbose=1
<test check-bulk-tests> prepare () {
prepare = ./genmasskeys.sh $outdir $numkeys $pcp $vault ./genmasskeys.sh $outdir $numkeys $pcp $vault
}
<test check-bulk-generate-keys> check_bulk_generate_keys () {
cmd = $pcp -V $vault -l | grep 0x | wc -l cmd=$pcp -V $vault -l | grep 0x | wc -l
expect = $numkeys expect=$numkeys
</test> }
<test check-bulk-vault-export-publics> check_bulk_vault_export_publics () {
prepare = ./exportmasspubs.sh $outdir $pcp $vault ./exportmasspubs.sh $outdir $pcp $vault
cmd = ls -1 $outdir/0x* | wc -l cmd="ls -1 $outdir/0x* | wc -l"
expect = $numkeys expect="$numkeys"
</test> check "$cmd" "$expect" "$input"
}
<test check-bulk-import-publics> check_bulk_import_publics () {
prepare = ./importmasspubs.sh $outdir $pcp $pvault ./importmasspubs.sh $outdir $pcp $pvault
cmd = $pcp -V $pvault -l | grep 0x | wc -l cmd="$pcp -V $pvault -l | grep 0x | wc -l"
expect $numkeys expect="$numkeys"
</test> check "$cmd" "$expect" "$input"
</test> }

View File

@@ -30,87 +30,87 @@ blake2=5baec1cad5bf54287028749d83f2bf3e3ed09f0ee38a233f35dbda1361c6a67fd824e17c8
blake2auth=d7fff04bd63004f7a2ba914d9b2ccff22827230d3c546d97ebaa29cbe9fb2380b7948bc799486d512b4355c24f0cce423e746419098d4455af91898c4a06a5df blake2auth=d7fff04bd63004f7a2ba914d9b2ccff22827230d3c546d97ebaa29cbe9fb2380b7948bc799486d512b4355c24f0cce423e746419098d4455af91898c4a06a5df
key=9U3Dk2s key=9U3Dk2s
. keys.cfg . ./keys.cfg
check-dependencies-pcp () { check_dependencies_pcp () {
cmd="ls $pcp" cmd="ls $pcp"
expect="/pcp/" expect="/pcp/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-streams-8 () { check_streams_8 () {
md5=`./md5 ../COPYING` md5=`./md5 ../COPYING`
cmd="./pipetest 8 e < ../COPYING | ./pipetest 8 d | ./md5" cmd="./pipetest 8 e < ../COPYING | ./pipetest 8 d | ./md5"
expect="/$md5/" expect="/$md5/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-streams-16 () { check_streams_16 () {
md5=`./md5 ../COPYING` md5=`./md5 ../COPYING`
cmd="./pipetest 16 e < ../COPYING | ./pipetest 16 d | ./md5" cmd="./pipetest 16 e < ../COPYING | ./pipetest 16 d | ./md5"
expect="/$md5/" expect="/$md5/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-streams-32 () { check_streams_32 () {
md5=`./md5 ../COPYING` md5=`./md5 ../COPYING`
cmd="./pipetest 32 e < ../COPYING | ./pipetest 32 d | ./md5" cmd="./pipetest 32 e < ../COPYING | ./pipetest 32 d | ./md5"
expect="/$md5/" expect="/$md5/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-streams-64 () { check_streams_64 () {
md5=`./md5 ../COPYING` md5=`./md5 ../COPYING`
cmd="./pipetest 64 e < ../COPYING | ./pipetest 64 d | ./md5" cmd="./pipetest 64 e < ../COPYING | ./pipetest 64 d | ./md5"
expect="/$md5/" expect="/$md5/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-z85-1-compliant () { check_z85_1_compliant () {
cmd="./decodertest 1" cmd="./decodertest 1"
expect="/ok/" expect="/ok/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-z85-2-compliant-no-newlines () { check_z85_2_compliant_no_newlines () {
cmd="./decodertest 2" cmd="./decodertest 2"
expect="/ok/" expect="/ok/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-z85-3-compliant-no-begin-header () { check_z85_3_compliant_no_begin_header () {
cmd="./decodertest 3" cmd="./decodertest 3"
expect="/ok/" expect="/ok/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-z85-4-uncompliant-empty-comment () { check_z85_4_uncompliant_empty_comment () {
cmd="./decodertest 4" cmd="./decodertest 4"
expect="/ok/" expect="/ok/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-z85-5-uncompliant-missing-char () { check_z85_5_uncompliant_missing_char () {
cmd="./decodertest 5" cmd="./decodertest 5"
expect="/ok/" expect="/ok/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-show-help () { check_show_help () {
cmd="$pcp -h" cmd="$pcp -h"
expect="/export/" expect="/export/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-if-fail-without-vault () { check_if_fail_without_vault () {
rm -f $vault rm -f $vault
cmd="$pcp -V $vault -l" cmd="$pcp -V $vault -l"
expect="/doesn.t contain any keys so far/" expect="/doesn.t contain any keys so far/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-generate-secret-key () { check_generate_secret_key () {
cmd="$pcp -V $vault -k -x $passwd" cmd="$pcp -V $vault -k -x $passwd"
input=$(cat <<'EOF' input=$(cat <<'EOF'
Dexter Morgan Dexter Morgan
@@ -121,7 +121,7 @@ EOF
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-fail-entropy-generate-secret-key () { check_fail_entropy_generate_secret_key () {
cmd="$pcp -V $vault -k -x password" cmd="$pcp -V $vault -k -x password"
input=$(cat <<'EOF' input=$(cat <<'EOF'
Dexter Morgan Dexter Morgan
@@ -133,62 +133,62 @@ EOF
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-if-vault-contains-secret () { check_if_vault_contains_secret () {
cmd="$pcp -V $vault -l" cmd="$pcp -V $vault -l"
expect="/Dexter Morgan/" expect="/Dexter Morgan/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-secret-key-info () { check_secret_key_info () {
cmd="$pcp -V $vault -l | tail -1 | cut -d ' ' -f 1 | xargs $pcp -V $vault -t -i" cmd="$pcp -V $vault -l | tail -1 | cut -d ' ' -f 1 | xargs $pcp -V $vault -t -i"
expect="/Serial Number/" expect="/Serial Number/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-export-public-key () { check_export_public_key () {
cmd="$pcp -V $vault -l | tail -1 | cut -d ' ' -f 1 | xargs $pcp -V $vault -p -x $passwd -z -i " cmd="$pcp -V $vault -l | tail -1 | cut -d ' ' -f 1 | xargs $pcp -V $vault -p -x $passwd -z -i "
expect="/PUBLIC KEY/" expect="/PUBLIC KEY/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-export-public-key-tofile () { check_export_public_key_tofile () {
cmd="$pcp -V $vault -l | tail -1 | cut -d ' ' -f 1 | xargs $pcp -V $vault -p -x $passwd -O testkey-self -i " cmd="$pcp -V $vault -l | tail -1 | cut -d ' ' -f 1 | xargs $pcp -V $vault -p -x $passwd -O testkey-self -i "
expectfile="testkey-self" expectfile="testkey-self"
expect="" expect=""
check "$cmd" "$expect" "$input" "$expectfile" check "$cmd" "$expect" "$input" "$expectfile"
} }
check-export-public-key-filecontent () { check_export_public_key_filecontent () {
cmd="strings testkey-self" cmd="strings testkey-self"
expect="Dexter" expect="Dexter"
check "$cmd" "$expect" "$input" "$expectfile" check "$cmd" "$expect" "$input" ""
} }
check-import-public-key () { check_import_public_key () {
cmd="$pcp -V $vault -K -I bart.pub" cmd="$pcp -V $vault -K -I bart.pub"
expect="/key $bartid added/" expect="/key $bartid added/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-imported-public-key-info () { check_imported_public_key_info () {
cmd="$pcp -V $vault -t -i $bartid" cmd="$pcp -V $vault -t -i $bartid"
expect="/Serial Number: $bartserial/" expect="/Serial Number: $bartserial/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-if-delete-public-key-works () { check_if_delete_public_key_works () {
cmd="$pcp -V $vault -R -i $bartid" cmd="$pcp -V $vault -R -i $bartid"
expect="/Public key deleted/" expect="/Public key deleted/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-if-vault-still-valid () { check_if_vault_still_valid () {
cmd="$pcp -V $vault -t" cmd="$pcp -V $vault -t"
expect="/Vault version: 00000002/" expect="/Vault version: 00000002/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-if-deleted-public-key-is-away () { check_if_deleted_public_key_is_away () {
cmd="$pcp -V $vault -t" cmd="$pcp -V $vault -t"
expect="/Public keys: 0/" expect="/Public keys: 0/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
@@ -198,69 +198,69 @@ check-if-deleted-public-key-is-away () {
# #
# encryption tests # encryption tests
# alicias part # alicias part
check-crypto-alicia-import-secret () { check_crypto_alicia_import_secret () {
cmd="$pcp -V va -K -I key-alicia-sec -x a" cmd="$pcp -V va -K -I key-alicia-sec -x a"
expect="/${idalicia}/" expect="/${idalicia}/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-crypto-alicia-import-bobbys-key () { check_crypto_alicia_import_bobbys_key () {
cmd="$pcp -V va -K -I key-bobby-pub" cmd="$pcp -V va -K -I key-bobby-pub"
expect="/${idbobby}/" expect="/${idbobby}/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-crypto-alicia-encrypt () { check_crypto_alicia_encrypt () {
cmd="$pcp -V va -e -i ${idbobby} -I testmessage -O testencrypted -x a" cmd="$pcp -V va -e -i ${idbobby} -I testmessage -O testencrypted -x a"
expect="/${idbobby} - Bobby/" expect="/${idbobby} - Bobby/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-crypto-alicia-encrypt-anonymous () { check_crypto_alicia_encrypt_anonymous () {
cmd="$pcp -V va -e -A -i ${idbobby} -I testmessage -O testencryptedanon -x a" cmd="$pcp -V va -e -A -i ${idbobby} -I testmessage -O testencryptedanon -x a"
expect="/${idbobby} - Bobby/" expect="/${idbobby} - Bobby/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
# bobbys part # bobbys part
check-crypto-bobby-import-secret () { check_crypto_bobby_import_secret () {
cmd="$pcp -V vb -K -I key-bobby-sec -x b" cmd="$pcp -V vb -K -I key-bobby-sec -x b"
expect="/${idbobby}/" expect="/${idbobby}/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-crypto-bobby-decrypt-anonymous () { check_crypto_bobby_decrypt_anonymous () {
# decrypt anon, without knowing alicias key # decrypt anon, without knowing alicias key
cmd="$pcp -V vb -d -O testdecryptedanon -I testencryptedanon -x b" cmd="$pcp -V vb -d -O testdecryptedanon -I testencryptedanon -x b"
expect="/successfully/" expect="/successfully/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-crypto-alicia-import-alicias-key () { check_crypto_alicia_import_alicias_key () {
cmd="$pcp -V vb -K -I key-alicia-pub" cmd="$pcp -V vb -K -I key-alicia-pub"
expect="/${idalicia}/" expect="/${idalicia}/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-crypto-bobby-decrypt () { check_crypto_bobby_decrypt () {
cmd="$pcp -V vb -d -O testdecrypted -I testencrypted -x b" cmd="$pcp -V vb -d -O testdecrypted -I testencrypted -x b"
expect="/successfully/" expect="/successfully/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-crypto-alicia-encrypted-file () { check_crypto_alicia_encrypted_file () {
cmd="cat testdecrypted" cmd="cat testdecrypted"
expect="/${md5msg}/" expect="/${md5msg}/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-crypto-alicia-encrypt-self () { check_crypto_alicia_encrypt_self () {
cmd="$pcp -V va -e -M -I testmessage -O testencryptedself -x a" cmd="$pcp -V va -e -M -I testmessage -O testencryptedself -x a"
expect="/Alicia/" expect="/Alicia/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-crypto-alicia-deencrypt-self () { check_crypto_alicia_deencrypt_self () {
cmd="$pcp -V va -d -I testencryptedself -O testdecrypted -x a" cmd="$pcp -V va -d -I testencryptedself -O testdecrypted -x a"
expect="/successfully/" expect="/successfully/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
@@ -268,13 +268,13 @@ check-crypto-alicia-deencrypt-self () {
# #
# symetric encryption test # symetric encryption test
check-sym-encrypt () { check_sym_encrypt () {
cmd="echo HELLOWORLD | $pcp -e -O testsymencrypted -x a" cmd="echo HELLOWORLD | $pcp -e -O testsymencrypted -x a"
expect="/symetrically/" expect="/symetrically/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-sym-decrypt () { check_sym_decrypt () {
cmd="$pcp -d -I testsymencrypted -x a" cmd="$pcp -d -I testsymencrypted -x a"
expect="/HELLO/" expect="/HELLO/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
@@ -283,26 +283,26 @@ check-sym-decrypt () {
# #
# signature tests # signature tests
check-sign-detached-to-bobby () { check_sign_detached_to_bobby () {
cmd="$pcp -V va -g -I README -f testsig -x a" cmd="$pcp -V va -g -I README -f testsig -x a"
expectfile="testsig" expectfile="testsig"
expect="" expect=""
check "$cmd" "$expect" "$input" "$expectfile" check "$cmd" "$expect" "$input" "$expectfile"
} }
check-verify-detached-signature () { check_verify_detached_signature () {
cmd="$pcp -V vb -c -f testsig -I README -i $idalicia" cmd="$pcp -V vb -c -f testsig -I README -i $idalicia"
expect="/verified/" expect="/verified/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-verify-detached-signature-self () { check_verify_detached_signature_self () {
cmd="$pcp -V va -c -f testsig -I README" cmd="$pcp -V va -c -f testsig -I README"
expect="/verified/" expect="/verified/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-sign-armored-to-bobby () { check_sign_armored_to_bobby () {
rm -f testsig rm -f testsig
cmd="$pcp -V va -g -I README -O testsig -x a -z" cmd="$pcp -V va -g -I README -O testsig -x a -z"
expectfile="testsig" expectfile="testsig"
@@ -310,19 +310,19 @@ check-sign-armored-to-bobby () {
check "$cmd" "$expect" "$input" "$expectfile" check "$cmd" "$expect" "$input" "$expectfile"
} }
check-verify-armored-signature () { check_verify_armored_signature () {
cmd="$pcp -V vb -c -I testsig -i $idalicia -z" cmd="$pcp -V vb -c -I testsig -i $idalicia -z"
expect="/verified/" expect="/verified/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-verify-armored-signature-self () { check_verify_armored_signature_self () {
cmd="$pcp -V va -c -I testsig -z" cmd="$pcp -V va -c -I testsig -z"
expect="/verified/" expect="/verified/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-sign-bin-to-bobby () { check_sign_bin_to_bobby () {
rm -f testsig rm -f testsig
cmd="$pcp -V va -g -I README -O testsig -x a" cmd="$pcp -V va -g -I README -O testsig -x a"
expectfile="testsig" expectfile="testsig"
@@ -330,13 +330,13 @@ check-sign-bin-to-bobby () {
check "$cmd" "$expect" "$input" "$expectfile" check "$cmd" "$expect" "$input" "$expectfile"
} }
check-verify-bin-signature () { check_verify_bin_signature () {
cmd="$pcp -V vb -c -I testsig -i $idalicia" cmd="$pcp -V vb -c -I testsig -i $idalicia"
expect="/verified/" expect="/verified/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-verify-bin-signature-self () { check_verify_bin_signature_self () {
cmd="$pcp -V va -c -I testsig " cmd="$pcp -V va -c -I testsig "
expect="/verified/" expect="/verified/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
@@ -344,19 +344,19 @@ check-verify-bin-signature-self () {
# #
# sign+encrypt tests # sign+encrypt tests
check-sign-crypt-to-bobby () { check_sign_crypt_to_bobby () {
cmd="$pcp -V va -g -e -I README -O testsig -r Bobby -x a" cmd="$pcp -V va -g -e -I README -O testsig -r Bobby -x a"
expect="/Encrypted/" expect="/Encrypted/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-verify-decrypt-from-alicia () { check_verify_decrypt_from_alicia () {
cmd="$pcp -V vb -c -d -I testsig -x b" cmd="$pcp -V vb -c -d -I testsig -x b"
expect="/Verified/" expect="/Verified/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-verify-decrypt-from-alicia-determine () { check_verify_decrypt_from_alicia_determine () {
cmd="$pcp -V vb -d -I testsig -x b" cmd="$pcp -V vb -d -I testsig -x b"
expect="/Verified/" expect="/Verified/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
@@ -364,7 +364,7 @@ check-verify-decrypt-from-alicia-determine () {
# #
# raw C test with prepared keys, message and cipher # raw C test with prepared keys, message and cipher
check-raw-decrypt () { check_raw_decrypt () {
cmd="./statictest" cmd="./statictest"
expect="/ok/" expect="/ok/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
@@ -373,159 +373,159 @@ check-raw-decrypt () {
# #
# negative tests, check for error handling # negative tests, check for error handling
check-if-catch-conflicting-params () { check_if_catch_conflicting_params () {
cmd="$pcp -V $vault -K -K" cmd="$pcp -V $vault -K -K"
expect="/invalid combination of commandline parameters/" expect="/invalid combination of commandline parameters/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-infile-error () { check_infile_error () {
cmd="$pcp -V $vault -I nonexist -K" cmd="$pcp -V $vault -I nonexist -K"
expect="/Could not open input file nonexist/" expect="/Could not open input file nonexist/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-import-without-id-error () { check_import_without_id_error () {
cmd="$pcp -V $vault -R" cmd="$pcp -V $vault -R"
expect="/You need to specify a key id/" expect="/You need to specify a key id/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-catch-invalid-short-keyid () { check_catch_invalid_short_keyid () {
cmd="$pcp -V $vault -R -i 0x1" cmd="$pcp -V $vault -R -i 0x1"
expect="/is too short/" expect="/is too short/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-catch-invalid-long-keyid () { check_catch_invalid_long_keyid () {
cmd="$pcp -V $vault -R -i 0x1111111111111111111111111" cmd="$pcp -V $vault -R -i 0x1111111111111111111111111"
expect="/is too long/" expect="/is too long/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-catch-invalid-long-keyid-without-0x () { check_catch_invalid_long_keyid_without_0x () {
cmd="$pcp -V $vault -R -i 11111111111111111" cmd="$pcp -V $vault -R -i 11111111111111111"
expect="/is too long/" expect="/is too long/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-catch-delete-nonexist () { check_catch_delete_nonexist () {
cmd="$pcp -V $vault -R -i 0x0101010101010101" cmd="$pcp -V $vault -R -i 0x0101010101010101"
expect="/No key with id 0x010101/" expect="/No key with id 0x010101/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-if-export-secret-catch-nonexistent-keyid () { check_if_export_secret_catch_nonexistent_keyid () {
cmd="$pcp -V $vault -s -i 0x0101010101010101" cmd="$pcp -V $vault -s -i 0x0101010101010101"
expect="/Could not find a secret key with id 0x010101/" expect="/Could not find a secret key with id 0x010101/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-if-export-secret-catch-no-primary () { check_if_export_secret_catch_no_primary () {
$pcp -V v2 -l # so we've got just an empty vault $pcp -V v2 -l # so we've got just an empty vault
cmd="$pcp -V v2 -s" cmd="$pcp -V v2 -s"
expect="/no primary secret key in the vault/" expect="/no primary secret key in the vault/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-if-export-secret-catch-outfile-error () { check_if_export_secret_catch_outfile_error () {
cmd=" $pcp -V $vault -l | grep primary |cut -d ' ' -f 1 | xargs $pcp -V $vault -s -O nonexistentdir/keyfile -i" cmd=" $pcp -V $vault -l | grep primary |cut -d ' ' -f 1 | xargs $pcp -V $vault -s -O nonexistentdir/keyfile -i"
expect="/Could not create output file nonexistentdir/" expect="/Could not create output file nonexistentdir/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-if-export-public-catch-nonexistent-keyid () { check_if_export_public_catch_nonexistent_keyid () {
cmd="$pcp -V $vault -p -i 0x0101010101010101" cmd="$pcp -V $vault -p -i 0x0101010101010101"
expect="/Could not find a key with id 0x010101/" expect="/Could not find a key with id 0x010101/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-if-export-public-catch-no-primary () { check_if_export_public_catch_no_primary () {
$pcp -V v3 -l # so we've got just an empty vault $pcp -V v3 -l # so we've got just an empty vault
cmd="$pcp -V v3 -p" cmd="$pcp -V v3 -p"
expect="/no primary secret key in the vault/" expect="/no primary secret key in the vault/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-if-export-public-catch-outfile-error () { check_if_export_public_catch_outfile_error () {
$pcp -V $vault -K -I bart.pub $pcp -V $vault -K -I bart.pub
cmd="$pcp -V $vault -l | grep public | cut -d ' ' -f 1 | tail -1 | xargs $pcp -V $vault -p -O nonexistentdir/keyfile" cmd="$pcp -V $vault -l | grep public | cut -d ' ' -f 1 | tail -1 | xargs $pcp -V $vault -p -O nonexistentdir/keyfile"
expect="/Could not create output file nonexistentdir/" expect="/Could not create output file nonexistentdir/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-if-catch-empty-input () { check_if_catch_empty_input () {
touch testfile-empty touch testfile-empty
cmd="$pcp -V $vault -K -I testfile-empty" cmd="$pcp -V $vault -K -I testfile-empty"
expect="/file is empty/" expect="/file is empty/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-if-catch-missing-newlines () { check_if_catch_missing_newlines () {
perl -e 'print "X" x 5000; print "\n"' > testfile-toolong perl -e 'print "X" x 5000; print "\n"' > testfile-toolong
cmd="$pcp -V $vault -K -I testfile-toolong -x x" cmd="$pcp -V $vault -K -I testfile-toolong -x x"
expect="/failed/" expect="/failed/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-if-catch-nokey-behind-z85 () { check_if_catch_nokey_behind_z85 () {
./jot 30 | while read ignore; do echo XXXXX; done | $pcp -z > testfile-nokey ./jot 30 | while read ignore; do echo XXXXX; done | $pcp -z > testfile-nokey
cmd="$pcp -V $vault -K -I testfile-nokey -x x" cmd="$pcp -V $vault -K -I testfile-nokey -x x"
expect="/failed/" expect="/failed/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-if-sanity-catch-keyexists () { check_if_sanity_catch_keyexists () {
cmd="$pcp -V $vault -K -I bart.pub" cmd="$pcp -V $vault -K -I bart.pub"
expect="/there already exists a key/" expect="/there already exists a key/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-if-catch-nokeys () { check_if_catch_nokeys () {
$pcp -V v3 -l $pcp -V v3 -l
cmd="$pcp -V v3 -l" cmd="$pcp -V v3 -l"
expect="/contain any keys so far/" expect="/contain any keys so far/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-testkey-wrong-version () { check_testkey_wrong_version () {
cmd="$pcp -V $vault -K -I testkey-wrong-version -x xxx" cmd="$pcp -V $vault -K -I testkey-wrong-version -x xxx"
expect="/unknown key version/" expect="/unknown key version/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-testkey-wrong-serial () { check_testkey_wrong_serial () {
cmd="$pcp -V $vault -K -I testkey-wrong-serial -x xxx" cmd="$pcp -V $vault -K -I testkey-wrong-serial -x xxx"
expect="/invalid serial number/" expect="/invalid serial number/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-testkey-wrong-ctime () { check_testkey_wrong_ctime () {
cmd="$pcp -V $vault -K -I testkey-invalid-ctime -x xxx" cmd="$pcp -V $vault -K -I testkey-invalid-ctime -x xxx"
expect="/invalid creation timestamp/" expect="/invalid creation timestamp/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-vault-invalid-header () { check_vault_invalid_header () {
cmd="$pcp -V testvault-invalidheader -l" cmd="$pcp -V testvault-invalidheader -l"
expect="/Unexpected vault file format/" expect="/Unexpected vault file format/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-vault-invalid-version () { check_vault_invalid_version () {
cmd="$pcp -V testvault-invalidversion -l" cmd="$pcp -V testvault-invalidversion -l"
expect="/Unexpected vault file format/" expect="/Unexpected vault file format/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-vault-invalid-itemtype () { check_vault_invalid_itemtype () {
cmd="$pcp -V testvault-invaliditemtype -l" cmd="$pcp -V testvault-invaliditemtype -l"
expect="/invalid key type/" expect="/invalid key type/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-vault-invalid-keytype () { check_vault_invalid_keytype () {
cmd="$pcp -V testvault-invalidkeytype -l" cmd="$pcp -V testvault-invalidkeytype -l"
expect="/contain any keys so far./" expect="/contain any keys so far./"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
@@ -534,7 +534,7 @@ check-vault-invalid-keytype () {
# #
# input handling tests # input handling tests
check-large-meta () { check_large_meta () {
cmd="(./jot 300 | while read m; do echo -n m; done; echo $passwd) | $pcp -V $vault -k -x $passwd" cmd="(./jot 300 | while read m; do echo -n m; done; echo $passwd) | $pcp -V $vault -k -x $passwd"
expect="/Generated new secret key/" expect="/Generated new secret key/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
@@ -542,7 +542,7 @@ check-large-meta () {
# #
# fuzz tests # fuzz tests
check-fuzz-binary-pubkey () { check_fuzz_binary_pubkey () {
expect="!/added/" expect="!/added/"
cmd="echo no | $pcp -V vf -K -I testfuzzP.pub -x $passwd" cmd="echo no | $pcp -V vf -K -I testfuzzP.pub -x $passwd"
@@ -556,7 +556,7 @@ check-fuzz-binary-pubkey () {
done done
} }
check-fuzz-binary-seckey () { check_fuzz_binary_seckey () {
cmd="echo no | $pcp -V vf -K -I testfuzzS.sec -x $passwd" cmd="echo no | $pcp -V vf -K -I testfuzzS.sec -x $passwd"
expect="!/added/" expect="!/added/"
for N in `./jot 30`; do for N in `./jot 30`; do
@@ -571,25 +571,25 @@ check-fuzz-binary-seckey () {
# checksum tests # checksum tests
check-checksum-copying () { check_checksum_copying () {
cmd="$pcp -C ../COPYING" cmd="$pcp -C ../COPYING"
expect="/$blake2/" expect="/$blake2/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-checksum-authenticated-copying () { check_checksum_authenticated_copying () {
cmd="$pcp -x $key -C ../COPYING" cmd="$pcp -x $key -C ../COPYING"
expect="/$blake2auth/" expect="/$blake2auth/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-checksum-copying-stdin () { check_checksum_copying_stdin () {
cmd="$pcp -C < ../COPYING" cmd="$pcp -C < ../COPYING"
expect="/$blake2/" expect="/$blake2/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"
} }
check-checksum-multiple () { check_checksum_multiple () {
cmd="$pcp -C ../COPYING ../README" cmd="$pcp -C ../COPYING ../README"
expect="/README/" expect="/README/"
check "$cmd" "$expect" "$input" check "$cmd" "$expect" "$input"

View File

@@ -1,24 +1,24 @@
#!/bin/sh #!/bin/sh
errout () { errout () {
log="$1" logout="$1"
expect="$2" expect="$2"
echo " EXPECTED: $expect" echo " EXPECTED: $expect"
echo -n " GOT: " echo -n " GOT: "
cat $log | head -1 cat $logout | head -1
cat $log | tail +2 | sed 's/^/ /' cat $logout | tail -n +2 | sed 's/^/ /'
} }
lookup () { lookup () {
log="$1" logfile="$1"
expect="$2" expect="$2"
if echo "$expect" | grep '!' > /dev/null 2>&2; then if echo "$expect" | grep '!' > /dev/null 2>&2; then
# negate # negate
expect=`echo "$expect" | sed -e 's/^\!//' -e 's#^/##' -e 's#/$##'` expect=`echo "$expect" | sed -e 's/^\!//' -e 's#^/##' -e 's#/$##'`
if cat $log | grep "$expect" > /dev/null 2>&1; then if cat $logfile | grep -i "$expect" > /dev/null 2>&1; then
errout "$log" "NOT $expect" errout "$logfile" "NOT $expect"
return 1 return 1
else else
echo " OK" echo " OK"
@@ -26,11 +26,11 @@ lookup () {
fi fi
else else
expect=`echo "$expect" | sed -e 's#^/##' -e 's#/$##'` expect=`echo "$expect" | sed -e 's#^/##' -e 's#/$##'`
if cat $log | grep "$expect" > /dev/null 2>&1; then if cat $logfile | grep -i "$expect" > /dev/null 2>&1; then
echo " OK" echo " OK"
return 0 return 0
else else
errout "$log" "$expect" errout "$logfile" "$expect"
return 1 return 1
fi fi
fi fi
@@ -52,7 +52,7 @@ check() {
# ignore result, check output file # ignore result, check output file
if test -n "$expect"; then if test -n "$expect"; then
# look for string in output # look for string in output
if ! lookup "$log" "$expect"; then if ! lookup "$file" "$expect"; then
fail=y fail=y
fi fi
else else
@@ -116,16 +116,16 @@ if ! test -e "$cfg"; then
exit 1 exit 1
fi fi
. $cfg . ./$cfg
count=`grep -E -- "^check-" "$cfg" | wc -l` count=`grep -E -- "^check_" "$cfg" | wc -l`
callcheck prepare callcheck prepare
if test -n "$check"; then if test -n "$check"; then
callcheck $check callcheck $check
else else
for F in `grep -E -- "^check-" "$cfg" | cut -d' ' -f1`; do for F in `grep -E -- "^check_" "$cfg" | cut -d' ' -f1`; do
callcheck $F callcheck $F
done done
echo "All Tests OK" echo "All Tests OK"