Skip to content

Commit

Permalink
[aem-universal-editor-service] add ssl proxy for author
Browse files Browse the repository at this point in the history
  • Loading branch information
juan-ayala committed Sep 13, 2024
1 parent ac27620 commit 9935fb8
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 22 deletions.
11 changes: 7 additions & 4 deletions src/aem-universal-editor-service/bin/start-ues
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ fi
cd ${AEM_UES_FEATURE_DIR}

source ${NVM_DIR}/nvm.sh
nvm install
nvm use

node universal-editor-service.cjs
nvm install ${AEM_UES_NODE_VERSION}
nvm exec ${AEM_UES_NODE_VERSION} \
npm install -g local-ssl-proxy concurrently
nvm exec ${AEM_UES_NODE_VERSION} \
concurrently --kill-others \
"node universal-editor-service.cjs" \
"local-ssl-proxy --source ${AEM_UES_AUTHOR_HTTPS_PORT} --target ${AEM_UES_AUTHOR_HTTP_PORT}"
17 changes: 16 additions & 1 deletion src/aem-universal-editor-service/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "aem-universal-editor-service",
"version": "1.0.1",
"version": "1.2.0",
"name": "Adobe Experience Manager Universal Editor Service",
"description": "Setup the AEM Universal Editor Service for local development.",
"options": {
Expand All @@ -9,6 +9,11 @@
"description": "Path to directory that contains one or more UES zip files downloaded from Adobe's Software Distribution.",
"default": ""
},
"uesNodeVersion": {
"type": "string",
"description": "Node.js version to use when running the Universal Editor Service.",
"default": "20"
},
"uesVersion": {
"type": "string",
"description": "Universal Editor Service version.",
Expand All @@ -18,6 +23,16 @@
"type": "string",
"description": "Universal Editor Service port.",
"default": "8000"
},
"authorHttpPort": {
"type": "string",
"description": "HTTP port the AEM author is running on.",
"default": "4502"
},
"authorHttpsPort": {
"type": "string",
"description": "HTTPS port that should be proxied for the AEM author.",
"default": "44302"
}
},
"containerEnv": {
Expand Down
18 changes: 9 additions & 9 deletions src/aem-universal-editor-service/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ mkdir -p ${AEM_UES_FEATURE_DIR}
# save feature properties
propertiesFile="${AEM_UES_FEATURE_DIR}/options.sh"
echo "AEM_UES_DOWNLOADS_DIR=\"${UESDOWNLOADSDIRECTORY}\"" >> ${propertiesFile}
echo "AEM_UES_NODE_VERSION=\"${UESNODEVERSION:-'20'}\"" >> ${propertiesFile}
echo "AEM_UES_VERSION=\"${UESVERSION:-'automatic'}\"" >> ${propertiesFile}
echo "AEM_UES_PORT=\"${UESPORT:-'8000'}\"" >> ${propertiesFile}
echo "AEM_UES_AUTHOR_HTTP_PORT=\"${AUTHORHTTPPORT:-'4502'}\"" >> ${propertiesFile}
echo "AEM_UES_AUTHOR_HTTPS_PORT=\"${AUTHORHTTPSPORT:-'44302'}\"" >> ${propertiesFile}
source ${propertiesFile}

# copy custom scripts
cp -r "$(dirname $0)/bin" ${AEM_UES_FEATURE_DIR}

# create .nvmrc file
echo "20" > "${AEM_UES_FEATURE_DIR}/.nvmrc"

# create ssl cert and private key
openssl req -newkey rsa:2048 -nodes -keyout "${AEM_UES_FEATURE_DIR}/key.pem" \
-x509 -days 365 -out "${AEM_UES_FEATURE_DIR}/certificate.pem" -subj '/CN=localhost'
Expand All @@ -24,9 +24,9 @@ chgrp ${_REMOTE_USER} "${AEM_UES_FEATURE_DIR}/key.pem"
chmod g+r "${AEM_UES_FEATURE_DIR}/key.pem"

# create .env file
envfile="${AEM_UES_FEATURE_DIR}/.env"
echo "UES_PORT=${AEM_UES_PORT}" >> "${envfile}"
echo "UES_PRIVATE_KEY=./key.pem" >> "${envfile}"
echo "UES_CERT=./certificate.pem" >> "${envfile}"
echo "UES_TLS_REJECT_UNAUTHORIZED=false" >> "${envfile}"

cat <<EOF >> "${AEM_UES_FEATURE_DIR}/.env"
UES_PORT=${AEM_UES_PORT}
UES_PRIVATE_KEY=./key.pem
UES_CERT=./certificate.pem
UES_TLS_REJECT_UNAUTHORIZED=false
EOF
10 changes: 8 additions & 2 deletions test/aem-universal-editor-service/defaults-with-zip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,19 @@ source dev-container-features-test-lib
source ${AEM_UES_FEATURE_DIR}/options.sh
check "downloads directory set" \
echo "${AEM_UES_DOWNLOADS_DIR}" | grep -E "^/workspaces/[0-9]+/.devcontainer$"
check "ues node version default" \
[ "${AEM_UES_NODE_VERSION}" = "20" ]
check "ues version default" \
[ "${AEM_UES_VERSION}" = "automatic" ]
check "ues port default" \
[ "${AEM_UES_PORT}" = "8000" ]
check "ues port default" \
[ "${AEM_UES_AUTHOR_HTTP_PORT}" = "4502" ]
check "ues port default" \
[ "${AEM_UES_AUTHOR_HTTPS_PORT}" = "44302" ]

# Check that ues installs and starts
# Check that ues installs and exec the node script
check "can install & run ues" \
start-ues | grep "hello, world"
bash -c "start-ues || true" | grep "hello, world"

reportResults
10 changes: 8 additions & 2 deletions test/aem-universal-editor-service/options-with-zip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,19 @@ source dev-container-features-test-lib
source ${AEM_UES_FEATURE_DIR}/options.sh
check "downloads directory set" \
echo "${AEM_UES_DOWNLOADS_DIR}" | grep -E "^/workspaces/[0-9]+/.devcontainer$"
check "ues node version default" \
[ "${AEM_UES_NODE_VERSION}" = "22" ]
check "ues version default" \
[ "${AEM_UES_VERSION}" = "mock-2024.02.01" ]
check "ues port default" \
[ "${AEM_UES_PORT}" = "9090" ]
check "ues port default" \
[ "${AEM_UES_AUTHOR_HTTP_PORT}" = "4510" ]
check "ues port default" \
[ "${AEM_UES_AUTHOR_HTTPS_PORT}" = "44310" ]

# Check that ues installs and starts
# Check that ues installs and exec the node script
check "can install & run ues" \
start-ues | grep "hello, world"
bash -c "start-ues || true" | grep "hello, world"

reportResults
5 changes: 4 additions & 1 deletion test/aem-universal-editor-service/scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@
"features": {
"aem-universal-editor-service": {
"uesDownloadsDirectory": "${containerWorkspaceFolder}/.devcontainer",
"uesNodeVersion": "22",
"uesVersion": "mock-2024.02.01",
"uesPort": "9090"
"uesPort": "9090",
"authorHttpPort": "4510",
"authorHttpsPort": "44310"
}
}
}
Expand Down
12 changes: 9 additions & 3 deletions test/aem-universal-editor-service/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,20 @@ source dev-container-features-test-lib
source ${AEM_UES_FEATURE_DIR}/options.sh
check "downloads directory default" \
[ -z "${AEM_UES_DOWNLOADS_DIR}" ]
check "sdk version default" \
check "ues node version default" \
[ "${AEM_UES_NODE_VERSION}" = "20" ]
check "ues version default" \
[ "${AEM_UES_VERSION}" = "automatic" ]
check "ues port default" \
[ "${AEM_UES_PORT}" = "8000" ]
check "ues port default" \
[ "${AEM_UES_AUTHOR_HTTP_PORT}" = "4502" ]
check "ues port default" \
[ "${AEM_UES_AUTHOR_HTTPS_PORT}" = "44302" ]
# Check start-ues in PATH is executable
check "start-ues is +x" \
stat -c '%A' $(which start-ues) | grep 'x.*x.*x'
# Check config files created
check "created .nvmrc" \
[ -f "${AEM_UES_FEATURE_DIR}/.nvmrc" ]
check "can read key" \
stat -c '%a' "${AEM_UES_FEATURE_DIR}/key.pem" | grep 640
check "key group set to remote user" \
Expand Down

0 comments on commit 9935fb8

Please sign in to comment.