Skip to content

Commit

Permalink
Added extra Docker container, tests, and credit for PR #5.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmuth committed Nov 2, 2019
1 parent b05fb33 commit 43512da
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ The following environment variables can be set to output debugging info:
## Credits

- <a href="https://github.com/steinbrueckri">Richard Steinbrück</a> - Added spport for port ranges.
- <a href="https://github.com/ladrob">ladrob</a> - Added friendly message for when Netcat is not installed


## TODO
Expand Down
18 changes: 18 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,24 @@ services:
environment:
- SSH_ENABLE_ROOT=true

source-no-netcat:
#
# Docs for this excelent container available at:
#
# https://github.com/panubo/docker-sshd
#
build:
context: .
dockerfile: files/Dockerfile-source-no-netcat

volumes:
- .:/mnt
- ./files/dummy-ssh-keys/testing.pub:/root/.ssh/authorized_keys
- ./files/source-motd:/etc/motd

environment:
- SSH_ENABLE_ROOT=true

source-netcat-openbsd:

build:
Expand Down
13 changes: 13 additions & 0 deletions files/Dockerfile-source-no-netcat
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

#
# Built from https://github.com/panubo/docker-sshd
#
FROM docker.io/panubo/sshd:1.0.3

# Add bash and remove Netcat
RUN apk update \
&& apk add bash \
&& rm -fv /usr/bin/nc

# No need for an ENTRYPOINT, as the source Docker image provides one.

9 changes: 9 additions & 0 deletions files/snowdrift-tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ source:dest01:441
source:dest01:450
source:dest01:451

source-no-netcat:dest01:80
source-no-netcat:dest01:81
source-no-netcat:dest01:440
source-no-netcat:dest01:441
source-no-netcat:dest01:450
source-no-netcat:dest01:451

source-netcat-openbsd:dest01:80
source-netcat-openbsd:dest01:81
source-netcat-openbsd:dest01:440
Expand Down Expand Up @@ -47,3 +54,5 @@ source-ubuntu-openbsd:dest01:441
source-ubuntu-openbsd:dest01:450
source-ubuntu-openbsd:dest01:451



10 changes: 6 additions & 4 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ function compareValues() {

if test "${VAL}" == "${EXPECTED}"
then
printf "%30s: %-14s ${GREEN}SUCCESS${NC}\n" "${STR}" "${VAL} == ${EXPECTED}"
printf "%36s: %-14s ${GREEN}SUCCESS${NC}\n" "${STR}" "${VAL} == ${EXPECTED}"

else
printf "%30s: %-14s ${RED}FAIL${NC}\n" "${STR}" "${VAL} == ${EXPECTED}"
printf "%36s: %-14s ${RED}FAIL${NC}\n" "${STR}" "${VAL} == ${EXPECTED}"

fi

Expand Down Expand Up @@ -128,16 +128,18 @@ docker-compose exec testing /mnt/snowdrift /mnt/${TMP_TESTS} | tee $TMP
RESULTS=$(cat $TMP)
rm -f $TMP $TMP_TESTS

NUM_NETCAT_NOT_INSTALLED=$(echo "$RESULTS" | grep "Netcat not installed" | wc -l | awk '{print $1}' )
TOTAL_HOSTS_SUCCESS=$(getMetric "Total Successful Hosts: ")
TOTAL_HOSTS_FAILED=$(getMetric "Total Failed Hosts: ")
TOTAL_CONNS_SUCCESS=$(getMetric "Total Successful Connections: ")
TOTAL_CONNS_FAILED=$(getMetric "Total Failed Connections: ")


compareValues "Total Hosts Successful" $TOTAL_HOSTS_SUCCESS "5"
compareValues "Num tests where Netcat not installed" $NUM_NETCAT_NOT_INSTALLED "6"
compareValues "Total Hosts Successful" $TOTAL_HOSTS_SUCCESS "6"
compareValues "Total Hosts Failed" $TOTAL_HOSTS_FAILED "ZERO"
compareValues "Total Connections Successful" $TOTAL_CONNS_SUCCESS "36"
compareValues "Total Connections Failed" $TOTAL_CONNS_FAILED "15"
compareValues "Total Connections Failed" $TOTAL_CONNS_FAILED "21"


echo "# Done!"
Expand Down

0 comments on commit 43512da

Please sign in to comment.