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
38 additions
and
20 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 |
---|---|---|
@@ -1,19 +1,27 @@ | ||
import asyncio | ||
import pytest | ||
|
||
|
||
from pysnmp.hlapi.v3arch.asyncio import * | ||
from tests.manager_context import MANAGER_PORT, ManagerContextManager | ||
import tests.manager_context | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_send_v3_trap_notification(): | ||
async with ManagerContextManager(): | ||
async with tests.manager_context.ManagerContextManager(): | ||
# snmptrap -v3 -l authPriv -u usr-md5-des -A authkey1 -X privkey1 -e 8000000001020304 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="8000000001020304")) | ||
errorIndication, errorStatus, errorIndex, varBinds = await sendNotification( | ||
snmpEngine, | ||
UsmUserData("usr-md5-des", "authkey1", "privkey1"), | ||
await UdpTransportTarget.create(("localhost", MANAGER_PORT)), | ||
await UdpTransportTarget.create( | ||
("localhost", tests.manager_context.MANAGER_PORT) | ||
), | ||
ContextData(), | ||
"trap", | ||
NotificationType(ObjectIdentity("IF-MIB", "linkDown")), | ||
) | ||
|
||
snmpEngine.closeDispatcher() | ||
await asyncio.sleep(1) | ||
assert tests.manager_context.message_count == 1 |
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