Skip to content

Commit c24ef82

Browse files
committed
Issue jenkinsci#213 Add test for JAVA_OPTS
1 parent 5fc9cd0 commit c24ef82

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

tests/test_helpers.bash

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ function assert {
1111
shift
1212
local actual_output=$("$@")
1313
if ! [ "$actual_output" = "$expected_output" ]; then
14-
echo "expected: \"$expected_output\", actual: \"$actual_output\""
14+
echo "expected: \"$expected_output\""
15+
echo "actual: \"$actual_output\""
1516
false
1617
fi
1718
}
@@ -37,7 +38,7 @@ function retry {
3738
}
3839

3940
function get_jenkins_url {
40-
if [ -z $DOCKER_HOST]; then
41+
if [ -z "${DOCKER_HOST}" ]; then
4142
DOCKER_IP=localhost
4243
else
4344
DOCKER_IP=$(echo $DOCKER_HOST | sed -e 's|tcp://\(.*\):[0-9]*|\1|')

tests/tests.bats

+9-5
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@ load test_helpers
1919
local version=$(grep 'ENV JENKINS_VERSION' Dockerfile | sed -e 's/ENV JENKINS_VERSION //')
2020
# need the last line of output, removing the last char
2121
local actual_version=$(docker run --rm -ti -e JENKINS_OPTS="--help --version" --name $SUT_CONTAINER -P $SUT_IMAGE | tail -n 1)
22-
assert "${version}" echo ${actual_version::-1}
22+
assert "${version}" echo "${actual_version::-1}"
2323
}
2424

2525
@test "test jenkins arguments" {
2626
# running --help --version should return the version, not the help
2727
local version=$(grep 'ENV JENKINS_VERSION' Dockerfile | sed -e 's/ENV JENKINS_VERSION //')
2828
# need the last line of output, removing the last char
2929
local actual_version=$(docker run --rm -ti --name $SUT_CONTAINER -P $SUT_IMAGE --help --version | tail -n 1)
30-
assert "${version}" echo ${actual_version::-1}
30+
assert "${version}" echo "${actual_version::-1}"
3131
}
3232

3333
@test "create test container" {
34-
docker run -d --name $SUT_CONTAINER -P $SUT_IMAGE
34+
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
3535
}
3636

3737
@test "test container is running" {
@@ -43,6 +43,10 @@ load test_helpers
4343
retry 30 5 test_url /api/json
4444
}
4545

46-
@test "clean test containers" {
47-
cleanup $SUT_CONTAINER
46+
@test "JAVA_OPTS are set" {
47+
local sed_expr='s/<wbr>//g;s/<td class="pane">.*<\/td><td class.*normal">//g;s/<t.>//g;s/<\/t.>//g'
48+
assert 'default-src &#039;self&#039;; script-src &#039;self&#039; &#039;unsafe-inline&#039; &#039;unsafe-eval&#039;; style-src &#039;self&#039; &#039;unsafe-inline&#039;;' \
49+
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}'"
50+
assert 'Europe/Madrid' \
51+
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}'"
4852
}

0 commit comments

Comments
 (0)