[Openvpn-devel,v2] tests: remove dependency on base64

Message ID E1hON0G-0007yB-1d@sfs-ml-4.v29.lw.sourceforge.com
State Accepted
Headers show
Series [Openvpn-devel,v2] tests: remove dependency on base64 | expand

Commit Message

Steffan Karger May 8, 2019, 3:52 a.m. UTC
From: Steffan Karger <steffan.karger@fox-it.com>

Triggered by the report from Ilya, that if base64 is missing, the tests
would still report success:

  Testing tls-crypt-v2 key generation (max length metadata)..../t_lpback.sh: base64: not found
  OK
  PASS: t_lpback.sh

The easiest way to fix that, is to remove the dependency on base64 (which
is it's current form wouldn't work on OSX anyway, because their base64
doesn't understand "-w0").

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
---
v2: build loop using 'expr' instead of 'seq', which should also work on
    OpenBSD.

 tests/t_lpback.sh | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

Patch

diff --git a/tests/t_lpback.sh b/tests/t_lpback.sh
index fb43211d..3b1e73a8 100755
--- a/tests/t_lpback.sh
+++ b/tests/t_lpback.sh
@@ -77,10 +77,17 @@  else
     echo "OK"
 fi
 
+# Generate max-length base64 metadata ('A' is 0b000000 in base64)
+METADATA=""
+i=0
+while [ $i -lt 732 ]; do
+    METADATA="${METADATA}A"
+    i=$(expr $i + 1)
+done
 echo -n "Testing tls-crypt-v2 key generation (max length metadata)..."
 "${top_builddir}/src/openvpn/openvpn" --tls-crypt-v2 tc-server-key.$$ \
-    --tls-crypt-v2-genkey client tc-client-key.$$ \
-    $(head -c732 /dev/zero | base64 -w0) >log.$$ 2>&1
+    --tls-crypt-v2-genkey client tc-client-key.$$ "${METADATA}" \
+    >log.$$ 2>&1
 if [ $? != 0 ] ; then
     echo "FAILED"
     cat log.$$