message: Accept CONSOLE_URL environment variable. Fall back to BRIDGE_BASE_ADDRESS and BRIDGE_BASE_PATH if it doesn't exist. Dump reports and screenshots into /out.
diff: -#!/bin/sh
  +#!/bin/bash
  -set -x
  +set -e
  -# Run chrome to create cert db
  -timeout 30 google-chrome --no-sandbox --headless --disable-gpu --dump-dom "$BRIDGE_HOST"
  +if [ -z "$CONSOLE_URL" ] && [ -z "$BRIDGE_BASE_ADDRESS" ]
  +then
  + echo 'No CONSOLE_URL or BRIDGE_BASE_ADDRESS. Defaulting to http://localhost:9000/'
  + CONSOLE_URL='http://localhost:9000/'
  +fi
  -set -e
  +if [ -z "$CONSOLE_URL" ]
  +then
  + if [ -z "$BRIDGE_BASE_PATH" ]
  + then
  + echo 'No BRIDGE_BASE_PATH. Defaulting to /'
  + BRIDGE_BASE_PATH=/
  + fi
  + CONSOLE_URL="${BRIDGE_BASE_ADDRESS}${BRIDGE_BASE_PATH}"
  +fi
  +
  +proto=$(echo "$CONSOLE_URL" | grep :// | sed -e 's,^\(.*://\).*,\1,g')
  +url="${CONSOLE_URL/$proto/}" # url without protocol
  +host_with_port=$(echo "$url" | sed 's/\/.*$//')
  +# shellcheck disable=SC2001
  +host=$(echo "$host_with_port" | sed 's/:.*$//')
  +port=$(echo "$host_with_port" | grep : | sed -e 's,^.*:,:,g' -e 's,.*:\([0-9]*\).*,\1,g')
  +
  +BRIDGE_BASE_ADDRESS="${proto}${host_with_port}"
  +BRIDGE_BASE_PATH="/$(echo "$url" | grep / | cut -d/ -f2-)"
  -BRIDGE_HOST=$(echo "$BRIDGE_BASE_ADDRESS" | sed 's/https:\/\///')
  -echo 'GET /' | timeout 30 openssl s_client -showcerts -connect "$BRIDGE_HOST:443" | openssl x509 -outform PEM > bridge-e2e.pem
  +# Run chrome to create cert db
  +timeout 30 google-chrome --no-sandbox --headless --disable-gpu --dump-dom "$CONSOLE_URL"
  +
  +if [ "$proto" == 'https://' ]
  +then
  + if [ -z "$port" ]; then
  + port=443
  + fi
  + echo 'GET /' | timeout 30 openssl s_client -showcerts -connect "$host:$port" | openssl x509 -outform PEM > bridge-e2e.pem
  certutil -d "sql:$HOME/.pki/nssdb" -A -n bridge -t Pu,, -i bridge-e2e.pem
  +fi
  +
  +export BRIDGE_BASE_ADDRESS
  +export BRIDGE_BASE_PATH
  +
  +set +e
  +failed=0
  +if yarn run test-gui --output /out; then
  + failed=1
  +fi
  +# Nightwatch has no a command line arg to change screenshot output path
  +cp -a ./gui_test_screenshots /out/
  -yarn run test-gui
  +exit $failed
  