Skip to content

Handle non-ascii community values in incoming traps without crashing #91

Handle non-ascii community values in incoming traps without crashing

Handle non-ascii community values in incoming traps without crashing #91

GitHub Actions / Test results failed Sep 4, 2025 in 0s

4 errors, 21 pass in 24s

 3 files   3 suites   24s ⏱️
25 tests 21 ✅ 0 💤 0 ❌ 4 🔥
75 runs  71 ✅ 0 💤 0 ❌ 4 🔥

Results for commit 6073f43.

Annotations

Check failure on line 0 in tests.test_session

See this annotation in the file changed.

@github-actions github-actions / Test results

1 out of 3 runs with error: test_it_should_agetnext_sysdescr_from_localhost (tests.test_session)

artifacts/reports-3.12/py312/unit-results.xml [took 6s]
Raw output
failed on setup with "TimeoutError"
fixturedef = <FixtureDef argname='snmpsim' scope='session' baseid='tests'>
request = <SubRequest 'snmpsim' for <Coroutine test_it_should_agetnext_sysdescr_from_localhost>>

    @pytest.hookimpl(wrapper=True)
    def pytest_fixture_setup(fixturedef: FixtureDef, request) -> object | None:
        asyncio_mode = _get_asyncio_mode(request.config)
        if not _is_asyncio_fixture_function(fixturedef.func):
            if asyncio_mode == Mode.STRICT:
                # Ignore async fixtures without explicit asyncio mark in strict mode
                # This applies to pytest_trio fixtures, for example
                return (yield)
            if not _is_coroutine_or_asyncgen(fixturedef.func):
                return (yield)
        default_loop_scope = request.config.getini("asyncio_default_fixture_loop_scope")
        loop_scope = (
            getattr(fixturedef.func, "_loop_scope", None)
            or default_loop_scope
            or fixturedef.scope
        )
        runner_fixture_id = f"_{loop_scope}_scoped_runner"
        runner = request.getfixturevalue(runner_fixture_id)
        synchronizer = _fixture_synchronizer(fixturedef, runner, request)
        _make_asyncio_fixture_function(synchronizer, loop_scope)
        with MonkeyPatch.context() as c:
            c.setattr(fixturedef, "func", synchronizer)
>           hook_result = yield
                          ^^^^^

.tox/py312/lib/python3.12/site-packages/pytest_asyncio/plugin.py:696: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.tox/py312/lib/python3.12/site-packages/pytest_asyncio/plugin.py:272: in _asyncgen_fixture_wrapper
    result = runner.run(setup(), context=context)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/opt/hostedtoolcache/Python/3.12.11/x64/lib/python3.12/asyncio/runners.py:118: in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/opt/hostedtoolcache/Python/3.12.11/x64/lib/python3.12/asyncio/base_events.py:691: in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
.tox/py312/lib/python3.12/site-packages/pytest_asyncio/plugin.py:268: in setup
    res = await gen_obj.__anext__()  # type: ignore[union-attr]
          ^^^^^^^^^^^^^^^^^^^^^^^^^
tests/conftest.py:49: in snmpsim
    await _wait_for_snmpsimd()
tests/conftest.py:44: in _wait_for_snmpsimd
    if await _verify_localhost_snmp_response(snmp_test_port):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/conftest.py:23: in _verify_localhost_snmp_response
    return await sess.aget(sysobjectid0)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <netsnmpy.session.SNMPSession object at 0x7fd47d2fafc0>
oids = (OID('.1.3.6.1.2.1.1.2.0'),)
request = <cdata 'struct snmp_pdu *' 0x55fea3d037e0>

    async def aget(self, *oids: OID) -> VarBindList:
        """Performs an asynchronous SNMP GET request"""
        request = make_request_pdu(SNMP_MSG_GET, *oids)
>       return await self._send_async(request, "get")
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E       TimeoutError

src/netsnmpy/session.py:207: TimeoutError

Check failure on line 0 in tests.test_session

See this annotation in the file changed.

@github-actions github-actions / Test results

1 out of 3 runs with error: test_it_should_getnext_sysdescr_from_localhost (tests.test_session)

artifacts/reports-3.12/py312/unit-results.xml [took 0s]
Raw output
failed on setup with "TimeoutError"
args = ()
kwargs = {'snmp_fixture_directory': '/home/runner/work/netsnmp-cffi/netsnmp-cffi/tests/snmp_fixtures', 'snmp_test_port': 1024, 'snmpsimd_path': '/home/runner/work/netsnmp-cffi/netsnmp-cffi/.tox/py312/bin/snmpsim-command-responder'}
setup = <function _wrap_asyncgen_fixture.<locals>._asyncgen_fixture_wrapper.<locals>.setup at 0x7fd47c66aa20>

    @functools.wraps(fixture_function)
    def _asyncgen_fixture_wrapper(
        *args: AsyncGenFixtureParams.args,
        **kwargs: AsyncGenFixtureParams.kwargs,
    ):
        gen_obj = fixture_function(*args, **kwargs)
    
        async def setup():
            res = await gen_obj.__anext__()  # type: ignore[union-attr]
            return res
    
        context = contextvars.copy_context()
