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
3 changed files
with
43 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
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,22 @@ | ||
import pytest | ||
from pysnmp.hlapi.asyncio import * | ||
|
||
@pytest.mark.asyncio | ||
async def test_usm_no_auth_no_priv(): | ||
snmpEngine = SnmpEngine() | ||
authData = UsmUserData( | ||
"usr-none-none" | ||
) | ||
errorIndication, errorStatus, errorIndex, varBinds = await getCmd( | ||
snmpEngine, | ||
authData, | ||
UdpTransportTarget(("demo.pysnmp.com", 161)), | ||
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) |
20 changes: 20 additions & 0 deletions
20
tests/hlapi/asyncio/manager/cmdgen/test_usm_none_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,20 @@ | ||
import pytest | ||
from pysnmp.hlapi.asyncio import * | ||
from pysnmp.proto.errind import DecryptionError | ||
|
||
@pytest.mark.asyncio | ||
async def test_usm_no_auth_no_priv_wrong_user(): | ||
snmpEngine = SnmpEngine() | ||
authData = UsmUserData( | ||
"usr-none-none-not-exist" | ||
) | ||
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, DecryptionError) | ||
# assert str(errorIndication) == 'Ciphering services not available or ciphertext is broken' |