[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [bridgedb/master] Make the test-moat script easier to input challenges and solutions.



commit 8245b6a2c4f4697a33b1c169529aed66b6e1a55a
Author: Isis Lovecruft <isis@xxxxxxxxxxxxxx>
Date:   Mon Nov 27 19:13:54 2017 +0000

    Make the test-moat script easier to input challenges and solutions.
---
 scripts/test-moat | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)

diff --git a/scripts/test-moat b/scripts/test-moat
index 6bfa500..490edc6 100755
--- a/scripts/test-moat
+++ b/scripts/test-moat
@@ -1,7 +1,10 @@
 #!/usr/bin/env bash
 
+CHALLENGE=
+SOLUTION=
+
 function usage() {
-    printf "Usage: %s [fetch] [check]\n" "$(basename $0)"
+    printf "Usage: %s [fetch] [check [challenge solution]]\n" "$(basename $0)"
 }
 
 if test "$#" -lt 1 ; then
@@ -20,17 +23,32 @@ function do_fetch() {
 function do_check() {
     curl -H 'Content-Type: application/vnd.api+json' \
          -H 'Accept: application/vnd.api+json' \
-         --data '{"data": [{"challenge": "foo", "solution": "bar", "version": "0.1.0", "qrcode": "false", "type": "moat-solution", "id": 2, "transport": "obfs4"}]}' \
+         --data '{"data": [{"challenge": "'$CHALLENGE'", "solution": "'$SOLUTION'", "version": "0.1.0", "qrcode": "false", "type": "moat-solution", "id": 2, "transport": "obfs4"}]}' \
          http://127.0.0.1:6790/meek/moat/check
     echo
 }
 
 while test -n "$1" ; do
+    OPTSHIFT=1
+
     case "$1" in
         fetch) do_fetch ;;
-        check) do_check ;;
+        check) if [[ "$2" != "fetch" ]] ; then
+                   CHALLENGE="$2"
+                   if [[ "$3" != "fetch" ]] ; then
+                       SOLUTION="$3"
+                   fi
+               fi
+               for var in "$CHALLENGE" "$SOLUTION" ; do
+                   if test -n "$var"; then
+                       OPTSHIFT=$(( OPTSHIFT + 1 ))
+                   fi
+               done
+               do_check ;;
+
         *) usage ;;
     esac
 
-    shift
+    shift $OPTSHIFT
+    OPTSHIFT=1
 done



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits