Skip to content

Commit

Permalink
fix test output
Browse files Browse the repository at this point in the history
  • Loading branch information
alxndrsn committed Dec 9, 2024
1 parent 9448750 commit 333b30e
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion enketo.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ WORKDIR ${ENKETO_SRC_DIR}
# care about anything the server needs. because the client config is baked at
# build time, we therefore hand it the untemplated config.

COPY files/shared/envsub.sh /scripts/
COPY files/shared/envsub.awk /scripts/
COPY files/enketo/config.json.template ${ENKETO_SRC_DIR}/config/config.json.template
COPY files/enketo/config.json.template ${ENKETO_SRC_DIR}/config/config.json
COPY files/enketo/start-enketo.sh ${ENKETO_SRC_DIR}/start-enketo.sh
Expand Down
2 changes: 1 addition & 1 deletion files/enketo/start-enketo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ BASE_URL=$( [ "${HTTPS_PORT}" = 443 ] && echo https://"${DOMAIN}" || echo https:
SECRET=$(cat /etc/secrets/enketo-secret) \
LESS_SECRET=$(cat /etc/secrets/enketo-less-secret) \
API_KEY=$(cat /etc/secrets/enketo-api-key) \
/scripts/envsub.sh \
/scripts/envsub.awk \
< "$CONFIG_PATH.template" \
> "$CONFIG_PATH"

Expand Down
4 changes: 2 additions & 2 deletions files/nginx/setup-odk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ if [[ $OIDC_ENABLED != 'true' ]] && [[ $OIDC_ENABLED != 'false' ]]; then
exit 1
fi

/scripts/envsub.sh \
/scripts/envsub.awk \
< /usr/share/odk/nginx/client-config.json.template \
> /usr/share/nginx/html/client-config.json

Expand All @@ -32,7 +32,7 @@ echo "writing fresh nginx templates..."
cp /usr/share/odk/nginx/redirector.conf /etc/nginx/conf.d/redirector.conf

CERT_DOMAIN=$( [ "$SSL_TYPE" = "customssl" ] && echo "local" || echo "$DOMAIN") \
/scripts/envsub.sh \
/scripts/envsub.awk \
< /usr/share/odk/nginx/odk.conf.template \
> /etc/nginx/conf.d/odk.conf

Expand Down
2 changes: 1 addition & 1 deletion files/service/scripts/start-odk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ echo "generating local service configuration.."

ENKETO_API_KEY=$(cat /etc/secrets/enketo-api-key) \
BASE_URL=$( [ "${HTTPS_PORT}" = 443 ] && echo https://"${DOMAIN}" || echo https://"${DOMAIN}":"${HTTPS_PORT}" ) \
/scripts/envsub.sh \
/scripts/envsub.awk \
< /usr/share/odk/config.json.template \
> /usr/odk/config/local.json

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion nginx.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ RUN apt-get update && apt-get install -y netcat-openbsd
RUN mkdir -p /usr/share/odk/nginx/

COPY files/nginx/setup-odk.sh \
files/shared/envsub.sh \
files/shared/envsub.awk \
/scripts/
RUN chmod +x /scripts/setup-odk.sh

Expand Down
2 changes: 1 addition & 1 deletion service.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ RUN apt-get update \
--fund=false --update-notifier=false

COPY server/ ./
COPY files/shared/envsub.sh /scripts/
COPY files/shared/envsub.awk /scripts/
COPY files/service/scripts/ ./

COPY files/service/config.json.template /usr/share/odk/
Expand Down
8 changes: 5 additions & 3 deletions test/envsub/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if diff <( \
SIMPLE=sv_simple \
SUBVAL_1=sub_val_one \
SUBVAL_2=sub_val_two \
../../files/shared/envsub.sh \
../../files/shared/envsub.awk \
< good-example.in
) good-example.expected; then
log " OK"
Expand All @@ -18,7 +18,7 @@ else
fi

log "should fail when asked to substitute undefined value"
if ! ../../files/shared/envsub.sh <<<"\${NOT_DEFINED}"; then
if ! ../../files/shared/envsub.awk <<<"\${NOT_DEFINED}" >/dev/null 2>/dev/null; then
log " OK"
else
((++failCount))
Expand All @@ -28,7 +28,7 @@ fi
log "should log all issues when asked to substitute multiple undefined values"
out="$(mktemp)"
err="$(mktemp)"
if ../../files/shared/envsub.sh < bad-example.in >"$out" 2>"$err"; then
if ../../files/shared/envsub.awk < bad-example.in >"$out" 2>"$err"; then
((++failCount))
log " FAILED: expected non-zero status code"
elif ! diff "$out" bad-example.stdout.expected; then
Expand All @@ -38,6 +38,8 @@ elif ! diff "$err" bad-example.stderr.expected; then
echo "err: $err"
((++failCount))
log " FAILED: generated stderr did not equal expected output"
else
log " OK"
fi

if [[ "$failCount" = 0 ]]; then
Expand Down

0 comments on commit 333b30e

Please sign in to comment.