From 93cc5e15b17fa472d0fa2f108d8d459e3b052fd4 Mon Sep 17 00:00:00 2001 From: xpetit <32063953+xpetit@users.noreply.github.com> Date: Sat, 31 Oct 2020 17:27:30 +0000 Subject: [PATCH] Make who-are-you & cl-camp4 exercises work offline --- sh/tests/Caddyfile | 4 ++++ sh/tests/Dockerfile | 18 +++++++++++++++++- sh/tests/cl-camp4_test.sh | 5 +++++ sh/tests/who-are-you_test.sh | 5 +++++ 4 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 sh/tests/Caddyfile diff --git a/sh/tests/Caddyfile b/sh/tests/Caddyfile new file mode 100644 index 000000000..39a9b829f --- /dev/null +++ b/sh/tests/Caddyfile @@ -0,0 +1,4 @@ +{$DOMAIN} +tls internal +encode zstd gzip +file_server diff --git a/sh/tests/Dockerfile b/sh/tests/Dockerfile index f7efadb83..ba983a8ca 100644 --- a/sh/tests/Dockerfile +++ b/sh/tests/Dockerfile @@ -1,6 +1,22 @@ FROM debian:10.5-slim RUN apt-get update -RUN apt-get -y install jq curl git +RUN apt-get -y install jq curl + +WORKDIR /app/assets/superhero +RUN curl --remote-name --location https://demo.01-edu.org/assets/superhero/all.json + +WORKDIR /tmp/installation + +RUN curl --remote-name --location https://github.com/caddyserver/caddy/releases/download/v2.2.1/caddy_2.2.1_linux_amd64.tar.gz +RUN tar xf caddy_2.2.1_linux_amd64.tar.gz +RUN mv caddy /usr/local/bin +RUN apt-get -y install libcap2-bin +RUN setcap 'cap_net_bind_service=+ep' /usr/local/bin/caddy + +WORKDIR /app + +RUN rm -rf /tmp/installation + COPY . /app ENTRYPOINT ["/app/entrypoint.sh"] diff --git a/sh/tests/cl-camp4_test.sh b/sh/tests/cl-camp4_test.sh index b02f9e66f..fe38c7025 100755 --- a/sh/tests/cl-camp4_test.sh +++ b/sh/tests/cl-camp4_test.sh @@ -5,6 +5,9 @@ set -euo pipefail IFS=' ' +echo insecure >> ~/.curlrc +caddy start &>/dev/null + challenge() { submitted=$(./student/myfamily.sh) expected=$(./solutions/myfamily.sh) @@ -14,3 +17,5 @@ challenge() { HERO_ID=1 challenge HERO_ID=70 challenge + +caddy stop &>/dev/null diff --git a/sh/tests/who-are-you_test.sh b/sh/tests/who-are-you_test.sh index 1082e0882..14cc0c8bb 100755 --- a/sh/tests/who-are-you_test.sh +++ b/sh/tests/who-are-you_test.sh @@ -5,7 +5,12 @@ set -euo pipefail IFS=' ' +echo insecure >> ~/.curlrc +caddy start &>/dev/null + submitted=$(./student/who-are-you.sh) expected=$(./solutions/who-are-you.sh) +caddy stop &>/dev/null + diff <(echo "$submitted") <(echo "$expected")