Skip to content

Commit

Permalink
Adding messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
edufolly committed Apr 25, 2024
1 parent d027d65 commit 375c356
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
tests:
name: Tests
runs-on: ubuntu-latest
timeout-minutes: 20
timeout-minutes: 5
strategy:
matrix:
alpine:
Expand Down
26 changes: 20 additions & 6 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,32 +35,36 @@ SNMP_V3_USER="testainers"
# SNMPv2c #
###########

echo "SNMPv2c"
docker run --rm --name "$CONTAINER_NAME" -p "$PORT:161/udp" -d "$IMAGE_NAME"

sleep 2

# SNMPv2c - Walk
echo "SNMPv2c - Walk"
snmpwalk -v 2c -c public "$HOST:$PORT" "$WALK" >/dev/null 2>&1

if [ $? -ne 0 ]; then
CODE=10
fi

# SNMPv2c - Get
echo "SNMPv2c - Get"
RESULT=$(snmpget -v2c -c public -Ovq "$HOST:$PORT" "$GET")

if [ "$RESULT" != "At flying circus" ]; then
CODE=11
fi

# SNMPv2c - GetNext
echo "SNMPv2c - GetNext"
RESULT=$(snmpgetnext -v2c -c public -Ovq "$HOST:$PORT" "$GET")

if [ "$RESULT" != "72" ]; then
CODE=12
fi

# SNMPv3 - Get - Need to fail
echo "SNMPv3 - Get"
snmpget -v3 -Ovq -u "$SNMP_V3_USER" -l noAuthNoPriv \
"$HOST:$PORT" "$GET" >/dev/null 2>&1

Expand All @@ -69,8 +73,8 @@ if [ $? -eq 0 ]; then
fi

# Stop Container
echo "Stop Container"
docker stop -t 1 "$CONTAINER_NAME"

sleep 2

##############################
Expand All @@ -84,17 +88,19 @@ sleep 2
################################

SNMP_V3_AUTH_PROTOCOL="SHA"
SNMP_V3_AUTH_PWD=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 12 | head -n 1)
# SNMP_V3_AUTH_PWD=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 12 | head -n 1)
SNMP_V3_AUTH_PWD="a1b2c3d4e5f6"

echo "SNMPv3 with auth and NO priv"
docker run --rm --name "$CONTAINER_NAME" -p "$PORT:161/udp" -d \
-e SNMP_V3_USER=$SNMP_V3_USER \
-e SNMP_V3_AUTH_PROTOCOL=$SNMP_V3_AUTH_PROTOCOL \
-e SNMP_V3_AUTH_PWD=$SNMP_V3_AUTH_PWD \
"$IMAGE_NAME"

sleep 2

# SNMPv3 - Walk
echo "SNMPv3 - Walk"
snmpwalk -v3 -On -u "$SNMP_V3_USER" \
-l authNoPriv \
-a "$SNMP_V3_AUTH_PROTOCOL" \
Expand All @@ -106,6 +112,7 @@ if [ $? -ne 0 ]; then
fi

# SNMPv3 - Get
echo "SNMPv3 - Get"
RESULT=$(snmpget -v3 -Ovq -u "$SNMP_V3_USER" \
-l authNoPriv \
-a "$SNMP_V3_AUTH_PROTOCOL" \
Expand All @@ -117,6 +124,7 @@ if [ "$RESULT" != "At flying circus" ]; then
fi

# SNMPv3 - GetNext
echo "SNMPv3 - GetNext"
RESULT=$(snmpgetnext -v3 -Ovq -u "$SNMP_V3_USER" \
-l authNoPriv \
-a "$SNMP_V3_AUTH_PROTOCOL" \
Expand All @@ -128,6 +136,7 @@ if [ "$RESULT" != "72" ]; then
fi

# Stop Container
echo "Stop Container"
docker stop -t 1 "$CONTAINER_NAME"

sleep 2
Expand All @@ -137,19 +146,21 @@ sleep 2
#####################################

SNMP_V3_PRIV_PROTOCOL="AES"
SNMP_V3_PRIV_PWD=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 12 | head -n 1)
# SNMP_V3_PRIV_PWD=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 12 | head -n 1)
SNMP_V3_PRIV_PWD="f6e5d4c3b2a1"

echo "SNMPv3 with auth and with privacy"
docker run --rm --name "$CONTAINER_NAME" -p "$PORT:161/udp" -d \
-e SNMP_V3_USER=$SNMP_V3_USER \
-e SNMP_V3_AUTH_PROTOCOL=$SNMP_V3_AUTH_PROTOCOL \
-e SNMP_V3_AUTH_PWD=$SNMP_V3_AUTH_PWD \
-e SNMP_V3_PRIV_PROTOCOL=$SNMP_V3_PRIV_PROTOCOL \
-e SNMP_V3_PRIV_PWD=$SNMP_V3_PRIV_PWD \
"$IMAGE_NAME"

sleep 2

# SNMPv3 - Walk
echo "SNMPv3 - Walk"
snmpwalk -v3 -On -u "$SNMP_V3_USER" \
-l authPriv \
-a "$SNMP_V3_AUTH_PROTOCOL" \
Expand All @@ -163,6 +174,7 @@ if [ $? -ne 0 ]; then
fi

# SNMPv3 - Get
echo "SNMPv3 - Get"
RESULT=$(snmpget -v3 -Ovq -u "$SNMP_V3_USER" \
-l authPriv \
-a "$SNMP_V3_AUTH_PROTOCOL" \
Expand All @@ -176,6 +188,7 @@ if [ "$RESULT" != "At flying circus" ]; then
fi

# SNMPv3 - GetNext
echo "SNMPv3 - GetNext"
RESULT=$(snmpgetnext -v3 -Ovq -u "$SNMP_V3_USER" \
-l authPriv \
-a "$SNMP_V3_AUTH_PROTOCOL" \
Expand All @@ -189,6 +202,7 @@ if [ "$RESULT" != "72" ]; then
fi

# Stop container
echo "Stop Container"
docker stop -t 1 "$CONTAINER_NAME"

sleep 2
Expand Down

0 comments on commit 375c356

Please sign in to comment.