Issue #213 Add test for JAVA_OPTS
diff --git a/tests/test_helpers.bash b/tests/test_helpers.bash
index 4ee7ed9..7a3d891 100644
--- a/tests/test_helpers.bash
+++ b/tests/test_helpers.bash
@@ -11,7 +11,8 @@
shift
local actual_output=$("$@")
if ! [ "$actual_output" = "$expected_output" ]; then
- echo "expected: \"$expected_output\", actual: \"$actual_output\""
+ echo "expected: \"$expected_output\""
+ echo "actual: \"$actual_output\""
false
fi
}
@@ -37,7 +38,7 @@
}
function get_jenkins_url {
- if [ -z $DOCKER_HOST]; then
+ if [ -z "${DOCKER_HOST}" ]; then
DOCKER_IP=localhost
else
DOCKER_IP=$(echo $DOCKER_HOST | sed -e 's|tcp://\(.*\):[0-9]*|\1|')
diff --git a/tests/tests.bats b/tests/tests.bats
index 1e8ec44..cab7123 100644
--- a/tests/tests.bats
+++ b/tests/tests.bats
@@ -19,7 +19,7 @@
local version=$(grep 'ENV JENKINS_VERSION' Dockerfile | sed -e 's/ENV JENKINS_VERSION //')
# need the last line of output, removing the last char
local actual_version=$(docker run --rm -ti -e JENKINS_OPTS="--help --version" --name $SUT_CONTAINER -P $SUT_IMAGE | tail -n 1)
- assert "${version}" echo ${actual_version::-1}
+ assert "${version}" echo "${actual_version::-1}"
}
@test "test jenkins arguments" {
@@ -27,11 +27,11 @@
local version=$(grep 'ENV JENKINS_VERSION' Dockerfile | sed -e 's/ENV JENKINS_VERSION //')
# need the last line of output, removing the last char
local actual_version=$(docker run --rm -ti --name $SUT_CONTAINER -P $SUT_IMAGE --help --version | tail -n 1)
- assert "${version}" echo ${actual_version::-1}
+ assert "${version}" echo "${actual_version::-1}"
}
@test "create test container" {
- docker run -d --name $SUT_CONTAINER -P $SUT_IMAGE
+ docker run -d -e JAVA_OPTS="-Duser.timezone=Europe/Madrid -Dhudson.model.DirectoryBrowserSupport.CSP=\"default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline';\"" --name $SUT_CONTAINER -P $SUT_IMAGE
}
@test "test container is running" {
@@ -43,6 +43,10 @@
retry 30 5 test_url /api/json
}
-@test "clean test containers" {
- cleanup $SUT_CONTAINER
+@test "JAVA_OPTS are set" {
+ local sed_expr='s/<wbr>//g;s/<td class="pane">.*<\/td><td class.*normal">//g;s/<t.>//g;s/<\/t.>//g'
+ assert 'default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline';' \
+ bash -c "curl -fsSL $(get_jenkins_url)/systemInfo | sed 's/<\/tr>/<\/tr>\'$'\n/g' | grep '<td class=\"pane\">hudson.model.DirectoryBrowserSupport.CSP</td>' | sed -e '${sed_expr}'"
+ assert 'Europe/Madrid' \
+ bash -c "curl -fsSL $(get_jenkins_url)/systemInfo | sed 's/<\/tr>/<\/tr>\'$'\n/g' | grep '<td class=\"pane\">user.timezone</td>' | sed -e '${sed_expr}'"
}