From 06b7d5d01a62d54224dff13fb7e3402b98f25967 Mon Sep 17 00:00:00 2001
From: josh <josh@elixxir.io>
Date: Wed, 28 Jul 2021 13:55:52 -0700
Subject: [PATCH] Implement Client-Registrar into testing

---
 basice2e/client-registrar.yaml | 36 ++++++++++++++++++++++++++++++++++
 basice2e/permissioning.yaml    |  5 ++++-
 basice2e/run.sh                |  8 ++++++++
 download_cmix_binaries.sh      | 15 +++++++++++++-
 4 files changed, 62 insertions(+), 2 deletions(-)
 create mode 100644 basice2e/client-registrar.yaml

diff --git a/basice2e/client-registrar.yaml b/basice2e/client-registrar.yaml
new file mode 100644
index 0000000..8187c68
--- /dev/null
+++ b/basice2e/client-registrar.yaml
@@ -0,0 +1,36 @@
+# ==================================
+# Client Registrar Configuration
+# ==================================
+
+# Log message level (0 = info, 1 = debug, >1 = trace)
+logLevel: 0
+# Path to log file
+logPath: "results/client-registrar.log"
+
+# Public address, used in NDF it gives to client
+publicAddress: "0.0.0.0:11421"
+# The listening port of this server
+port: 11421
+
+# === REQUIRED FOR ENABLING TLS ===
+# Path to the registration server private key file
+keyPath: "../keys/cmix.rip.key"
+# Path to the registration server certificate file
+certPath: "../keys/cmix.rip.crt"
+
+# Maximum number of connections per period
+userRegCapacity: 1000
+# How often the number of connections is reset
+userRegLeakPeriod: "24h"
+
+# Database connection information
+dbUsername: "cmix"
+dbPassword: ""
+dbName: "cmix_server"
+dbAddress: ""
+
+# List of client codes to be added to the database (for testing)
+clientRegCodes:
+  - "AAAA"
+  - "BBBB"
+  - "CCCC"
diff --git a/basice2e/permissioning.yaml b/basice2e/permissioning.yaml
index 9ff894f..d6146bd 100644
--- a/basice2e/permissioning.yaml
+++ b/basice2e/permissioning.yaml
@@ -91,4 +91,7 @@ RegCodesFilePath: "regCodes.json"
 # Set address space size for ephemeral IDs
 addressSpace: 32
 
-randomGeoBinning: true
\ No newline at end of file
+randomGeoBinning: true
+
+# Public address used in NDF to give to client
+registrationAddress: "0.0.0.0:11421"
\ No newline at end of file
diff --git a/basice2e/run.sh b/basice2e/run.sh
index e02b4c5..d384741 100755
--- a/basice2e/run.sh
+++ b/basice2e/run.sh
@@ -67,6 +67,14 @@ then
     PIDVAL=$!
     echo "$PERMCMD -- $PIDVAL"
 
+
+    # Run Client Registrar
+    CLIENT_REG_CMD="../bin/client-registrar \
+    -l 2 -c client-registrar.yaml"
+    $CLIENT_REG_CMD > results/client-registrat-console.txt 2>&1 &
+    PIDVAL=$!
+    echo "$CLIENT_REG_CMD -- $PIDVAL"
+
     for SERVERID in $(seq 5 -1 1)
     do
         IDX=$(($SERVERID - 1))
diff --git a/download_cmix_binaries.sh b/download_cmix_binaries.sh
index a8a332a..7ede87f 100755
--- a/download_cmix_binaries.sh
+++ b/download_cmix_binaries.sh
@@ -49,7 +49,7 @@ fi
 # Set up the URL for downloading the binaries
 DEFAULTBRANCH=${DEFAULTBRANCH:="release"}
 if [[ $USEREPO == "d" ]]; then
