test: Fix Caddy route tests with custom Caddy (#32675)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit


- **Refactor**
- Updated base Docker image and installation processes for tools within
the Docker environment.
- **Chores**
- Modified scripts to enhance file handling and environment variable
configurations.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Shrikant Sharat Kandula 2024-04-18 14:03:10 +05:30 committed by GitHub
parent 2ac328449c
commit 0a9f9b9043
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 31 additions and 13 deletions

View File

@ -1,7 +1,22 @@
FROM node:lts-alpine FROM appsmith/base-ce:release
RUN apk add --no-cache bash caddy \ SHELL ["bash", "-eux", "-c"]
&& apk add --no-cache hurl mkcert --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing/
RUN <<END
version="$(basename "$(curl -sS --write-out '%{redirect_url}' 'https://github.com/Orange-OpenSource/hurl/releases/latest')")"
curl -sS --location "https://github.com/Orange-OpenSource/hurl/releases/download/$version/hurl-$version-$(uname -m)-unknown-linux-gnu.tar.gz" \
| tar xvz -C /tmp --strip-components 1
mv /tmp/hurl /bin
chmod +x /bin/hurl
version="$(basename "$(curl -sS --write-out '%{redirect_url}' 'https://github.com/FiloSottile/mkcert/releases/latest')")"
curl -sS --location "https://github.com/FiloSottile/mkcert/releases/download/$version/mkcert-$version-linux-$(uname -m | sed 's/x86_64/amd64/; s/aarch64/arm64/')" \
-o /bin/mkcert
chmod +x /bin/mkcert
END
ENV PATH=/opt/caddy:/opt/node/bin:$PATH
WORKDIR /code WORKDIR /code

View File

@ -4,7 +4,7 @@ Content-Type: text/html; charset=utf-8
Content-Security-Policy: frame-ancestors {{frame_ancestors}} Content-Security-Policy: frame-ancestors {{frame_ancestors}}
[Asserts] [Asserts]
header "Server" not exists header "Server" not exists
body == "index.html body" body == "actual index.html body"
GET http://127.0.0.1 GET http://127.0.0.1
HTTP 200 HTTP 200
@ -12,7 +12,7 @@ Content-Type: text/html; charset=utf-8
Content-Security-Policy: frame-ancestors {{frame_ancestors}} Content-Security-Policy: frame-ancestors {{frame_ancestors}}
[Asserts] [Asserts]
header "Server" not exists header "Server" not exists
body == "index.html body" body == "actual index.html body"
GET http://local.com GET http://local.com
HTTP 200 HTTP 200
@ -20,7 +20,7 @@ Content-Type: text/html; charset=utf-8
Content-Security-Policy: frame-ancestors {{frame_ancestors}} Content-Security-Policy: frame-ancestors {{frame_ancestors}}
[Asserts] [Asserts]
header "Server" not exists header "Server" not exists
body == "index.html body" body == "actual index.html body"
GET http://localhost/some/non/handled/path GET http://localhost/some/non/handled/path
HTTP 200 HTTP 200
@ -28,7 +28,7 @@ Content-Type: text/html; charset=utf-8
Content-Security-Policy: frame-ancestors {{frame_ancestors}} Content-Security-Policy: frame-ancestors {{frame_ancestors}}
[Asserts] [Asserts]
header "Server" not exists header "Server" not exists
body == "index.html body" body == "actual index.html body"
GET http://127.0.0.1/some/non/handled/path GET http://127.0.0.1/some/non/handled/path
HTTP 200 HTTP 200
@ -36,7 +36,7 @@ Content-Type: text/html; charset=utf-8
Content-Security-Policy: frame-ancestors {{frame_ancestors}} Content-Security-Policy: frame-ancestors {{frame_ancestors}}
[Asserts] [Asserts]
header "Server" not exists header "Server" not exists
body == "index.html body" body == "actual index.html body"
GET http://local.com/some/non/handled/path GET http://local.com/some/non/handled/path
HTTP 200 HTTP 200
@ -44,4 +44,4 @@ Content-Type: text/html; charset=utf-8
Content-Security-Policy: frame-ancestors {{frame_ancestors}} Content-Security-Policy: frame-ancestors {{frame_ancestors}}
[Asserts] [Asserts]
header "Server" not exists header "Server" not exists
body == "index.html body" body == "actual index.html body"

View File

@ -1,4 +1,4 @@
#!/usr/bin/env bash #!/bin/bash
set -o errexit set -o errexit
set -o nounset set -o nounset
@ -44,8 +44,11 @@ echo
export TMP=/tmp/appsmith export TMP=/tmp/appsmith
export WWW_PATH="$TMP/www" export WWW_PATH="$TMP/www"
mkdir -p "$WWW_PATH" # Fake files needed by the caddy-reconfigure script
echo -n 'index.html body' > "$WWW_PATH/index.html" mkdir -p "$WWW_PATH" /opt/appsmith/editor
echo -n 'index.html body, this will be replaced' > "$WWW_PATH/index.html"
echo '{}' > /opt/appsmith/info.json
echo -n 'actual index.html body' > /opt/appsmith/editor/index.html
mkcert -install mkcert -install
# Start echo server # Start echo server

View File

@ -18,7 +18,7 @@ docker run \
--name ar \ --name ar \
--rm \ --rm \
"${args[@]}" \ "${args[@]}" \
-e OPEN_SHELL=${OPEN_SHELL-} \ -e OPEN_SHELL="${OPEN_SHELL-}" \
--volume "$(dirname "$PWD")/fs/opt/appsmith/caddy-reconfigure.mjs:/caddy-reconfigure.mjs:ro" \ --volume "$(dirname "$PWD")/fs/opt/appsmith/caddy-reconfigure.mjs:/caddy-reconfigure.mjs:ro" \
--volume ".:/code:ro" \ --volume ".:/code:ro" \
ar ar