>       result = runner.run(setup(), context=context)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.tox/py312/lib/python3.12/site-packages/pytest_asyncio/plugin.py:272: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/opt/hostedtoolcache/Python/3.12.11/x64/lib/python3.12/asyncio/runners.py:118: in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/opt/hostedtoolcache/Python/3.12.11/x64/lib/python3.12/asyncio/base_events.py:691: in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
.tox/py312/lib/python3.12/site-packages/pytest_asyncio/plugin.py:268: in setup
    res = await gen_obj.__anext__()  # type: ignore[union-attr]
          ^^^^^^^^^^^^^^^^^^^^^^^^^
tests/conftest.py:49: in snmpsim
    await _wait_for_snmpsimd()
tests/conftest.py:44: in _wait_for_snmpsimd
    if await _verify_localhost_snmp_response(snmp_test_port):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/conftest.py:23: in _verify_localhost_snmp_response
    return await sess.aget(sysobjectid0)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <netsnmpy.session.SNMPSession object at 0x7fd47d2fafc0>
oids = (OID('.1.3.6.1.2.1.1.2.0'),)
request = <cdata 'struct snmp_pdu *' 0x55fea3d037e0>

    async def aget(self, *oids: OID) -> VarBindList:
        """Performs an asynchronous SNMP GET request"""
        request = make_request_pdu(SNMP_MSG_GET, *oids)
>       return await self._send_async(request, "get")
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E       TimeoutError

src/netsnmpy/session.py:207: TimeoutError

Check failure on line 0 in tests.test_session

See this annotation in the file changed.

@github-actions github-actions / Test results

1 out of 3 runs with error: test_it_should_bulkget_sysuptime_and_sysdescr_from_localhost (tests.test_session)

artifacts/reports-3.12/py312/unit-results.xml [took 0s]
Raw output
failed on setup with "TimeoutError"
args = ()
kwargs = {'snmp_fixture_directory': '/home/runner/work/netsnmp-cffi/netsnmp-cffi/tests/snmp_fixtures', 'snmp_test_port': 1024, 'snmpsimd_path': '/home/runner/work/netsnmp-cffi/netsnmp-cffi/.tox/py312/bin/snmpsim-command-responder'}
setup = <function _wrap_asyncgen_fixture.<locals>._asyncgen_fixture_wrapper.<locals>.setup at 0x7fd47c66aa20>

    @functools.wraps(fixture_function)
    def _asyncgen_fixture_wrapper(
        *args: AsyncGenFixtureParams.args,
        **kwargs: AsyncGenFixtureParams.kwargs,
    ):
        gen_obj = fixture_function(*args, **kwargs)
    
        async def setup():
            res = await gen_obj.__anext__()  # type: ignore[union-attr]
            return res
    
        context = contextvars.copy_context()
>       result = runner.run(setup(), context=context)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.tox/py312/lib/python3.12/site-packages/pytest_asyncio/plugin.py:272: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/opt/hostedtoolcache/Python/3.12.11/x64/lib/python3.12/asyncio/runners.py:118: in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/opt/hostedtoolcache/Python/3.12.11/x64/lib/python3.12/asyncio/base_events.py:691: in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
.tox/py312/lib/python3.12/site-packages/pytest_asyncio/plugin.py:268: in setup
    res = await gen_obj.__anext__()  # type: ignore[union-attr]
          ^^^^^^^^^^^^^^^^^^^^^^^^^
tests/conftest.py:49: in snmpsim
    await _wait_for_snmpsimd()
tests/conftest.py:44: in _wait_for_snmpsimd
    if await _verify_localhost_snmp_response(snmp_test_port):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/conftest.py:23: in _verify_localhost_snmp_response
    return await sess.aget(sysobjectid0)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <netsnmpy.session.SNMPSession object at 0x7fd47d2fafc0>
oids = (OID('.1.3.6.1.2.1.1.2.0'),)
request = <cdata 'struct snmp_pdu *' 0x55fea3d037e0>

    async def aget(self, *oids: OID) -> VarBindList:
        """Performs an asynchronous SNMP GET request"""
        request = make_request_pdu(SNMP_MSG_GET, *oids)
>       return await self._send_async(request, "get")
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E       TimeoutError

src/netsnmpy/session.py:207: TimeoutError

Check failure on line 0 in tests.test_session

See this annotation in the file changed.

@github-actions github-actions / Test results

1 out of 3 runs with error: test_get_should_work_more_than_once (tests.test_session)

