Skip to content

Commit

Permalink
Added two test cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
lextm committed Feb 3, 2024
1 parent 6521c80 commit 8d30d95
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions Development.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Change Poetry Venv Python Version

```bash
pyenv local 3.12
poetry env use 3.12
poetry env info --path
```
Expand Down
22 changes: 22 additions & 0 deletions tests/hlapi/asyncio/manager/cmdgen/test_usm_none_none.py
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)
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'

0 comments on commit 8d30d95

Please sign in to comment.