Skip to content

Commit

Permalink
🧪 More detailed testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mihara committed Jun 25, 2023
1 parent d5b474e commit 48a0a39
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,40 @@

# This is a preliminary smoke test engine, and not a proper integration test framework.
# Yet. It lets people run tests without ever touching their real key file though.
# Currently will not work properly on Windows: text mode tests assume
# starting with a Linux line endings file.

CACHE=testcases/keys/cache
KEY=testcases/keys/N0CALL.p12
SRC=testcases/files
DST=testcases/results

# Straightforward signature.
echo === Straightforward test: must pass.
go run *.go sign -c $CACHE -p changeme $KEY $SRC/sstv.jpg $DST/sstv-signed.jpg
go run *.go verify -c $CACHE $DST/sstv-signed.jpg $DST/sstv-unsigned.jpg
cmp -l $SRC/sstv.jpg $DST/sstv-unsigned.jpg

# Uncompressed signature.
echo === Uncompressed signature test: must pass.
go run *.go sign -c $CACHE -p changeme -u -a $KEY $SRC/sstv.jpg $DST/sstv-signed-unc.jpg
go run *.go verify -c $CACHE $DST/sstv-signed-unc.jpg $DST/sstv-unsigned.jpg
cmp -l $SRC/sstv.jpg $DST/sstv-unsigned.jpg

# Text mode signing.
echo === Detached signature test: must pass.
go run *.go sign -c $CACHE -p changeme -s $DST/sstv.jpg.sig -a $KEY $SRC/sstv.jpg
go run *.go verify -c $CACHE $DST/sstv-signed-unc.jpg

echo === Damaged file: must fail.
printf "00000c: %02x" $b_dec | xxd -r - $DST/sstv-signed.jpg
go run *.go verify -c $CACHE $DST/sstv-signed.jpg

echo === Text mode tests -- native line endings: must pass.
go run *.go sign -t -c $CACHE -p changeme $KEY $SRC/lipsum.txt $DST/lipsum-signed.txt
go run *.go verify -t -c $CACHE $DST/lipsum-signed.txt $DST/lipsum-unsigned.txt

echo === Text mode tests -- mac line endings: must pass.
unix2mac -n $DST/lipsum-signed.txt $DST/lipsum-signed-mac.txt
go run *.go verify -t -c $CACHE $DST/lipsum-signed-mac.txt $DST/lipsum-unsigned-mac.txt

echo === Text mode tests -- dos line endings: must pass.
unix2dos -n $DST/lipsum-signed.txt $DST/lipsum-signed-dos.txt
go run *.go verify -t -c $CACHE $DST/lipsum-signed-dos.txt $DST/lipsum-unsigned-dos.txt

0 comments on commit 48a0a39

Please sign in to comment.