def test_hash_of_nonexistent_default_config_is_None():
    path = '/etc/vsftpd/vsftpd.conf'
    f = MockFile(path, to_raise=make_IOError(errno.ENOENT))

    h = get_default_config_hash(read_func=f.read_file)

    assert h is None
    assert not f.error
def migrate_configs(facts, fileops=FileOperations()):
    if facts.default_config_hash is not None:
        new_hash = get_default_config_hash(read_func=fileops.read)
        # If the default config file was unmodified, it got replaced during the RPM upgrade,
        # so we have to change it back.
        if facts.default_config_hash != new_hash:
            _restore_default_config_file(fileops=fileops)
    for config in facts.configs:
        _migrate_config(config, fileops=fileops)
Esempio n. 3
0
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_hash_of_default_config_is_correct():
    path = '/etc/vsftpd/vsftpd.conf'
    content = 'foo\n'
    f = MockFile(path, content=content)

    h = get_default_config_hash(read_func=f.read_file)

    assert h == 'f1d2d2f924e986ac86fdf7b36c94bcdf32beec15'
    assert not f.error