artifacts/reports-3.12/py312/unit-results.xml [took 0s]
Raw output
failed on setup with "TimeoutError"
args = ()
kwargs = {'snmp_fixture_directory': '/home/runner/work/netsnmp-cffi/netsnmp-cffi/tests/snmp_fixtures', 'snmp_test_port': 1024, 'snmpsimd_path': '/home/runner/work/netsnmp-cffi/netsnmp-cffi/.tox/py312/bin/snmpsim-command-responder'}
setup = <function _wrap_asyncgen_fixture.<locals>._asyncgen_fixture_wrapper.<locals>.setup at 0x7fd47c66aa20>

    @functools.wraps(fixture_function)
    def _asyncgen_fixture_wrapper(
        *args: AsyncGenFixtureParams.args,
        **kwargs: AsyncGenFixtureParams.kwargs,
    ):
        gen_obj = fixture_function(*args, **kwargs)
    
        async def setup():
            res = await gen_obj.__anext__()  # type: ignore[union-attr]
            return res
    
        context = contextvars.copy_context()
>       result = runner.run(setup(), context=context)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.tox/py312/lib/python3.12/site-packages/pytest_asyncio/plugin.py:272: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/opt/hostedtoolcache/Python/3.12.11/x64/lib/python3.12/asyncio/runners.py:118: in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/opt/hostedtoolcache/Python/3.12.11/x64/lib/python3.12/asyncio/base_events.py:691: in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
.tox/py312/lib/python3.12/site-packages/pytest_asyncio/plugin.py:268: in setup
    res = await gen_obj.__anext__()  # type: ignore[union-attr]
          ^^^^^^^^^^^^^^^^^^^^^^^^^
tests/conftest.py:49: in snmpsim
    await _wait_for_snmpsimd()
tests/conftest.py:44: in _wait_for_snmpsimd
    if await _verify_localhost_snmp_response(snmp_test_port):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tests/conftest.py:23: in _verify_localhost_snmp_response
    return await sess.aget(sysobjectid0)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <netsnmpy.session.SNMPSession object at 0x7fd47d2fafc0>
oids = (OID('.1.3.6.1.2.1.1.2.0'),)
request = <cdata 'struct snmp_pdu *' 0x55fea3d037e0>

    async def aget(self, *oids: OID) -> VarBindList:
        """Performs an asynchronous SNMP GET request"""
        request = make_request_pdu(SNMP_MSG_GET, *oids)
>       return await self._send_async(request, "get")
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E       TimeoutError

src/netsnmpy/session.py:207: TimeoutError

Check notice on line 0 in .github

See this annotation in the file changed.

@github-actions github-actions / Test results

25 tests found

There are 25 tests, see "Raw output" for the full list of tests.
Raw output
tests.test_netsmp_ffi ‑ test_ffi_definitions_should_compile
tests.test_netsnmp ‑ test_when_netsnmp_debug_logging_is_enabled_load_mibs_should_log_debug_msgs
tests.test_netsnmp.TestDecodeString ‑ test_when_input_contains_nul_chars_it_should_include_them
tests.test_oids.TestOIDAdd ‑ test_when_adding_a_valid_oid_string_it_should_return_expected_oid
tests.test_oids.TestOIDAdd ‑ test_when_adding_an_invalid_oid_string_it_should_raise_valueerror
tests.test_oids.TestOIDAdd ‑ test_when_adding_two_oids_it_should_return_expected_oid
tests.test_oids.TestOIDInit ‑ test_when_input_is_integer_it_should_raise_typeerror
tests.test_oids.TestOIDInit ‑ test_when_input_is_integer_tuple_it_should_instantiate
tests.test_oids.TestOIDInit ‑ test_when_input_is_invalid_oid_string_it_should_raise_valueerror
tests.test_oids.TestOIDInit ‑ test_when_input_is_valid_oid_bytes_it_should_instantiate
tests.test_oids.TestOIDInit ‑ test_when_input_is_valid_oid_string_it_should_instantiate
tests.test_oids.TestOIDIsAPrefix ‑ test_when_oid_is_not_a_prefix_of_other_it_should_return_false
tests.test_oids.TestOIDIsAPrefix ‑ test_when_oid_is_prefix_of_other_it_should_return_true
tests.test_oids.TestOIDStrings ‑ test_repr_should_return_expected_representation
tests.test_oids.TestOIDStrings ‑ test_str_should_return_expected_string
tests.test_oids.TestOIDStripPrefix ‑ test_when_input_is_a_prefix_it_should_return_a_stripped_oid
tests.test_oids.TestOIDStripPrefix ‑ test_when_input_is_not_a_prefix_it_should_return_itself
tests.test_session ‑ test_get_should_work_more_than_once
tests.test_session ‑ test_it_should_agetnext_sysdescr_from_localhost
tests.test_session ‑ test_it_should_bulkget_sysuptime_and_sysdescr_from_localhost
tests.test_session ‑ test_it_should_getnext_sysdescr_from_localhost
tests.test_session ‑ test_too_many_sessions_should_raise_sensible_exception
tests.test_session ‑ test_when_host_is_unreachable_then_agent_should_raise_timeout
tests.test_session ‑ test_when_snmp_version_is_invalid_it_should_raise_valueerror
tests.test_trapsession.TestSNMPTrap ‑ test_given_trap_with_non_ascii_community_then_from_pdu_should_not_crash