def test_deliver_apply_and_get_confs(): """Remote conf delivery, apply and get it back """ d = dict((h, [ip_addr]) for ip_addr, h in addrmap.iteritems()) # confs = {hostname: {iface: [rules, ] }, ... } confs = dict( (h, ['# this is an iptables conf test', '# for %s' % h, '-A INPUT -s 3.3.3.3/32 -j ACCEPT', ] ) for h in d ) # deliver log.debug("Delivery...") sx = SSHConnector(d) status = sx.deliver_confs(confs) assert status == {'InternalFW': 'ok', 'Server001': 'ok', 'BorderFW': 'ok', 'localhost': 'ok', 'Smeagol': 'ok'}, repr(status) # apply log.debug("Applying...") sx.apply_remote_confs() # get and compare log.debug("Getting confs...") rconfs = sx.get_confs() for h, conf in confs.iteritems(): assert h in rconfs, "%s missing from received confs" % h r = rconfs[h] assert 'iptables' in r assert 'ip_a_s' in r assert 'nat' in r['iptables'] assert 'filter' in r['iptables'] # assert r['iptables']['nat'] == [], repr(r) #FIXME: re-enable this #assert r['iptables']['filter'] == ['-A INPUT -s 3.3.3.3/32 -j ACCEPT'], "Rconf: %s" % repr(r) assert 'lo' in r['ip_a_s']
def test_deliver_confs(): d = dict((h, [ip_addr]) for ip_addr, h in addrmap.iteritems()) sx = SSHConnector(d) confs = dict((h, []) for h in d) status = sx.deliver_confs(confs) assert status == {'InternalFW': 'ok', 'Server001': 'ok', 'BorderFW': 'ok', 'localhost': 'ok', 'Smeagol': 'ok'}, repr(status)