From f9c515a27d65446d567e25293371031b16951232 Mon Sep 17 00:00:00 2001 From: LeonZhang77 Date: Fri, 23 Feb 2018 22:28:30 -0800 Subject: [PATCH 1/2] check USER lines --- travis-script/test-dockerfile.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/travis-script/test-dockerfile.sh b/travis-script/test-dockerfile.sh index fb3601d..b4933fe 100644 --- a/travis-script/test-dockerfile.sh +++ b/travis-script/test-dockerfile.sh @@ -12,7 +12,7 @@ test_Dockerfile(){ echo "INFORMATION: Details of "${DOCKER_IMAGE_NAME}":" cat inspect.json - # Check Ports + # Check SSH Ports testSSH=$(jq .[].Config.ExposedPorts inspect.json | grep 2222) if [ -z "${testSSH}" ]; then echo "FAILED - PORT 2222 isn't opened, SSH isn't working!!!" @@ -21,7 +21,7 @@ test_Dockerfile(){ echo "${testSSH}" echo "PASSED - PROT 2222 is opened." fi - + # Check Volume testVOLUME=$(jq .[].Config.Volumes inspect.json | grep null) if [ -z "${testVOLUME}" ]; then @@ -32,6 +32,16 @@ test_Dockerfile(){ else echo "PASSED - Great, there is no VOLUME lines." fi + + # Check User + testUSER=$(jq .[].Config.User inspect.json) + if test "${testUSER}" != '""' ; then + echo "${testUSER}" + echo "FAILED - These USER lines should not be existed!!!" + exit 1 + else + echo "PASSED - Great, there is no USER lines." + fi } echo "Docker: "${DOCKER_IMAGE_NAME}"/"${DOCKER_IMAGE_VERSION} From 671fbef11f04e8aeb5db97dea9a99f4af5a094eb Mon Sep 17 00:00:00 2001 From: leonzhang77 Date: Mon, 26 Feb 2018 04:59:01 +0000 Subject: [PATCH 2/2] Check Ports, only 2 ports allowed where one is always 2222 --- travis-script/test-dockerfile.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/travis-script/test-dockerfile.sh b/travis-script/test-dockerfile.sh index b4933fe..83113e2 100644 --- a/travis-script/test-dockerfile.sh +++ b/travis-script/test-dockerfile.sh @@ -13,6 +13,14 @@ test_Dockerfile(){ cat inspect.json # Check SSH Ports + # Only 2 ports allowed where one is always 2222 + testPORTS=$(jq .[].Config.ExposedPorts inspect.json | grep -o ":" | wc -w) + if [ ${testPORTS} -gt 2 ]; then + echo "${testPORTS}" + echo "FAILED - Too many ports are exposed!!!" + exit 1 + fi + testSSH=$(jq .[].Config.ExposedPorts inspect.json | grep 2222) if [ -z "${testSSH}" ]; then echo "FAILED - PORT 2222 isn't opened, SSH isn't working!!!"