Skip to content

Commit

Permalink
Fixed broken test case.
Browse files Browse the repository at this point in the history
  • Loading branch information
lextm committed Aug 11, 2024
1 parent 8df333e commit f5510f4
Showing 1 changed file with 37 additions and 37 deletions.
74 changes: 37 additions & 37 deletions tests/hlapi/asyncio/manager/cmdgen/test_lcd_configurator.py
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
from unittest import mock

from pysnmp import hlapi
from pysnmp.hlapi.asyncio.cmdgen import CommandGeneratorLcdConfigurator
from pysnmp.hlapi.asyncio import *
from pysnmp.hlapi.asyncio.lcd import CommandGeneratorLcdConfigurator


@mock.patch('pysnmp.entity.config.addV3User')
@mock.patch('pysnmp.entity.config.delV3User')
@mock.patch("pysnmp.entity.config.addV3User")
@mock.patch("pysnmp.entity.config.delV3User")
def test_usm_auth_cache_cleared(delV3User, addV3User):
"""
Ensure auth cache is cleared when auth data is changed.
"""
snmpEngine = hlapi.SnmpEngine()
transportTarget = hlapi.UdpTransportTarget('198.51.100.1')
snmpEngine = SnmpEngine()
transportTarget = UdpTransportTarget(("198.51.100.1", 161))

authDataValues = {
'userName': 'username',
'authKey': 'authkey1',
'authProtocol': hlapi.usmHMACMD5AuthProtocol,
'privKey': 'privkey1',
'privProtocol': hlapi.usmAesCfb128Protocol,
"userName": "username",
"authKey": "authkey1",
"authProtocol": usmHMACMD5AuthProtocol,
"privKey": "privkey1",
"privProtocol": usmAesCfb128Protocol,
}

lcd = CommandGeneratorLcdConfigurator()
initialAuthData = hlapi.UsmUserData(**authDataValues)
initialAuthData = UsmUserData(**authDataValues)
lcd.configure(snmpEngine, initialAuthData, transportTarget)
addV3User.assert_called_with(
snmpEngine,
initialAuthData.userName,
initialAuthData.authProtocol,
initialAuthData.authKey,
initialAuthData.privProtocol,
initialAuthData.privKey,
securityEngineId=initialAuthData.securityEngineId,
securityName=initialAuthData.securityName,
authKeyType=initialAuthData.authKeyType,
privKeyType=initialAuthData.privKeyType,
snmpEngine,
initialAuthData.userName,
initialAuthData.authProtocol,
initialAuthData.authKey,
initialAuthData.privProtocol,
initialAuthData.privKey,
securityEngineId=initialAuthData.securityEngineId,
securityName=initialAuthData.securityName,
authKeyType=initialAuthData.authKeyType,
privKeyType=initialAuthData.privKeyType,
)

# Ensure we do not add/delete if nothing changes
Expand All @@ -44,18 +44,18 @@ def test_usm_auth_cache_cleared(delV3User, addV3User):
delV3User.assert_not_called()

changeAuthValues = {
'authKey': 'authKey2',
'privProtocol': hlapi.usmDESPrivProtocol,
'authProtocol': hlapi.usmHMACSHAAuthProtocol,
'privKey': 'privKey2',
"authKey": "authKey2",
"privProtocol": usmDESPrivProtocol,
"authProtocol": usmHMACSHAAuthProtocol,
"privKey": "privKey2",
}

for field, value in changeAuthValues.items():
addV3User.reset_mock()
delV3User.reset_mock()

authDataValues[field] = value
authData = hlapi.UsmUserData(**authDataValues)
authData = UsmUserData(**authDataValues)
lcd.configure(snmpEngine, authData, transportTarget)

delV3User.assert_called_with(
Expand All @@ -65,14 +65,14 @@ def test_usm_auth_cache_cleared(delV3User, addV3User):
)

addV3User.assert_called_with(
snmpEngine,
authData.userName,
authData.authProtocol,
authData.authKey,
authData.privProtocol,
authData.privKey,
securityEngineId=authData.securityEngineId,
securityName=authData.securityName,
authKeyType=authData.authKeyType,
privKeyType=authData.privKeyType,
snmpEngine,
authData.userName,
authData.authProtocol,
authData.authKey,
authData.privProtocol,
authData.privKey,
securityEngineId=authData.securityEngineId,
securityName=authData.securityName,
authKeyType=authData.authKeyType,
privKeyType=authData.privKeyType,
)

0 comments on commit f5510f4

Please sign in to comment.