forked from etingof/pysnmp
-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |
24 changes: 24 additions & 0 deletions
24
tests/hlapi/asyncio/manager/cmdgen/test_usm_sha_none_wrong_user.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |