File: test_v3_cache.py

package info (click to toggle)
python-easysnmp 0.2.6-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 540 kB
  • sloc: ansic: 3,735; python: 1,410; makefile: 161
file content (31 lines) | stat: -rw-r--r-- 836 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from __future__ import unicode_literals

import pytest
from easysnmp import Session
from easysnmp.exceptions import EasySNMPConnectionError


def test_v3_not_caching_user(sess_v3):
    s = Session(**sess_v3)
    res = s.get('sysDescr.0')

    assert res.oid == "sysDescr"
    assert res.oid_index == "0"
    assert res.snmp_type == "OCTETSTR"
    s.update_session(privacy_password="wrong_pass")

    with pytest.raises(EasySNMPConnectionError):
        res = s.get('sysDescr.0')

    d = dict(**sess_v3)
    d["privacy_password"] = "wrong_pass"
    s = Session(**d)
    with pytest.raises(EasySNMPConnectionError):
        res = s.get("sysDescr.0")

    s.update_session(privacy_password="priv_pass")
    res = s.get('sysDescr.0')

    assert res.oid == "sysDescr"
    assert res.oid_index == "0"
    assert res.snmp_type == "OCTETSTR"