From 1f5173d13dd538bf6f3472808f0981b8361cd237 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 18 Nov 2016 11:21:50 +0000 Subject: [PATCH] Test that onion ports are unique --- src/freedombone-tests | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/freedombone-tests b/src/freedombone-tests index 191e5ca9..83f07c81 100755 --- a/src/freedombone-tests +++ b/src/freedombone-tests @@ -74,6 +74,18 @@ function test_app_functions { done } +function test_unique_onion_ports { + # test that some services are not assigned the same onion port + FILES=src/${PROJECT_NAME}-app-* + ports=$(grep -r "_ONION_PORT=" $FILES | awk -F ':' '{print $2}' | uniq | awk -F '=' '{print $2}') + unique_ports=$(grep -r "_ONION_PORT=" $FILES | awk -F ':' '{print $2}' | uniq | awk -F '=' '{print $2}' | uniq) + if [[ "$ports" != "$unique_ports" ]]; then + echo $'Some onion ports are clashing' + grep -r "_ONION_PORT=" $FILES | awk -F ':' '{print $2}' | uniq + exit 637252 + fi +} + while [[ $# > 1 ]] do key="$1" @@ -92,6 +104,7 @@ done echo $'Running tests' test_app_functions +test_unique_onion_ports echo $'All tests passed'