-    REPOS_API=${REPOS_API:="https://git.xx.network/api/v4/projects/elixxir%2F"}
+    REPOS_API=${REPOS_API:="https://gitlab.com/api/v4/projects/elixxir%2F"}
 else
     REPOS_API=${REPOS_API:="https://elixxir-bins.s3-us-west-1.amazonaws.com"}
 fi
@@ -85,12 +85,14 @@ for BRANCH in $(echo "forcedbranch" $FBRANCH $FBRANCH2 $DEFAULTBRANCH); do
         SERVER_GPU_URL=${SERVER_GPU_URL:="${REPOS_API}server/$BRANCH_URL/server-cuda.linux64?job=build"}
         GPULIB_URL=${GPULIB_URL:="${REPOS_API}server/$BRANCH_URL/libpowmosm75.so?job=build"}
         GPULIB2_URL=${GPULIB2_URL:="${REPOS_API}server/$BRANCH_URL/libpow.fatbin?job=build"}
+        CLIENT_REG_URL=${CLIENT_REG_URL:="${REPOS_API}client-registrar/$BRANCH_URL/registration$BIN"}
     else
         UDB_URL=${UDB_URL:="${REPOS_API}/$BRANCH/udb$BIN"}
         SERVER_URL=${SERVER_URL:="${REPOS_API}/$BRANCH/server$BIN"}
         GW_URL=${GW_URL:="${REPOS_API}/$BRANCH/gateway$BIN"}
         PERMISSIONING_URL=${PERMISSIONING_URL:="${REPOS_API}/$BRANCH/registration.stateless$BIN"}
         CLIENT_URL=${CLIENT_URL:="${REPOS_API}/$BRANCH/client$BIN"}
+        CLIENT_REG_URL=${CLIENT_REG_URL:="${REPOS_API}client-registrar/$BRANCH_URL/registration$BIN"}
     fi
 
     set -x
@@ -120,6 +122,11 @@ for BRANCH in $(echo "forcedbranch" $FBRANCH $FBRANCH2 $DEFAULTBRANCH); do
         curl -s -f -L -H "PRIVATE-TOKEN: $GITLAB_ACCESS_TOKEN" -o "$download_path/client" ${CLIENT_URL}
     fi
 
+        # Silently download the client registrar binary to the provisioning directory
+    if [ ! -f $download_path/client-registrar ] && [[ "$CLIENT_REG_URL" != *"forcedbranch"* ]]; then
+        curl -s -f -L -H "PRIVATE-TOKEN: $GITLAB_ACCESS_TOKEN" -o "$download_path/client-registrar" ${CLIENT_REG_URL}
+    fi
+
 if [[ $2 == "d" ]]; then
     # Silently download the Server binary to the provisioning directory
     if [ ! -f $download_path/server-cuda ] && [[ "$SERVER_GPU_URL" != *"forcedbranch"* ]]; then
@@ -134,6 +141,11 @@ if [[ $2 == "d" ]]; then
     if [ ! -f $download_path/libpow.fatbin ] && [[ "$GPULIB2_URL" != *"forcedbranch"* ]]; then
         curl -s -f -L -H "PRIVATE-TOKEN: $GITLAB_ACCESS_TOKEN" -o "$download_path/libpow.fatbin" ${GPULIB2_URL}
     fi
+
+        # Silently download the client registrar binary to the provisioning directory
+    if [ ! -f $download_path/client-registrar ] && [[ "$CLIENT_REG_URL" != *"forcedbranch"* ]]; then
+        curl -s -f -L -H "PRIVATE-TOKEN: $GITLAB_ACCESS_TOKEN" -o "$download_path/client-registrar" ${CLIENT_REG_URL}
+    fi
 fi
 
     set +x
@@ -148,6 +160,7 @@ fi
     unset SERVER_GPU_URL
     unset GPULIB_URL
     unset GPULIB2_URL
+    unset CLIENT_REG_URL
 done
 
 # Make binaries executable
-- 
GitLab