diff --git a/tests/hlapi/asyncio/manager/cmdgen/test_usm_sha_none.py b/tests/hlapi/asyncio/manager/cmdgen/test_usm_sha_none.py new file mode 100644 index 000000000..d9adfb013 --- /dev/null +++ b/tests/hlapi/asyncio/manager/cmdgen/test_usm_sha_none.py @@ -0,0 +1,26 @@ +import pytest +from pysnmp.hlapi.asyncio import * + +@pytest.mark.asyncio +async def test_usm_sha_none(): + snmpEngine = SnmpEngine() + authData = UsmUserData( + "usr-sha-none", + "authkey1", + authProtocol=usmHMACSHAAuthProtocol, + ) + errorIndication, errorStatus, errorIndex, varBinds = await getCmd( + snmpEngine, + authData, + UdpTransportTarget(("demo.pysnmp.com", 161), retries=0), + ContextData(), + ObjectType(ObjectIdentity("SNMPv2-MIB", "sysDescr", 0)), + ) + + assert errorIndication is None + assert errorStatus == 0 + assert len(varBinds) == 1 + assert varBinds[0][0].prettyPrint() == "SNMPv2-MIB::sysDescr.0" + isinstance(varBinds[0][1], OctetString) + + snmpEngine.transportDispatcher.closeDispatcher() diff --git a/tests/hlapi/asyncio/manager/cmdgen/test_usm_sha_none_wrong_user.py b/tests/hlapi/asyncio/manager/cmdgen/test_usm_sha_none_wrong_user.py new file mode 100644 index 000000000..4eaf84e4d --- /dev/null +++ b/tests/hlapi/asyncio/manager/cmdgen/test_usm_sha_none_wrong_user.py @@ -0,0 +1,24 @@ +import pytest +from pysnmp.hlapi.asyncio import * +from pysnmp.proto.errind import UnknownUserName + +@pytest.mark.asyncio +async def test_usm_sha_none_wrong_user(): + snmpEngine = SnmpEngine() + authData = UsmUserData( + "usr-sha-none-not-exist", + "authkey1", + authProtocol=usmHMACSHAAuthProtocol, + ) + errorIndication, errorStatus, errorIndex, varBinds = await getCmd( + snmpEngine, + authData, + UdpTransportTarget(("demo.pysnmp.com", 161), retries=0), + ContextData(), + ObjectType(ObjectIdentity("SNMPv2-MIB", "sysDescr", 0)), + ) + + assert isinstance(errorIndication, UnknownUserName) + assert str(errorIndication) == 'Unknown USM user' + + snmpEngine.transportDispatcher.closeDispatcher()