Skip to content

Commit

Permalink
Add test for trap agent identification
Browse files Browse the repository at this point in the history
This detects the problem described by Uninett#2497
  • Loading branch information
lunkwill42 committed Nov 10, 2022
1 parent 4c0e8b9 commit 8ce2240
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion tests/integration/snmptrapd_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import time
from nav.config import find_config_file
from nav.snmptrapd.plugin import load_handler_modules

from nav.snmptrapd.trap import SNMPTrap

# Implementation tests for plugins

Expand Down Expand Up @@ -75,3 +75,20 @@ def first_alarm(*_):
handler.close()
signal.signal(signal.SIGALRM, signal.SIG_DFL)
signal.alarm(0)


class TestSnmpTrap:
def test_trap_agent_should_be_correctly_identified(self, localhost_using_legacy_db):
trap = SNMPTrap(
src="127.0.0.1",
agent="127.0.0.1",
type=None,
genericType=None,
snmpTrapOID=None,
uptime=None,
community="public",
version=2,
varbinds={},
)
netbox = trap.netbox
assert netbox.netboxid == localhost_using_legacy_db

0 comments on commit 8ce2240

Please sign in to comment.