def test_create_L4_L7_ACL(self, *args): set_module_args(dict( name='foo', acl_order=0, type='static', path_match_case=True, description='my description', 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='******' ) )) 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=False) mm.create_on_device = Mock(return_value=True) results = mm.exec_module() assert results['changed'] is True assert results['acl_order'] == 0 assert results['description'] == 'my description' assert results['type'] == 'static' 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_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' )]