def _createGroup(self, group, ugRoot): """ Create group. Create also the basic group role and assign it to the group. Secure the corresponding workspace for this group. If the group already exists, make sure that the group role does exist and is properly assigned. But don't touch the workspace security settings.""" # Search for the group if sys.hexversion >= 0x02070000: # Python 2.7 or more groupElem = ugRoot.find("./{http://www.geoserver.org/security/users}groups/{http://www.geoserver.org/security/users}group[@name='"+group+"']") else: # Python 2.6 or less groupElem = self._xPath26Find(ugRoot, "./{http://www.geoserver.org/security/users}groups/{http://www.geoserver.org/security/users}group", "name", group) brandNew = False if groupElem is None: # Create the group groupElem = Xml.Element("{http://www.geoserver.org/security/users}group", {"enabled":"true", "name":group}) groupsElem = ugRoot.find("./{http://www.geoserver.org/security/users}groups") groupsElem.append(groupElem) brandNew = True # Create and assign the group role role = self.createGroupRole(group) # If the group was newly created, secure the corresponding workspace if brandNew: from layman.layed.gssec import GsSec gss = GsSec(self.config) gss.secureWorkspace(ws=group, rolelist=[role])
class GsSecTestCase(unittest.TestCase): gss = None gsdir = None def setUp(self): cfg = ConfigParser.SafeConfigParser() cfg.read((os.path.join(TEST_DIR, "tests.cfg"))) self.gss = GsSec(cfg) self.gsdir = self.gss.config.get("GeoServer", "gsdir") def test_gsSec(self): self.gss.setRule("zednici", "mury", "w", ["MAJSTR", "PRIDAVAC"]) self.gss.setRule("zednici", "*", "w", ["MAJSTR"]) self.gss.secureWorkspace("drotari", ["ROLE_DROTAR", "ROLE_POWER"]) self.gss.writeLayerProp()
class GsSecTestCase(unittest.TestCase): gss = None gsdir = None def setUp(self): cfg = ConfigParser.SafeConfigParser() cfg.read((os.path.join(TEST_DIR,"tests.cfg"))) self.gss = GsSec(cfg) self.gsdir = self.gss.config.get("GeoServer", "gsdir") def test_gsSec(self): self.gss.setRule("zednici", "mury", "w", ["MAJSTR", "PRIDAVAC"]) self.gss.setRule("zednici", "*", "w", ["MAJSTR"]) self.gss.secureWorkspace("drotari", ["ROLE_DROTAR","ROLE_POWER"]) self.gss.writeLayerProp()
def setUp(self): cfg = ConfigParser.SafeConfigParser() cfg.read((os.path.join(TEST_DIR, "tests.cfg"))) self.gss = GsSec(cfg) self.gsdir = self.gss.config.get("GeoServer", "gsdir")
def setUp(self): cfg = ConfigParser.SafeConfigParser() cfg.read((os.path.join(TEST_DIR,"tests.cfg"))) self.gss = GsSec(cfg) self.gsdir = self.gss.config.get("GeoServer", "gsdir")