#!/bin/sh

. ../eval_tools.sh

HEADER SNMPv3 user creation and usage using snmpusm
SKIPIFNOT USE_OPENSSL

#
# Begin test
#

# standard V3 configuration for initial user
. ./Sv3config

STARTAGENT

CAPTURE "snmpusm $SNMP_FLAGS $AUTHTESTARGS $SNMP_TRANSPORT_SPEC:$SNMP_TEST_DEST$SNMP_SNMPD_PORT create newtestuser template"
CHECKORDIE "User successfully created"

CAPTURE "snmpusm $SNMP_FLAGS -Cx -x $DEFPRIVTYPE -v 3 -a $DEFAUTHTYPE -A template_test_pass_auth -l anp -u newtestuser $SNMP_TRANSPORT_SPEC:$SNMP_TEST_DEST$SNMP_SNMPD_PORT passwd template_test_pass_auth newtestpass"
CHECKORDIE "SNMPv3 Key(s) successfully changed"

CAPTURE "snmpusm $SNMP_FLAGS -Ca -v 3 -a $DEFAUTHTYPE -A template_test_pass_auth -l anp -u newtestuser $SNMP_TRANSPORT_SPEC:$SNMP_TEST_DEST$SNMP_SNMPD_PORT passwd template_test_pass_auth newtestpass"
CHECKORDIE "SNMPv3 Key(s) successfully changed"

CAPTURE "snmpget -On $SNMP_FLAGS -v 3 -a $DEFAUTHTYPE -A newtestpass -l anp -u newtestuser $SNMP_TRANSPORT_SPEC:$SNMP_TEST_DEST$SNMP_SNMPD_PORT .1.3.6.1.2.1.1.3.0"
CHECKORDIE ".1.3.6.1.2.1.1.3.0 = Timeticks:"

# auth
CAPTURE "snmpget -On $SNMP_FLAGS -v 3 -a $DEFAUTHTYPE -A newtestpass -l anp -u newtestuser $SNMP_TRANSPORT_SPEC:$SNMP_TEST_DEST$SNMP_SNMPD_PORT .1.3.6.1.2.1.1.3.0"
CHECKORDIE ".1.3.6.1.2.1.1.3.0 = Timeticks:"

# auth & encr
CAPTURE "snmpget -On $SNMP_FLAGS -v 3 -a $DEFAUTHTYPE -A newtestpass -x $DEFPRIVTYPE -X newtestpass -l ap -u newtestuser $SNMP_TRANSPORT_SPEC:$SNMP_TEST_DEST$SNMP_SNMPD_PORT .1.3.6.1.2.1.1.3.0"
CHECKORDIE ".1.3.6.1.2.1.1.3.0 = Timeticks:"

# change both keys at once
CAPTURE "snmpusm $SNMP_FLAGS -v 3 -x $DEFPRIVTYPE -a $DEFAUTHTYPE -A newtestpass -l anp -u newtestuser $SNMP_TRANSPORT_SPEC:$SNMP_TEST_DEST$SNMP_SNMPD_PORT passwd newtestpass myotherpass"
CHECKORDIE "SNMPv3 Key(s) successfully changed"

# auth & encr
CAPTURE "snmpget -On $SNMP_FLAGS -v 3 -a $DEFAUTHTYPE -A myotherpass -x $DEFPRIVTYPE -X myotherpass -l ap -u newtestuser $SNMP_TRANSPORT_SPEC:$SNMP_TEST_DEST$SNMP_SNMPD_PORT .1.3.6.1.2.1.1.3.0"
CHECKORDIE ".1.3.6.1.2.1.1.3.0 = Timeticks:"

STOPAGENT


FINISHED
