def test_actor_with_supported_tcpwrap_and_vsftpd_config(current_actor_context): config1 = VsftpdConfig(path='/etc/vsftpd/foo.conf', tcp_wrappers=False) config2 = VsftpdConfig(path='/etc/vsftpd/bar.conf', tcp_wrappers=False) vsftpd_facts = VsftpdFacts(configs=[config1, config2]) daemon_list = DaemonList(value=['all', 'except', 'vsftpd']) tcpwrap_facts = TcpWrappersFacts(daemon_lists=[daemon_list]) current_actor_context.feed(vsftpd_facts) current_actor_context.feed(tcpwrap_facts) current_actor_context.run() assert not current_actor_context.consume(Report)
def test_actor_with_unsupported_tcpwrap_and_vsftpd_config(current_actor_context): config1 = VsftpdConfig(path='/etc/vsftpd/foo.conf', tcp_wrappers=False) config2 = VsftpdConfig(path='/etc/vsftpd/bar.conf', tcp_wrappers=True) vsftpd_facts = VsftpdFacts(configs=[config1, config2]) daemon_list = DaemonList(value=['vsftpd']) tcpwrap_facts = TcpWrappersFacts(daemon_lists=[daemon_list]) current_actor_context.feed(vsftpd_facts) current_actor_context.feed(tcpwrap_facts) current_actor_context.run() report = current_actor_context.consume(Report)[0] assert 'inhibitor' in report.flags assert 'foo.conf' not in report.detail['summary'] assert 'bar.conf' in report.detail['summary']
def test_restoring_default_config(): content = 'anonymous_enable=NO\n' \ 'tcp_wrappers=NO\n' \ 'strict_ssl_read_eof=NO\n' fileops = MockFileOperations() fileops.files[VSFTPD_DEFAULT_CONFIG_PATH] = content config = VsftpdConfig(path=VSFTPD_DEFAULT_CONFIG_PATH, tcp_wrappers=False, strict_ssl_read_eof=False) facts = VsftpdFacts(default_config_hash='foobar', configs=[config]) migrate_configs(facts, fileops=fileops) assert len(fileops.files_read) == 1 assert VSFTPD_DEFAULT_CONFIG_PATH in fileops.files_read assert len(fileops.files_written) == 1 assert VSFTPD_DEFAULT_CONFIG_PATH in fileops.files_written expected_lines = ['# Commented out by Leapp:', '#anonymous_enable=NO', 'tcp_wrappers=NO', 'strict_ssl_read_eof=NO', '', '# Added by Leapp:', 'anonymous_enable=YES', ''] assert fileops.files[VSFTPD_DEFAULT_CONFIG_PATH] == '\n'.join(expected_lines)
def get_vsftpd_facts(read_func=utils.read_file, listdir=os.listdir): config_hash = utils.get_default_config_hash(read_func=read_func) configs = _get_parsed_configs(read_func=read_func, listdir=listdir) res_configs = [] for path, config in configs: res_configs.append(VsftpdConfig(path=path, strict_ssl_read_eof=config.get(utils.STRICT_SSL_READ_EOF), tcp_wrappers=config.get(utils.TCP_WRAPPERS))) return VsftpdFacts(default_config_hash=config_hash, configs=res_configs)
def test_setting_strict_ssl_read_eof(): path = '/etc/vsftpd/bar.conf' content = 'local_enable=YES\n' fileops = MockFileOperations() fileops.files[path] = content config = VsftpdConfig(path=path, tcp_wrappers=None, strict_ssl_read_eof=None) facts = VsftpdFacts(configs=[config]) migrate_configs(facts, fileops=fileops) assert path in fileops.files_read assert len(fileops.files_written) == 1 assert path in fileops.files_written expected_lines = [ 'local_enable=YES', '', '# Added by Leapp:', 'strict_ssl_read_eof=NO', '' ] assert fileops.files[path] == '\n'.join(expected_lines)
def test_setting_tcp_wrappers(): path = '/etc/vsftpd/foo.conf' content = 'tcp_wrappers=YES\n' \ 'strict_ssl_read_eof=NO\n' fileops = MockFileOperations() fileops.files[path] = content config = VsftpdConfig(path=path, tcp_wrappers=True, strict_ssl_read_eof=False) facts = VsftpdFacts(configs=[config]) migrate_configs(facts, fileops=fileops) assert path in fileops.files_read assert len(fileops.files_written) == 1 assert path in fileops.files_written expected_lines = [ '# Commented out by Leapp:', '#tcp_wrappers=YES', 'strict_ssl_read_eof=NO', '', '# Added by Leapp:', 'tcp_wrappers=NO', '' ] assert fileops.files[path] == '\n'.join(expected_lines)