Skip to content

Commit

Permalink
Revised test cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
lextm committed Feb 4, 2024
1 parent 242401a commit 41ae447
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ async def test_usm_no_auth_no_priv_wrong_user():
)

assert isinstance(errorIndication, UnknownUserName)
# assert str(errorIndication) == 'Unknown USM user'
assert str(errorIndication) == 'Unknown USM user'
snmpEngine.transportDispatcher.closeDispatcher()
3 changes: 1 addition & 2 deletions tests/hlapi/asyncio/manager/cmdgen/test_usm_sha_aes128.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import pytest
from pysnmp.hlapi.asyncio import *


@pytest.mark.asyncio
async def test_usm_sha_aes128():
snmpEngine = SnmpEngine()
Expand All @@ -15,7 +14,7 @@ async def test_usm_sha_aes128():
errorIndication, errorStatus, errorIndex, varBinds = await getCmd(
snmpEngine,
authData,
UdpTransportTarget(("demo.pysnmp.com", 161)),
UdpTransportTarget(("demo.pysnmp.com", 161), retries=0),
ContextData(),
ObjectType(ObjectIdentity("SNMPv2-MIB", "sysDescr", 0)),
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import pytest
from pysnmp.hlapi.asyncio import *
from pysnmp.proto.errind import UnknownUserName

@pytest.mark.asyncio
async def test_usm_sha_aes128_wrong_user():
snmpEngine = SnmpEngine()
authData = UsmUserData(
"usr-sha-aes-not-exist",
"authkey1",
"privkey1",
authProtocol=usmHMACSHAAuthProtocol,
privProtocol=usmAesCfb128Protocol,
)
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()

0 comments on commit 41ae447

Please sign in to comment.