def _do_execute(my): # restablish the site if my.site: Site.set_site(my.site) Environment.set_security(my.security) my.execute()
def __init__(self, login_name, password=None): super(XmlRpcLogin,self).__init__() self.set_app_server("xmlrpc") # If the tag <force_lowercase_login> is set to "true" # in the TACTIC config file, # then force the login string argument to be lowercase. # This tag is false by default. self.login_name = login_name if Config.get_value("security","force_lowercase_login") == "true": self.login_name = self.login_name.lower() self.password = password # clear the main container #Container.clear() Environment.set_env_object( self ) # set up the security object security = Security() Environment.set_security(security) self._do_login()
def __init__(self, ticket, site=None): super(XmlRpcInit,self).__init__() if not site: # if not explicitly set, keep the current site site = Site.get_site() self.set_app_server("xmlrpc") self.ticket = ticket # clear the main container #Container.clear() Environment.set_env_object( self ) # set up the security object security = Security() Environment.set_security(security) if site: Site.set_site(site) self._do_login()
def __init__(self, project_code=None, login_code=None, site=None): self.set_app_server("batch") if not site: # if not explicitly set, keep the current site site = Site.get_site() plugin_dir = Environment.get_plugin_dir() if plugin_dir not in sys.path: sys.path.insert(0, plugin_dir) super(Batch,self).__init__() self.login_code = login_code # clear the main container Container.create() if site: Site.set_site(site) # set this as the environment if not project_code: self.context = self.get_default_context() else: self.context = project_code Environment.set_env_object( self ) # set up the security object security = Security() Environment.set_security(security) self._do_login() site_dir = Environment.get_site_dir() if site_dir not in sys.path: sys.path.insert(0, site_dir) # set the project from pyasm.biz import Project if self.context == "batch": Project.set_project("admin") else: Project.set_project(self.context) self.initialize_python_path() # start workflow engine #from pyasm.command import Workflow #Workflow().init() DbContainer.commit_thread_sql()
def _test_guest_allow(self): '''test Config tag allow_guest in security tag. Note: Since it is hard to emulate AppServer class, this is based on logic which handles in _get_display of BaseAppServer. 1. If allow_guest is false, then it is necessary that Sudo is instantiated. 2. If allow_guest is true, then it is necessary that guest login rules are added and login_as_guest is executed. ''' security = Security() Environment.set_security(security) #1. allow_guest is false fail = False try: sudo = Sudo() except Exception as e: fail = True self.assertEquals( False, fail ) sudo.exit() key = [{'code': "*"}] project_access = security.check_access("project", key, "allow") self.assertEquals(project_access, False) #2. allow_guest is true Site.set_site("default") try: security.login_as_guest() ticket_key = security.get_ticket_key() access_manager = security.get_access_manager() xml = Xml() xml.read_string(''' <rules> <rule column="login" value="{$LOGIN}" search_type="sthpw/login" access="deny" op="!=" group="search_filter"/> <rule group="project" code="default" access="allow"/> </rules> ''') access_manager.add_xml_rules(xml) finally: Site.pop_site() default_key = [{'code': "default"}] project_access = security.check_access("project", default_key, "allow") self.assertEquals(project_access, True) unittest_key = [{'code', "sample3d"}] project_access = security.check_access("project", unittest_key, "allow") self.assertEquals(project_access, False)
def _test_guest_allow(self): '''test Config tag allow_guest in security tag. Note: Since it is hard to emulate AppServer class, this is based on logic which handles in _get_display of BaseAppServer. 1. If allow_guest is false, then it is necessary that Sudo is instantiated. 2. If allow_guest is true, then it is necessary that guest login rules are added and login_as_guest is executed. ''' security = Security() Environment.set_security(security) #1. allow_guest is false fail = False try: sudo = Sudo() except Exception as e: fail = True self.assertEquals(False, fail) sudo.exit() key = [{'code': "*"}] project_access = security.check_access("project", key, "allow") self.assertEquals(project_access, False) #2. allow_guest is true Site.set_site("default") try: security.login_as_guest() ticket_key = security.get_ticket_key() access_manager = security.get_access_manager() xml = Xml() xml.read_string(''' <rules> <rule column="login" value="{$LOGIN}" search_type="sthpw/login" access="deny" op="!=" group="search_filter"/> <rule group="project" code="default" access="allow"/> </rules> ''') access_manager.add_xml_rules(xml) finally: Site.pop_site() default_key = [{'code': "default"}] project_access = security.check_access("project", default_key, "allow") self.assertEquals(project_access, True) unittest_key = [{'code', "sample3d"}] project_access = security.check_access("project", unittest_key, "allow") self.assertEquals(project_access, False)
def _do_execute(my): # reestablish the site if my.site: try: Site.set_site(my.site) except: return try: Environment.set_security(my.security) my.execute() finally: if my.site: Site.pop_site()
def __init__(self, ticket=None): super(TacticInit,self).__init__() self.ticket = ticket # create the main container Container.create() Environment.set_env_object( self ) # set up the security object security = Security() Environment.set_security(security)
def __init__(my, ticket): super(XmlRpcInit,my).__init__() my.set_app_server("xmlrpc") my.ticket = ticket # clear the main container #Container.clear() Environment.set_env_object( my ) # set up the security object security = Security() Environment.set_security(security) my._do_login()
def __init__(my, ticket): super(XmlRpcInit, my).__init__() my.set_app_server("xmlrpc") my.ticket = ticket # clear the main container #Container.clear() Environment.set_env_object(my) # set up the security object security = Security() Environment.set_security(security) my._do_login()
def __init__(my, project_code=None, login_code=None, site=None): my.set_app_server("batch") plugin_dir = Environment.get_plugin_dir() if plugin_dir not in sys.path: sys.path.insert(0, plugin_dir) super(Batch,my).__init__() my.login_code = login_code # clear the main container Container.create() if site: Site.set_site(site) # set this as the environment if not project_code: my.context = my.get_default_context() else: my.context = project_code Environment.set_env_object( my ) # set up the security object security = Security() Environment.set_security(security) my._do_login() site_dir = Environment.get_site_dir() if site_dir not in sys.path: sys.path.insert(0, site_dir) # set the project from pyasm.biz import Project if my.context == "batch": Project.set_project("admin") else: Project.set_project(my.context) my.initialize_python_path() DbContainer.commit_thread_sql()
def __init__(my, project_code=None, login_code=None, site=None): my.set_app_server("batch") plugin_dir = Environment.get_plugin_dir() if plugin_dir not in sys.path: sys.path.insert(0, plugin_dir) super(Batch, my).__init__() my.login_code = login_code # clear the main container Container.create() if site: Site.set_site(site) # set this as the environment if not project_code: my.context = my.get_default_context() else: my.context = project_code Environment.set_env_object(my) # set up the security object security = Security() Environment.set_security(security) my._do_login() site_dir = Environment.get_site_dir() if site_dir not in sys.path: sys.path.insert(0, site_dir) # set the project from pyasm.biz import Project if my.context == "batch": Project.set_project("admin") else: Project.set_project(my.context) my.initialize_python_path() DbContainer.commit_thread_sql()
def _do_execute(my): Environment.set_security(my.security) my.execute()
def upgrade(): print "Running upgrade on 'sthpw' database" install_dir = Environment.get_install_dir() python = Config.get_value("services", "python") if not python: python = "python" cmd = "%s \"%s/src/bin/upgrade_db.py\" -f -y -p sthpw" % (python, install_dir) print cmd os.system(cmd) if __name__ == '__main__': Environment.set_security(FakeSecurity()) import_bootstrap() #import_schema("sthpw_schema") #import_schema("config_schema") # upgrade the database using the upgrade script upgrade()
xml.read_file(manifest_path) # create a new project installer = PluginInstaller(base_dir=base_dir, manifest=xml.to_string()) installer.execute() def upgrade(): print "Running upgrade on 'sthpw' database" install_dir = Environment.get_install_dir() python = Config.get_value("services", "python") if not python: python = "python" cmd = "%s %s/src/bin/upgrade_db.py -f -y -p sthpw" % (python, install_dir) print cmd os.system(cmd) if __name__ == '__main__': Environment.set_security(FakeSecurity()) import_bootstrap() #import_schema("sthpw_schema") #import_schema("config_schema") # upgrade the database using the upgrade script upgrade()