aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Phillips <david@yeah.nah.nz>2020-09-05 15:39:19 +1200
committerDavid Phillips <david@yeah.nah.nz>2020-09-05 15:39:19 +1200
commit6d81ef9443797d9174fc0849f8ec01d423754490 (patch)
tree69cf73e959514ad1b36981c0d84dd58597cfcc29
parent2b2ad2c10770c6a864f3ada1e2803ed72c8dfa1b (diff)
downloadsand-leek-6d81ef9443797d9174fc0849f8ec01d423754490.tar.xz
Handle multiple returned domains in 002-test-key-name.test
This patch resolves a source of unreliability in the 002-test-key-name test. If sand-leek returned multiple "Found: " lines, then the test script would take only the first, and expect that they RSA key is for this domain. However, this isn't always true, due to the parallel nature of the program. Instead, this patch adjusts the test to capture all found domains, and assert that the domain calculated from the RSA key is one of these domains. Tested 100% reliable over 1000 repetitions.
-rwxr-xr-xtest/002-test-key-name.test/run.sh27
1 files changed, 15 insertions, 12 deletions
diff --git a/test/002-test-key-name.test/run.sh b/test/002-test-key-name.test/run.sh
index cdd0004..aa2adca 100755
--- a/test/002-test-key-name.test/run.sh
+++ b/test/002-test-key-name.test/run.sh
@@ -15,9 +15,9 @@ stderr="$(mktemp)"
# Four character search should be a < 1 second CPU burst for CI runner
${EXECUTABLE} -s site > $key 2>$stderr
-found="$(tr '\r' '\n' < $stderr | grep Found | cut -d ' ' -f 3)"
+found=($(tr '\r' '\n' < $stderr | grep Found | cut -d ' ' -f 3))
-echo "sand-leek says it found $found..."
+echo "sand-leek says it found ${found[*]}..."
# Trick adapted to py3 from https://swehack.org/viewtopic.php?f=37&p=6978
real="$( \
@@ -30,13 +30,16 @@ real="$( \
echo "Key analysis shows it's for ${real}"
-if [ "$found" = "$real" ] ; then
- echo "It's a match, I'm happy"
- rm $key
- rm $stderr
- exit 0
-else
- echo "Error: No match. Key file contents:"
- cat "$key"
- exit 1
-fi
+for f in "${found[@]}" ; do
+ if [ "$f" == "$real" ] ; then
+ echo "Found a match, I'm happy"
+ rm $key
+ rm $stderr
+ exit 0
+ fi
+done
+
+# fallthrough: not found
+echo "Error: No match. Key file contents:"
+cat "$key"
+exit 1