def testSetMgmt181(self): mgmt = MockCpeManagementServer() mgmt181 = management_server.ManagementServer181(mgmt) self.assertEqual(mgmt.CWMPRetryIntervalMultiplier, 1) self.assertEqual(mgmt181.CWMPRetryIntervalMultiplier, 1) mgmt181.CWMPRetryIntervalMultiplier = 2 self.assertEqual(mgmt.CWMPRetryIntervalMultiplier, 2) self.assertEqual(mgmt181.CWMPRetryIntervalMultiplier, 2) mgmt181.ValidateExports()
def testGetMgmt181(self): mgmt = MakeCpeManagementServer() mgmt181 = management_server.ManagementServer181(mgmt) self.assertEqual(mgmt181.ParameterKey, mgmt.ParameterKey) self.assertEqual(mgmt181.EnableCWMP, mgmt.EnableCWMP) self.assertTrue(mgmt181.UpgradesManaged) self.assertFalse(mgmt181.STUNEnable) self.assertEqual(mgmt181.ManageableDeviceNumberOfEntries, 0) tr.handle.ValidateExports(mgmt181)
def testSetMgmt181(self): mgmt = MakeCpeManagementServer() mgmt181 = management_server.ManagementServer181(mgmt) self.assertEqual(mgmt.CWMPRetryIntervalMultiplier, 1) self.assertEqual(mgmt181.CWMPRetryIntervalMultiplier, 1) mgmt181.CWMPRetryIntervalMultiplier = 2 self.assertEqual(mgmt.CWMPRetryIntervalMultiplier, 2) self.assertEqual(mgmt181.CWMPRetryIntervalMultiplier, 2) self.assertRaises(AttributeError, setattr, mgmt181, 'ManageableDeviceNumberOfEntries', 1)
def testAcsUrl(self): class FakeAcsConfig(object): def __init__(self): self.url = None def SetAcsUrl(self, value): print 'SetAcsUrl(%r)' % value self.url = value return self.url def GetAcsUrl(self): return self.url dmroot = tr.core.Exporter() unused_dh4 = dnsmasq.DHCPv4(dmroot=dmroot) self.dh4p.Enable = True dmroot.Device = tr.core.Exporter() _mgmt = tr.cpe_management_server.CpeManagementServer( acs_config=FakeAcsConfig(), port=12345, ping_path='http://localhost') mgmt = management_server.ManagementServer181(_mgmt) dmroot.Device.ManagementServer = mgmt self.loop.RunOnce() self.assertEqual( dnsmasq._ReadFileActiveLines(dnsmasq.DNSMASQCONFIG[0]), []) mgmt.URL = 'http://localhost' # no idle cycle yet, so config not rewritten self.assertEqual( dnsmasq._ReadFileActiveLines(dnsmasq.DNSMASQCONFIG[0]), []) self.loop.RunOnce() # now it should be updated. cfg = dnsmasq._ReadFileActiveLines(dnsmasq.DNSMASQCONFIG[0]) self.assertNotEqual(cfg, []) cfg = '|'.join(cfg) self.assertTrue('option6:1,"http://localhost"' in cfg) self.assertTrue('11,"http://localhost"' in cfg) mgmt.URL = 'http://localh"ost\\2' self.loop.RunOnce() cfg = dnsmasq._ReadFileActiveLines(dnsmasq.DNSMASQCONFIG[0]) self.assertNotEqual(cfg, []) cfg = '|'.join(cfg) self.assertTrue('option6:1,"http://localhost2"' in cfg) self.assertTrue('11,"http://localhost2"' in cfg)
def testDelMgmt181(self): mgmt = MockCpeManagementServer() mgmt181 = management_server.ManagementServer181(mgmt) delattr(mgmt181, 'CWMPRetryIntervalMultiplier') self.assertFalse(hasattr(mgmt, 'CWMPRetryIntervalMultiplier'))
def testGetMgmt181(self): mgmt = MockCpeManagementServer() mgmt181 = management_server.ManagementServer181(mgmt) self.assertEqual(mgmt181.ParameterKey, mgmt.ParameterKey) self.assertEqual(mgmt181.EnableCWMP, mgmt.EnableCWMP) self.assertTrue(mgmt181.UpgradesManaged)
def testTransactions181(self): mgmt = MockCpeManagementServer() mgmt181 = management_server.ManagementServer181(mgmt) self.TransactionTester(mgmt181)