Skip to content

Commit

Permalink
Added a new test case.
Browse files Browse the repository at this point in the history
  • Loading branch information
lextm committed Oct 5, 2024
1 parent a7c3299 commit 39441de
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/hlapi/v3arch/asyncio/agent/ntforg/test_v3-trap.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,25 @@ async def test_send_v3_trap_notification():
assert message_count == [1]


@pytest.mark.asyncio
async def test_send_v3_trap_notification_none():
async with ManagerContextManager() as (_, message_count):
# snmptrap -v3 -l noAuthNoPriv -u usr-none-none -e 8000000001020305 localhost:MANAGER_PORT 0 1.3.6.1.6.3.1.1.5.1 1.3.6.1.2.1.1.1.0 s "my system"
snmpEngine = SnmpEngine(OctetString(hexValue="8000000001020305"))
errorIndication, errorStatus, errorIndex, varBinds = await sendNotification(
snmpEngine,
UsmUserData("usr-none-none", None, None),
await UdpTransportTarget.create(("localhost", MANAGER_PORT)),
ContextData(),
"trap",
NotificationType(ObjectIdentity("IF-MIB", "linkDown")),
)

snmpEngine.closeDispatcher()
await asyncio.sleep(1)
assert message_count == [1]


@pytest.mark.asyncio
async def test_send_v3_trap_notification_invalid_user():
async with ManagerContextManager() as (_, message_count):
Expand Down
10 changes: 10 additions & 0 deletions tests/manager_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ async def start_manager(
securityEngineId=v2c.OctetString(hexValue="8000000001020304"),
)

# user: usr-none-none, auth: NONE, priv: NONE
# this USM entry is used for TRAP receiving purposes
config.addV3User(
snmpEngine,
"usr-none-none",
config.USM_AUTH_NONE,
config.USM_PRIV_NONE,
securityEngineId=v2c.OctetString(hexValue="8000000001020305"),
)

# Callback function for receiving notifications
# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal
def cbFun(
Expand Down

0 comments on commit 39441de

Please sign in to comment.