Browse Source

Test that onion ports are unique

Bob Mottram 8 years ago
parent
commit
1f5173d13d
1 changed files with 13 additions and 0 deletions
  1. 13
    0
      src/freedombone-tests

+ 13
- 0
src/freedombone-tests View File

@@ -74,6 +74,18 @@ function test_app_functions {
74 74
     done
75 75
 }
76 76
 
77
+function test_unique_onion_ports {
78
+    # test that some services are not assigned the same onion port
79
+    FILES=src/${PROJECT_NAME}-app-*
80
+    ports=$(grep -r "_ONION_PORT=" $FILES | awk -F ':' '{print $2}' | uniq | awk -F '=' '{print $2}')
81
+    unique_ports=$(grep -r "_ONION_PORT=" $FILES | awk -F ':' '{print $2}' | uniq | awk -F '=' '{print $2}' | uniq)
82
+    if [[ "$ports" != "$unique_ports" ]]; then
83
+        echo $'Some onion ports are clashing'
84
+        grep -r "_ONION_PORT=" $FILES | awk -F ':' '{print $2}' | uniq
85
+        exit 637252
86
+    fi
87
+}
88
+
77 89
 while [[ $# > 1 ]]
78 90
 do
79 91
     key="$1"
@@ -92,6 +104,7 @@ done
92 104
 echo $'Running tests'
93 105
 
94 106
 test_app_functions
107
+test_unique_onion_ports
95 108
 
96 109
 echo $'All tests passed'
97 110