Пример #1
0
def test_server_role():
    config = samba.SambaConfigs(context_wrap(TESTPARM))

    assert config.get('global', 'server schannel') == 'Yes'
    assert config.get('homes', 'browseable') == 'No'
    assert config.get('global', 'afs username map') == ''
    assert config.server_role == "ROLE_STANDALONE"
Пример #2
0
def test_match():
    for config in [
            samba.SambaConfig(context_wrap(SAMBA_CONFIG)),  # noqa: E101
            samba.SambaConfigs(
                context_wrap("Server role: ROLE_STANDALONE\n\n" +
                             SAMBA_CONFIG)),
            samba.SambaConfigsAll(
                context_wrap("Server role: ROLE_STANDALONE\n\n" +
                             SAMBA_CONFIG)),
    ]:
        assert config.get('global', 'this option should be in global') == 'yes'
        assert config.get('global',
                          'this option should also be in global') == 'true'
        assert config.get(
            'global', 'this another option should also be in global') == '1'
        assert config.get('global', 'workgroup') == 'MYGROUP'
        assert config.get('global', 'workgroup') == 'MYGROUP'
        assert config.get('global',
                          'server string') == 'Samba Server Version %v'
        assert not config.has_option('global', 'netbios name')
        assert config.get('global', 'log file') == '/var/log/samba/log.%m'
        assert config.get('global', 'max log size') == '50'

        assert config.get('global', 'security') == 'user'
        assert config.get('global', 'passdb backend') == 'tdbsam'

        assert config.get('global', 'load printers') == 'yes'
        assert config.get('global', 'cups options') == 'raw'

        assert not config.has_option('global', 'printcap name')

        assert config.get('homes', 'comment') == 'Home Directories'
        assert config.get('homes', 'browseable') == 'no'
        assert config.get('homes', 'writable') == 'yes'
        assert not config.has_option('homes', 'valid users')

        assert config.get('printers', 'comment') == 'All Printers'
        assert config.get('printers', 'path') == '/var/spool/samba'
        assert config.get('printers', 'browseable') == 'no'
        assert config.get('printers', 'guest ok') == 'no'
        assert config.get('printers', 'writable') == 'no'
        assert config.get('printers', 'printable') == 'yes'

        assert 'netlogin' not in config
        assert 'Profiles' not in config
        assert 'public' not in config
Пример #3
0
def test_server_role_missing():
    with pytest.raises(ParseException) as e:
        samba.SambaConfigs(context_wrap(SAMBA_CONFIG))
        assert e.value == "Server role not found."