def test_read_yml(): from io import StringIO from ldap2pg.config import Configuration, ConfigurationError config = Configuration() fo = StringIO("- role: alice") payload = config.read(fo, 'memory', mode=0o0) assert 'sync_map' in payload fo = StringIO("entry: value") payload = config.read(fo, 'memory', mode=0o644) assert 'entry' in payload assert payload['world_readable'] is True # Accept empty file (e.g. /dev/null) fo = StringIO("") payload = config.read(fo, 'memory', mode=0o600) assert payload['world_readable'] is False with pytest.raises(ConfigurationError): fo = StringIO("bad_value") payload = config.read(fo, 'memory', mode=0o600) with pytest.raises(ConfigurationError): fo = StringIO("bad: { yaml ] *&") payload = config.read(fo, 'memory', mode=0o600)
def test_read_yml(): from io import StringIO from ldap2pg.config import Configuration, ConfigurationError config = Configuration() fo = StringIO("- role: alice") payload = config.read(fo, 'memory', mode=0o0) assert 'sync_map' in payload fo = StringIO("sync_map: []") payload = config.read(fo, 'memory', mode=0o644) assert 'sync_map' in payload assert payload['world_readable'] is True # Refuse empty file (e.g. /dev/null) with pytest.raises(ConfigurationError): fo = StringIO("") config.read(fo, 'memory', mode=0o600) with pytest.raises(ConfigurationError): fo = StringIO("bad_value") payload = config.read(fo, 'memory', mode=0o600) with pytest.raises(ConfigurationError): fo = StringIO("bad: { yaml ] *&") payload = config.read(fo, 'memory', mode=0o600) # No sync_map. with pytest.raises(ConfigurationError): fo = StringIO("postgres: {}") payload = config.read(fo, 'memory', mode=0o600)
def test_read_yml(): from io import StringIO from ldap2pg.config import Configuration, ConfigurationError config = Configuration() # Deny list file fo = StringIO("- listentry") with pytest.raises(ConfigurationError): config.read(fo, mode=0o0) fo = StringIO("entry: value") payload = config.read(fo, mode=0o644) assert 'entry' in payload assert payload['world_readable'] is True # Accept empty file (e.g. /dev/null) fo = StringIO("") payload = config.read(fo, mode=0o600) assert payload['world_readable'] is False