def test_update_L4_L7_ACL(self, *args): set_module_args(dict( name='lastone', acl_order=0, path_match_case='yes', entries=[ dict(action='allow', dst_port='80', dst_addr='192.168.1.1', src_port='443', src_addr='10.10.10.0', src_mask='255.255.255.128', protocol='tcp', host_name='foobar.com', paths='/shopfront', scheme='https' ) ], provider=dict( server='localhost', password='******', user='******' ) )) current = ApiParameters(params=load_fixture('load_apm_acl.json')) module = AnsibleModule( argument_spec=self.spec.argument_spec, supports_check_mode=self.spec.supports_check_mode, ) # Override methods in the specific type of manager mm = ModuleManager(module=module) mm.exists = Mock(return_value=True) mm.update_on_device = Mock(return_value=True) mm.read_current_from_device = Mock(return_value=current) results = mm.exec_module() assert results['changed'] is True assert results['acl_order'] == 0 assert results['path_match_case'] == 'yes' assert results['entries'] == [ dict(action='allow', dst_port='80', dst_addr='192.168.1.1', src_port='443', src_addr='10.10.10.0', src_mask='255.255.255.128', protocol='tcp', host_name='foobar.com', paths='/shopfront', scheme='https' )]
def test_api_parameters(self): args = load_fixture('load_apm_acl.json') p = ApiParameters(params=args) assert p.name == 'lastone' assert p.acl_order == 2 assert p.type == 'static' assert p.path_match_case == 'false' assert p.description == 'foobar' assert p.entries[0] == dict(action='discard', dstEndPort=0, dstStartPort=0, dstSubnet='0.0.0.0/0', srcEndPort=0, srcStartPort=0, srcSubnet='0.0.0.0/0', protocol=1, scheme='any', log='none')