Beispiel #1
0
    def test_issue_2420(self):
        # manipulate the core.re to enable host access control
        corefile = get_irods_config_dir() + "/core.re"
        backupcorefile = corefile + "--" + self._testMethodName
        shutil.copy(corefile, backupcorefile)
        os.system(
            '''sed -e '/^acAclPolicy {msiAclPolicy("STRICT"); }/iacAclPolicy {ON($userNameClient == "quickshare") { } }' /etc/irods/core.re > /tmp/irods/core.re''')
        time.sleep(1)  # remove once file hash fix is commited #2279
        os.system("cp /tmp/irods/core.re /etc/irods/core.re")
        time.sleep(1)  # remove once file hash fix is commited #2279

        # restart the server to reread the new core.re
        os.system(get_irods_top_level_dir() + "/iRODS/irodsctl stop")
        os.system(get_irods_top_level_dir() + "/iRODS/irodsctl start")

        assertiCmd(s.adminsession, "ils", "LIST", "tempZone")

        # look for the error "unable to read session variable $userNameClient."
        p = subprocess.Popen(
            ['grep "unable to read session variable $userNameClient."  ../../iRODS/server/log/rodsLog.*'], shell=True, stdout=subprocess.PIPE)
        result = p.communicate()[0]

        # restore the original core.re
        shutil.copy(backupcorefile, corefile)
        os.remove(backupcorefile)

        # check the results for the error
        assert(-1 == result.find("userNameClient"))
Beispiel #2
0
    def test_server_config_environment_variables(self):
        # set log level to get all the things
        os.environ['spLogLevel'] = '11'

        # set a random environment value to find in the log
        svr_cfg_file = get_irods_config_dir() + "/server_config.json"
        os.system("cp %s %sOrig" % (svr_cfg_file, svr_cfg_file))

        with open(svr_cfg_file) as f:
            svr_cfg = json.load(f)
        the_value = 'THIS_IS_THE_VALUE'
        svr_cfg['environment_variables']['foo_bar'] = the_value
        mod_json_file(svr_cfg_file, svr_cfg)

        # bounce the server to get the new env variable
        os.system(get_irods_top_level_dir() + "/iRODS/irodsctl stop")
        os.system(get_irods_top_level_dir() + "/iRODS/irodsctl start")

        assertiCmd(s.adminsession, "ils", "LIST", "tempZone")

        # look for the error "unable to read session variable $userNameClient."
        p = subprocess.Popen(
            ['grep "' + the_value + '"  ../../iRODS/server/log/rodsLog.*'], shell=True, stdout=subprocess.PIPE)
        result = p.communicate()[0]

        del os.environ['spLogLevel']
        os.system("mv %sOrig %s" % (svr_cfg_file, svr_cfg_file))

        os.system(get_irods_top_level_dir() + "/iRODS/irodsctl stop")
        os.system(get_irods_top_level_dir() + "/iRODS/irodsctl start")

        # check the results for the error
        assert(-1 != result.find(the_value))
Beispiel #3
0
class Test_ixmsg(unittest.TestCase):
    serverConfigFile = get_irods_config_dir() + "/server.config"
    xmsgHost = 'localhost'
    xmsgPort = '1279'

    def setUp(self):
        # Set up admin session
        s.admin_up()

        # add Xmsg settings to server.config
        os.system("cp %s %s_orig" %
                  (self.serverConfigFile, self.serverConfigFile))
        os.system('echo "xmsgHost %s" >> %s' %
                  (self.xmsgHost, self.serverConfigFile))
        os.system('echo "xmsgPort %s" >> %s' %
                  (self.xmsgPort, self.serverConfigFile))

        # apparently needed by the server too...
        my_env = os.environ.copy()
        my_env['xmsgHost'] = self.xmsgHost
        my_env['xmsgPort'] = self.xmsgPort

        # restart server with Xmsg
        args = [get_irods_top_level_dir() + '/iRODS/irodsctl', 'restart']
        subprocess.Popen(args, env=my_env).communicate()

    def tearDown(self):
        # revert to original server.config
        os.system("mv -f %s_orig %s" %
                  (self.serverConfigFile, self.serverConfigFile))

        # restart server
        my_env = os.environ.copy()
        args = [get_irods_top_level_dir() + '/iRODS/irodsctl', 'restart']
        subprocess.Popen(args, env=my_env).communicate()

        # Close admin session
        s.admin_down()

    def test_send_and_receive_one_xmsg(self):
        message = 'Hello World!'

        # set up Xmsg in client environment
        my_env = os.environ.copy()
        my_env['xmsgHost'] = self.xmsgHost
        my_env['xmsgPort'] = self.xmsgPort

        # send msg
        args = ['/usr/bin/ixmsg', 's', '-M "{0}"'.format(message)]
        subprocess.Popen(args, env=my_env).communicate(
        )  # couldn't get ixmsg to work non-interactively in assertiCmd()...

        # receive msg
        args = ['/usr/bin/ixmsg', 'r', '-n 1']
        res = subprocess.Popen(args, env=my_env,
                               stdout=subprocess.PIPE).communicate()

        # assertion
        print 'looking for "{0}" in "{1}"'.format(message, res[0].rstrip())
        assert (res[0].find(message) >= 0)
Beispiel #4
0
    def test_host_access_control(self):
        my_ip = socket.gethostbyname(socket.gethostname())

        # manipulate the core.re to enable host access control
        corefile = get_irods_config_dir() + "/core.re"
        backupcorefile = corefile + "--" + self._testMethodName
        shutil.copy(corefile, backupcorefile)
        os.system(
            '''sed -e '/^acChkHostAccessControl { }/i acChkHostAccessControl { msiCheckHostAccessControl; }' /etc/irods/core.re > /tmp/irods/core.re''')
        time.sleep(1)  # remove once file hash fix is commited #2279
        os.system("cp /tmp/irods/core.re /etc/irods/core.re")
        time.sleep(1)  # remove once file hash fix is commited #2279

        # restart the server to reread the new core.re
        os.system(get_irods_top_level_dir() + "/iRODS/irodsctl stop")
        os.system(get_irods_top_level_dir() + "/iRODS/irodsctl start")

        host_access_control = ''
        if os.path.isfile('/etc/irods/host_access_control.json'):
            host_access_control = '/etc/irods/host_access_control.json'
        else:
            install_dir = os.path.dirname(
                os.path.dirname(
                    os.path.realpath(__file__)))
            host_access_control = install_dir + '/iRODS/server/config/host_access_control.json'

        orig_file = host_access_control + '.orig'
        os.system('cp %s %s' % (host_access_control, orig_file))

        write_host_access_control(host_access_control, 'nope', 'nope', '', '')

        assertiCmdFail(s.adminsession, "ils", "ERROR", "SYS_AGENT_INIT_ERR")

        write_host_access_control(host_access_control, 'all', 'all', my_ip, '255.255.255.255')

        assertiCmd(s.adminsession, "ils", "LIST", "tempZone")

        # restore the original host_access_control.json
        os.system('mv %s %s' % (orig_file, host_access_control))

        # restore the original core.re
        shutil.copy(backupcorefile, corefile)
        os.remove(backupcorefile)
Beispiel #5
0
    def test_authentication_OSAuth(self):
        # add auth test user
        authTestUser = "******"
        authTestPass = "******"
        assertiCmd(s.adminsession, "iadmin mkuser %s rodsuser" % authTestUser)

        # add client irodsEnv settings
        clientEnvFile = s.adminsession.sessionDir + "/.irodsEnv"
        os.system("cp %s %sOrig" % (clientEnvFile, clientEnvFile))
        os.system("echo \"irodsAuthScheme 'OSAuth'\" >> %s" % clientEnvFile)
        os.system("echo \"irodsUserName '%s'\" >> %s" %
                  (authTestUser, clientEnvFile))
        os.system("echo \"irodsHome '/tempZone/home/%s'\" >> %s" %
                  (authTestUser, clientEnvFile))
        os.system("echo \"irodsCwd '/tempZone/home/%s'\" >> %s" %
                  (authTestUser, clientEnvFile))

        # setup the irods.key file necessary for OSAuth
        keyfile = get_irods_config_dir() + "/irods.key"
        os.system("echo \"gibberish\" > %s" % keyfile)

        # do the reauth
        assertiCmd(s.adminsession, "iexit full")  # exit out entirely
        assertiCmd(s.adminsession, "iinit %s" % authTestPass)  # reinitialize
        # connect and list some files
        assertiCmd(s.adminsession, "icd")  # home directory
        assertiCmd(s.adminsession, "ils -L", "LIST",
                   "home")  # should be listed

        # reset client environment to original
        os.system("mv %sOrig %s" % (clientEnvFile, clientEnvFile))
        # reconnect as admin
        assertiCmd(s.adminsession, "iexit full")  # exit out entirely
        assertiCmd(s.adminsession,
                   "iinit %s" % s.users[0]['passwd'])  # reinitialize

        # remove auth test user
        assertiCmd(s.adminsession, "iadmin rmuser %s" % authTestUser)

        # clean up keyfile
        os.system("rm %s" % keyfile)
Beispiel #6
0
    def test_authentication_OSAuth(self):
        # add auth test user
        authTestUser = "******"
        authTestPass = "******"
        assertiCmd(s.adminsession,"iadmin mkuser %s rodsuser" % authTestUser)

        # add client irodsEnv settings
        clientEnvFile = s.adminsession.sessionDir+"/irods_environment.json"
        os.system("cp %s %sOrig" % (clientEnvFile, clientEnvFile))

        env = {}
        env['irods_authentication_scheme'] = "OSAuth"
        env['irods_user_name'] = authTestUser
        env['irods_home'] = '/tempZone/home/'+authTestUser 
        env['irods_cwd'] = '/tempZone/home/'+authTestUser 
        mod_json_file(clientEnvFile,env);

        # setup the irods.key file necessary for OSAuth
        keyfile = get_irods_config_dir() + "/irods.key"
        os.system("echo \"gibberish\" > %s" % keyfile)

        # do the reauth
        assertiCmd(s.adminsession,"iexit full" )             # exit out entirely
        assertiCmd(s.adminsession,"iinit %s" % authTestPass) # reinitialize
        # connect and list some files
        assertiCmd(s.adminsession,"icd") # home directory
        assertiCmd(s.adminsession,"ils -L","LIST","home") # should be listed

        # reset client environment to original
        os.system("mv %sOrig %s" % (clientEnvFile, clientEnvFile))
        # reconnect as admin
        assertiCmd(s.adminsession,"iexit full" )                     # exit out entirely
        assertiCmd(s.adminsession,"iinit %s" % s.users[0]['passwd']) # reinitialize

        # remove auth test user
        assertiCmd(s.adminsession,"iadmin rmuser %s" % authTestUser)

        # clean up keyfile
        os.system("rm %s" % keyfile)
Beispiel #7
0
    def test_authentication_OSAuth(self):
        # add auth test user
        authTestUser = "******"
        authTestPass = "******"
        assertiCmd(s.adminsession, "iadmin mkuser %s rodsuser" % authTestUser)

        # add client irodsEnv settings
        clientEnvFile = s.adminsession._session_dir + "/irods_environment.json"
        os.system("cp %s %sOrig" % (clientEnvFile, clientEnvFile))

        env = {}
        env['irods_authentication_scheme'] = "OSAuth"
        env['irods_user_name'] = authTestUser
        env['irods_home'] = '/tempZone/home/' + authTestUser
        env['irods_cwd'] = '/tempZone/home/' + authTestUser
        update_json_file_from_dict(clientEnvFile, env)

        # setup the irods.key file necessary for OSAuth
        keyfile = get_irods_config_dir() + "/irods.key"
        os.system("echo \"gibberish\" > %s" % keyfile)

        # do the reauth
        assertiCmd(s.adminsession, "iexit full")             # exit out entirely
        assertiCmd(s.adminsession, "iinit %s" % authTestPass)  # reinitialize
        # connect and list some files
        assertiCmd(s.adminsession, "icd")  # home directory
        assertiCmd(s.adminsession, "ils -L", "LIST", "home")  # should be listed

        # reset client environment to original
        os.system("mv %sOrig %s" % (clientEnvFile, clientEnvFile))
        # reconnect as admin
        assertiCmd(s.adminsession, "iexit full")                     # exit out entirely
        assertiCmd(s.adminsession, 'iinit %s' % s.adminsession._password)  # reinitialize

        # remove auth test user
        assertiCmd(s.adminsession, "iadmin rmuser %s" % authTestUser)

        # clean up keyfile
        os.system("rm %s" % keyfile)
Beispiel #8
0
    def test_authentication_PAM_with_server_params(self):
        # add auth test user
        authTestUser = "******"
        authTestPass = "******"
        assertiCmd(s.adminsession,"iadmin mkuser %s rodsuser" % authTestUser)

        # set up client and server side for ssl handshake

        # server side certificate setup
        os.system("openssl genrsa -out server.key")
        # os.system("openssl req -batch -new -key server.key -out server.csr")    # if use external CA
        os.system("openssl req -batch -new -x509 -key server.key -out server.crt -days 365")    # self-signed certificate
        os.system("mv server.crt chain.pem")
        os.system("openssl dhparam -2 -out dhparams.pem 100") # normally 2048, but smaller size here for speed

        # server side environment variables
        os.environ['irodsSSLCertificateChainFile'] = get_irods_top_level_dir() + "/tests/pydevtest/chain.pem"
        os.environ['irodsSSLCertificateKeyFile'] = get_irods_top_level_dir() + "/tests/pydevtest/server.key"
        os.environ['irodsSSLDHParamsFile'] = get_irods_top_level_dir() + "/tests/pydevtest/dhparams.pem"

        # client side environment variables
        os.environ['irodsSSLVerifyServer'] = "none"

        # add client irodsEnv settings
        clientEnvFile = s.adminsession.sessionDir+"/irods_environment.json"
        os.system("cp %s %sOrig" % (clientEnvFile, clientEnvFile))

        env = {}
        env['irods_client_server_policy'] = 'CS_NEG_REQUIRE'
        env['irods_authentication_scheme'] = "PaM"
        env['irods_user_name'] = authTestUser
        env['irods_home'] = '/tempZone/home/'+authTestUser 
        env['irods_cwd'] = '/tempZone/home/'+authTestUser 
        mod_json_file(clientEnvFile,env);

        # add server_config.json settings
        serverConfigFile = get_irods_config_dir() + "/server_config.json"
        with open(serverConfigFile) as f:
            contents = json.load(f)
        os.system("cp %s %sOrig" % (serverConfigFile, serverConfigFile))
        contents['pam_password_length'] = 20;
        contents['pam_no_extend'] = False;
        contents['pam_password_min_time'] = 121;
        contents['pam_password_max_time'] = 1209600;
        with open(serverConfigFile, 'w') as f:
            json.dump(contents, f)

        # server reboot to pick up new irodsEnv and server settings
        os.system(get_irods_top_level_dir() + "/iRODS/irodsctl restart")

        # do the reauth
        assertiCmd(s.adminsession,"iinit %s" % authTestPass) # reinitialize
        # connect and list some files
        assertiCmd(s.adminsession,"icd") # home directory
        assertiCmd(s.adminsession,"ils -L","LIST","home") # should be listed

        # reset client environment to original
        os.system("mv %sOrig %s" % (clientEnvFile, clientEnvFile))
        # reconnect as admin
        assertiCmd(s.adminsession,"iinit %s" % s.users[0]['passwd']) # reinitialize

        # remove auth test user
        assertiCmd(s.adminsession,"iadmin rmuser %s" % authTestUser)

        # clean up
        os.system("rm server.key chain.pem dhparams.pem")

        # reset server_config.json to original
        os.system("mv %sOrig %s" % (serverConfigFile, serverConfigFile))
        
        # server reboot to revert to previous server configuration
        os.system(get_irods_top_level_dir() + "/iRODS/irodsctl stop")
        os.system(get_irods_top_level_dir() + "/tests/zombiereaper.sh")
        os.system(get_irods_top_level_dir() + "/iRODS/irodsctl start")
Beispiel #9
0
    def test_authentication_PAM_with_server_params(self):
        # add auth test user
        authTestUser = "******"
        authTestPass = "******"
        assertiCmd(s.adminsession, "iadmin mkuser %s rodsuser" % authTestUser)

        # set up client and server side for ssl handshake

        # server side certificate setup
        os.system("openssl genrsa -out server.key")
        # os.system("openssl req -batch -new -key server.key -out server.csr")    # if use external CA
        os.system(
            "openssl req -batch -new -x509 -key server.key -out server.crt -days 365"
        )  # self-signed certificate
        os.system("mv server.crt chain.pem")
        os.system("openssl dhparam -2 -out dhparams.pem 100"
                  )  # normally 2048, but smaller size here for speed

        # server side environment variables
        os.environ['irodsSSLCertificateChainFile'] = get_irods_top_level_dir(
        ) + "/tests/pydevtest/chain.pem"
        os.environ['irodsSSLCertificateKeyFile'] = get_irods_top_level_dir(
        ) + "/tests/pydevtest/server.key"
        os.environ['irodsSSLDHParamsFile'] = get_irods_top_level_dir(
        ) + "/tests/pydevtest/dhparams.pem"

        # client side environment variables
        os.environ['irodsSSLVerifyServer'] = "none"

        # add client irodsEnv settings
        clientEnvFile = s.adminsession.sessionDir + "/.irodsEnv"
        os.system("cp %s %sOrig" % (clientEnvFile, clientEnvFile))
        os.system("echo \"irodsClientServerPolicy 'CS_NEG_REQUIRE'\" >> %s" %
                  clientEnvFile)
        os.system("echo \"irodsAuthScheme 'PaM'\" >> %s" %
                  clientEnvFile)  # check for auth to_lower
        os.system("echo \"irodsUserName '%s'\" >> %s" %
                  (authTestUser, clientEnvFile))
        os.system("echo \"irodsHome '/tempZone/home/%s'\" >> %s" %
                  (authTestUser, clientEnvFile))
        os.system("echo \"irodsCwd '/tempZone/home/%s'\" >> %s" %
                  (authTestUser, clientEnvFile))

        # add server.config settings
        serverConfigFile = get_irods_config_dir() + "/server.config"
        os.system("cp %s %sOrig" % (serverConfigFile, serverConfigFile))
        os.system("echo \"pam_password_length 20\" >> %s" % serverConfigFile)
        os.system("echo \"pam_no_extend false\" >> %s" % serverConfigFile)
        os.system("echo \"pam_password_min_time 121\" >> %s" %
                  serverConfigFile)
        os.system("echo \"pam_password_max_time 1209600\" >> %s" %
                  serverConfigFile)

        # server reboot to pick up new irodsEnv and server settings
        os.system(get_irods_top_level_dir() + "/iRODS/irodsctl restart")

        # do the reauth
        assertiCmd(s.adminsession, "iinit %s" % authTestPass)  # reinitialize
        # connect and list some files
        assertiCmd(s.adminsession, "icd")  # home directory
        assertiCmd(s.adminsession, "ils -L", "LIST",
                   "home")  # should be listed

        # reset client environment to original
        os.system("mv %sOrig %s" % (clientEnvFile, clientEnvFile))
        # reconnect as admin
        assertiCmd(s.adminsession,
                   "iinit %s" % s.users[0]['passwd'])  # reinitialize

        # remove auth test user
        assertiCmd(s.adminsession, "iadmin rmuser %s" % authTestUser)

        # clean up
        os.system("rm server.key chain.pem dhparams.pem")

        # reset server.config to original
        os.system("mv %sOrig %s" % (serverConfigFile, serverConfigFile))

        # server reboot to revert to previous server configuration
        os.system(get_irods_top_level_dir() + "/iRODS/irodsctl stop")
        os.system(get_irods_top_level_dir() + "/tests/zombiereaper.sh")
        os.system(get_irods_top_level_dir() + "/iRODS/irodsctl start")
Beispiel #10
0
class Test_AllRules(unittest.TestCase, ResourceBase):

    __metaclass__ = metaclass_unittest_test_case_generator.MetaclassUnittestTestCaseGenerator

    global rules30dir
    currentdir = os.path.dirname(os.path.realpath(__file__))
    rules30dir = currentdir + "/../../iRODS/clients/icommands/test/rules3.0/"
    conf_dir = get_irods_config_dir()

    my_test_resource = {
        "setup": [],
        "teardown": [],
    }

    def setUp(self):
        ResourceBase.__init__(self)
        s.twousers_up()
        self.run_resource_setup()

        # testallrules setup
        global rules30dir
        hostname = socket.gethostname()
        hostuser = getpass.getuser()
        progname = __file__
        dir_w = rules30dir + ".."
        s.adminsession.runCmd(
            'icd'
        )  # to get into the home directory (for testallrules assumption)
        s.adminsession.runAdminCmd('iadmin',
                                   ["mkuser", "devtestuser", "rodsuser"])
        s.adminsession.runAdminCmd('iadmin', [
            "mkresc", "testallrulesResc", "unix file system",
            hostname + ":/tmp/" + hostuser + "/pydevtest_testallrulesResc"
        ])
        s.adminsession.runCmd('imkdir', ["sub1"])
        s.adminsession.runCmd('imkdir', ["sub3"])
        s.adminsession.runCmd('imkdir', ["forphymv"])
        s.adminsession.runCmd('imkdir', ["ruletest"])
        s.adminsession.runCmd('imkdir', ["test"])
        s.adminsession.runCmd('imkdir', ["test/phypathreg"])
        s.adminsession.runCmd('imkdir', ["ruletest/subforrmcoll"])
        s.adminsession.runCmd('iput', [progname, "test/foo1"])
        s.adminsession.runCmd('icp', ["test/foo1", "sub1/dcmetadatatarget"])
        s.adminsession.runCmd('icp', ["test/foo1", "sub1/mdcopysource"])
        s.adminsession.runCmd('icp', ["test/foo1", "sub1/mdcopydest"])
        s.adminsession.runCmd('icp', ["test/foo1", "sub1/foo1"])
        s.adminsession.runCmd('icp', ["test/foo1", "sub1/foo2"])
        s.adminsession.runCmd('icp', ["test/foo1", "sub1/foo3"])
        s.adminsession.runCmd('icp', ["test/foo1", "forphymv/phymvfile"])
        s.adminsession.runCmd('icp', ["test/foo1", "sub1/objunlink1"])
        s.adminsession.runCmd('irm',
                              ["sub1/objunlink1"])  # put it in the trash
        s.adminsession.runCmd('icp', ["test/foo1", "sub1/objunlink2"])
        s.adminsession.runCmd('irepl',
                              ["-R", "testallrulesResc", "sub1/objunlink2"])
        s.adminsession.runCmd('icp', ["test/foo1", "sub1/freebuffer"])
        s.adminsession.runCmd('icp', ["test/foo1", "sub1/automove"])
        s.adminsession.runCmd('icp', ["test/foo1", "test/versiontest.txt"])
        s.adminsession.runCmd('icp', ["test/foo1", "test/metadata-target.txt"])
        s.adminsession.runCmd('icp', ["test/foo1", "test/ERAtestfile.txt"])
        s.adminsession.runCmd('ichmod',
                              ["read devtestuser", "test/ERAtestfile.txt"])
        s.adminsession.runCmd(
            'imeta',
            ["add", "-d", "test/ERAtestfile.txt", "Fun", "99", "Balloons"])
        s.adminsession.runCmd('icp', ["test/foo1", "sub1/for_versioning.txt"])
        s.adminsession.runCmd('imkdir', ["sub1/SaveVersions"])
        s.adminsession.runCmd(
            'iput', [dir_w + "/misc/devtestuser-account-ACL.txt", "test"])
        s.adminsession.runCmd('iput',
                              [dir_w + "/misc/load-metadata.txt", "test"])
        s.adminsession.runCmd('iput',
                              [dir_w + "/misc/load-usermods.txt", "test"])
        s.adminsession.runCmd('iput', [dir_w + "/misc/sample.email", "test"])
        s.adminsession.runCmd('iput', [dir_w + "/misc/email.tag", "test"])
        s.adminsession.runCmd(
            'iput', [dir_w + "/misc/sample.email", "test/sample2.email"])
        s.adminsession.runCmd('iput',
                              [dir_w + "/misc/email.tag", "test/email2.tag"])

        # setup for rulemsiAdmChangeCoreRE and the likes
        empty_core_file_name = 'empty.test.re'
        new_core_file_name = 'new.test.re'
        open(self.conf_dir + "/" + empty_core_file_name,
             'w').close()  # create empty file
        shutil.copy(self.conf_dir + "/core.re",
                    self.conf_dir + "/core.re.bckp")  # back up core.re
        shutil.copy(self.conf_dir + "/core.re",
                    self.conf_dir + "/" + new_core_file_name)  # copy core.re

    def tearDown(self):
        # testallrules teardown
        s.adminsession.runCmd('icd')  # for home directory assumption
        s.adminsession.runCmd('ichmod', ["-r", "own", "rods", "."])
        s.adminsession.runCmd('imcoll', [
            "-U",
            "/" + s.adminsession.get_zone_name() + "/home/rods/test/phypathreg"
        ])
        s.adminsession.runCmd('irm', [
            "-rf", "test", "ruletest", "forphymv", "sub1", "sub2", "sub3",
            "bagit", "rules", "bagit.tar",
            "/" + s.adminsession.get_zone_name() + "/bundle/home/rods"
        ])
        s.adminsession.runAdminCmd('iadmin', ["rmresc", "testallrulesResc"])
        s.adminsession.runAdminCmd('iadmin', ["rmuser", "devtestuser"])
        s.adminsession.runCmd('iqdel', ["-a"])  # remove all/any queued rules

        # cleanup mods in iRODS config dir
        os.system('mv -f %s/core.re.bckp %s/core.re' %
                  (self.conf_dir, self.conf_dir))
        os.system('rm -f %s/*.test.re' % self.conf_dir)

        self.run_resource_teardown()
        s.twousers_down()

    def generate_tests_allrules():
        global rules30dir

        def filter_rulefiles(rulefile):

            # skip rules that handle .irb files
            names_to_skip = [
                "rulemsiAdmAppendToTopOfCoreIRB",
                "rulemsiAdmChangeCoreIRB",
                "rulemsiGetRulesFromDBIntoStruct",
            ]
            for n in names_to_skip:
                if n in rulefile:
                    # print "skipping " + rulefile + " ----- RE"
                    return False

            # skip rules that fail by design
            names_to_skip = ["GoodFailure"]
            for n in names_to_skip:
                if n in rulefile:
                    # print "skipping " + rulefile + " ----- failbydesign"
                    return False

            for n in names_to_skip:
                if n in rulefile:
                    # print "skipping " + rulefile + " ----- failbydesign"
                    return False

            # skip if an action (run in the core.re), not enough input/output for irule
            names_to_skip = [
                "rulemsiAclPolicy",
                "rulemsiAddUserToGroup",
                "rulemsiCheckHostAccessControl",
                "rulemsiCheckOwner",
                "rulemsiCheckPermission",
                "rulemsiCommit",
                "rulemsiCreateCollByAdmin",
                "rulemsiCreateUser",
                "rulemsiDeleteCollByAdmin",
                "rulemsiDeleteDisallowed",
                "rulemsiDeleteUser",
                "rulemsiExtractNaraMetadata",
                "rulemsiOprDisallowed",
                "rulemsiRegisterData",
                "rulemsiRenameCollection",
                "rulemsiRenameLocalZone",
                "rulemsiRollback",
                "rulemsiSetBulkPutPostProcPolicy",
                "rulemsiSetDataObjAvoidResc",
                "rulemsiSetDataObjPreferredResc",
                "rulemsiSetDataTypeFromExt",
                "rulemsiSetDefaultResc",
                "rulemsiSetGraftPathScheme",
                "rulemsiSetMultiReplPerResc",
                "rulemsiSetNoDirectRescInp",
                "rulemsiSetNumThreads",
                "rulemsiSetPublicUserOpr",
                "rulemsiSetRandomScheme",
                "rulemsiSetRescQuotaPolicy",
                "rulemsiSetRescSortScheme",
                "rulemsiSetReServerNumProc",
                "rulemsiSetResource",
                "rulemsiSortDataObj",
                "rulemsiStageDataObj",
                "rulemsiSysChksumDataObj",
                "rulemsiSysMetaModify",
                "rulemsiSysReplDataObj",
                "rulemsiNoChkFilePathPerm",
                "rulemsiNoTrashCan",
            ]
            for n in names_to_skip:
                if n in rulefile:
                    # print "skipping " + rulefile + " ----- input/output"
                    return False

            # skip rules we are not yet supporting
            names_to_skip = [
                "rulemsiobj",
            ]
            for n in names_to_skip:
                if n in rulefile:
                    # print "skipping " + rulefile + " ----- msiobj"
                    return False

            # ERA
            names_to_skip = [
                "rulemsiFlagInfectedObjs",
                "rulemsiGetAuditTrailInfoByActionID",
                "rulemsiGetAuditTrailInfoByKeywords",
                "rulemsiGetAuditTrailInfoByObjectID",
                "rulemsiGetAuditTrailInfoByTimeStamp",
                "rulemsiGetAuditTrailInfoByUserID",
                "rulemsiMergeDataCopies",
                "rulemsiGetCollectionPSmeta-null"  # marked for removal - iquest now handles this natively
            ]
            for n in names_to_skip:
                if n in rulefile:
                    # print "skipping " + rulefile + " ----- ERA"
                    return False

            # XMSG
            names_to_skip = [
                "rulemsiCreateXmsgInp",
                "rulemsiRcvXmsg",
                "rulemsiSendXmsg",
                "rulemsiXmsgCreateStream",
                "rulemsiXmsgServerConnect",
                "rulemsiXmsgServerDisConnect",
                "rulereadXMsg",
                "rulewriteXMsg",
            ]
            for n in names_to_skip:
                if n in rulefile:
                    # print "skipping " + rulefile + " ----- XMSG"
                    return False

            # FTP
            names_to_skip = [
                "rulemsiFtpGet",
                "rulemsiTwitterPost",
            ]
            for n in names_to_skip:
                if n in rulefile:
                    # print "skipping " + rulefile + " ----- FTP"
                    return False

            # webservices
            names_to_skip = [
                "rulemsiConvertCurrency",
                "rulemsiGetQuote",
                "rulemsiIp2location",
                "rulemsiObjByName",
                "rulemsiSdssImgCutout_GetJpeg",
            ]
            for n in names_to_skip:
                if n in rulefile:
                    # print "skipping " + rulefile + " ----- webservices"
                    return False

            # XML
            names_to_skip = [
                "rulemsiLoadMetadataFromXml",
                "rulemsiXmlDocSchemaValidate",
                "rulemsiXsltApply",
            ]
            for n in names_to_skip:
                if n in rulefile:
                    # print "skipping " + rulefile + " ----- XML"
                    return False

            # transition to core microservices only
            names_to_skip = [
                "rulemsiAddKeyVal.r",
                "rulemsiApplyDCMetadataTemplate.r",
                "rulemsiAssociateKeyValuePairsToObj.r",
                "rulemsiCollectionSpider.r",
                "rulemsiCopyAVUMetadata.r",
                "rulemsiExportRecursiveCollMeta.r",
                "rulemsiFlagDataObjwithAVU.r",
                "rulemsiGetCollectionACL.r",
                "rulemsiGetCollectionContentsReport.r",
                "rulemsiGetCollectionPSmeta.r",
                "rulemsiGetCollectionSize.r",
                "rulemsiGetDataObjACL.r",
                "rulemsiGetDataObjAIP.r",
                "rulemsiGetDataObjAVUs.r",
                "rulemsiGetDataObjPSmeta.r",
                "rulemsiGetObjectPath.r",
                "rulemsiGetUserACL.r",
                "rulemsiGetUserInfo.r",
                "rulemsiGuessDataType.r",
                "rulemsiIsColl.r",
                "rulemsiIsData.r",
                "rulemsiLoadACLFromDataObj.r",
                "rulemsiLoadMetadataFromDataObj.r",
                "rulemsiLoadUserModsFromDataObj.r",
                "rulemsiPropertiesAdd.r",
                "rulemsiPropertiesClear.r",
                "rulemsiPropertiesClone.r",
                "rulemsiPropertiesExists.r",
                "rulemsiPropertiesFromString.r",
                "rulemsiPropertiesGet.r",
                "rulemsiPropertiesNew.r",
                "rulemsiPropertiesRemove.r",
                "rulemsiPropertiesSet.r",
                "rulemsiRecursiveCollCopy.r",
                "rulemsiRemoveKeyValuePairsFromObj.r",
                "rulemsiSetDataType.r",
                "rulemsiString2KeyValPair.r",
                "rulemsiStripAVUs.r",
                "rulemsiStructFileBundle.r",
                "rulewriteKeyValPairs.r",
            ]
            for n in names_to_skip:
                if n in rulefile:
                    # print "skipping " + rulefile + " ----- transition to core"
                    return False

            # skipping rules requiring additional .re files in community code
            names_to_skip = [
                "rulemsiAdmAddAppRuleStruct.r",
                "rulemsiAdmClearAppRuleStruct.r",
                "rulemsiAdmInsertRulesFromStructIntoDB.r",
                "rulemsiAdmReadRulesFromFileIntoStruct.r",
                "rulemsiAdmRetrieveRulesFromDBIntoStruct.r",
                "rulemsiAdmWriteRulesFromStructIntoFile.r",
            ]
            for n in names_to_skip:
                if n in rulefile:
                    # print "skipping " + rulefile + " ----- community"
                    return False

            # skipping for now, not sure why it's throwing a stacktrace at the moment
            if "rulemsiPropertiesToString" in rulefile:
                # print "skipping " + rulefile + " ----- b/c of stacktrace"
                return False

            # misc / other
            if "ruleintegrity" in rulefile:
                # print "skipping " + rulefile + " ----- integrityChecks"
                return False
            if "z3950" in rulefile:
                # print "skipping " + rulefile + " ----- z3950"
                return False
            if "rulemsiImage" in rulefile:
                # print "skipping " + rulefile + " ----- image"
                return False
            if "rulemsiRda" in rulefile:
                # print "skipping " + rulefile + " ----- RDA"
                return False
            if "rulemsiCollRepl" in rulefile:
                # print "skipping " + rulefile + " ----- deprecated"
                return False
            if "rulemsiTarFileExtract" in rulefile:
                # print "skipping " + rulefile + " ----- CAT_NO_ROWS_FOUND - failed in
                # call to getDataObjInfoIncSpecColl"
                return False
            if "rulemsiDataObjRsync" in rulefile:
                # print "skipping " + rulefile + " ----- tested separately"
                return False

            return True

        for rulefile in filter(filter_rulefiles,
                               sorted(os.listdir(rules30dir))):

            def make_test(rulefile):
                def test(self):
                    global rules30dir
                    assertiCmd(s.adminsession, "icd")
                    assertiCmd(s.adminsession,
                               "irule -vF " + rules30dir + rulefile, "STDOUT",
                               "completed successfully")

                return test

            yield 'test_' + rulefile.replace('.', '_'), make_test(rulefile)

    def test_rulemsiDataObjRsync(self):
        rulefile = 'rulemsiDataObjRsync.r'
        src_filename = 'source.txt'
        dest_filename = 'dest.txt'
        test_dir = '/tmp'
        test_coll = '/tempZone/home/rods/synctest'
        src_file = os.path.join(test_dir, src_filename)
        src_obj = test_coll + '/' + src_filename
        dest_obj = test_coll + '/' + dest_filename

        # create test collection
        s.adminsession.runCmd('imkdir', [test_coll])

        # create source test file
        f = open(src_file, 'a')
        f.write('blah\n')
        f.close()

        # upload source test file
        s.adminsession.runCmd('iput', [src_file, test_coll])

        # first rsync rule test
        assertiCmd(s.adminsession, "irule -F " + rules30dir + rulefile, "LIST",
                   "status = 99999992")

        # modify the source and try again
        for i in range(1, 5):
            f = open(src_file, 'a')
            f.write('blah_' + str(i) + '\n')
            f.close()

            # force upload source
            s.adminsession.runCmd('iput', ['-f', src_file, test_coll])

            # sync test
            assertiCmd(s.adminsession, "irule -F " + rules30dir + rulefile,
                       "LIST", "status = 99999992")

        # cleanup
        s.adminsession.runCmd('irm', ['-rf', test_coll])
        os.remove(src_file)

    def test_rulemsiPhyBundleColl(self):
        rulefile = 'rulemsiPhyBundleColl.r'

        # rule test
        assertiCmd(
            s.adminsession, "irule -F " + rules30dir + rulefile, "LIST",
            "Create tar file of collection /tempZone/home/rods/test on resource testallrulesResc"
        )

        # look for the bundle
        output = getiCmdOutput(s.adminsession,
                               "ils -L /tempZone/bundle/home/rods")

        # last token in stdout should be the bundle file's full physical path
        bundlefile = output[0].split()[-1]

        # check on the bundle file's name
        assert bundlefile.find('test.') >= 0

        # check physical path on resource
        assert os.path.isfile(bundlefile)

        # now try as a normal user (expect err msg)
        assertiCmd(s.sessions[1], "irule -F " + rules30dir + rulefile, "ERROR",
                   "SYS_NO_API_PRIV")

        # cleanup
        s.adminsession.runCmd('irm', ['-rf', '/tempZone/bundle/home/rods'])
Beispiel #11
0
class Test_ixmsg(unittest.TestCase):
    serverConfigFile = get_irods_config_dir() + "/server_config.json"
    xmsgHost = 'localhost'
    xmsgPort = 1279

    def setUp(self):
        # Set up admin session
        s.admin_up()

        # add Xmsg settings to server_config.json
        with open(self.serverConfigFile) as f:
            contents = json.load(f)
        os.system("cp %s %s_orig" %
                  (self.serverConfigFile, self.serverConfigFile))
        contents["xmsg_host"] = self.xmsgHost
        contents["xmsg_port"] = self.xmsgPort
        with open(self.serverConfigFile, 'w') as f:
            json.dump(contents, f)

        # apparently needed by the server too...
        my_env = os.environ.copy()
        my_env['XMSG_HOST'] = self.xmsgHost
        my_env['XMSG_PORT'] = str(self.xmsgPort)

        # restart server with Xmsg
        args = [get_irods_top_level_dir() + '/iRODS/irodsctl', 'restart']
        subprocess.Popen(args, env=my_env).communicate()

    def tearDown(self):
        # revert to original server_config.json
        os.system("mv -f %s_orig %s" %
                  (self.serverConfigFile, self.serverConfigFile))

        # restart server
        my_env = os.environ.copy()
        args = [get_irods_top_level_dir() + '/iRODS/irodsctl', 'restart']
        subprocess.Popen(args, env=my_env).communicate()

        # Close admin session
        s.admin_down()

    @unittest.skipIf(
        pydevtest_common.irods_test_constants.TOPOLOGY_FROM_RESOURCE_SERVER,
        "Skip for topology testing from resource server")
    def test_send_and_receive_one_xmsg(self):
        message = 'Hello World!'

        # set up Xmsg in client environment
        my_env = os.environ.copy()
        my_env['XMSG_HOST'] = self.xmsgHost
        my_env['XMSG_PORT'] = str(self.xmsgPort)

        # send msg
        args = ['/usr/bin/ixmsg', 's', '-M "{0}"'.format(message)]
        # couldn't get ixmsg to work non-interactively in assertiCmd()...
        subprocess.Popen(args, env=my_env).communicate()

        # receive msg
        args = ['/usr/bin/ixmsg', 'r', '-n 1']
        res = subprocess.Popen(args, env=my_env,
                               stdout=subprocess.PIPE).communicate()

        # assertion
        print 'looking for "{0}" in "{1}"'.format(message, res[0].rstrip())
        assert (res[0].find(message) >= 0)
    def test_authentication_PAM_with_server_params(self):
        # add auth test user
        authTestUser = "******"
        authTestPass = "******"
        assertiCmd(s.adminsession,"iadmin mkuser %s rodsuser" % authTestUser)

        # set up client and server side for ssl handshake

        # server side certificate setup
        os.system("openssl genrsa -out server.key")
        # os.system("openssl req -batch -new -key server.key -out server.csr")    # if use external CA
        os.system("openssl req -batch -new -x509 -key server.key -out server.crt -days 365")    # self-signed certificate
        os.system("mv server.crt chain.pem")
        os.system("openssl dhparam -2 -out dhparams.pem 100") # normally 2048, but smaller size here for speed

        # server side environment variables
        os.environ['irodsSSLCertificateChainFile'] = get_irods_top_level_dir() + "/tests/pydevtest/chain.pem"
        os.environ['irodsSSLCertificateKeyFile'] = get_irods_top_level_dir() + "/tests/pydevtest/server.key"
        os.environ['irodsSSLDHParamsFile'] = get_irods_top_level_dir() + "/tests/pydevtest/dhparams.pem"

        # client side environment variables
        os.environ['irodsSSLVerifyServer'] = "none"

        # add client irodsEnv settings
        clientEnvFile = s.adminsession.sessionDir+"/.irodsEnv"
        os.system("cp %s %sOrig" % (clientEnvFile, clientEnvFile))
        os.system("echo \"irodsClientServerPolicy 'CS_NEG_REQUIRE'\" >> %s" % clientEnvFile)
        os.system("echo \"irodsAuthScheme 'PaM'\" >> %s" % clientEnvFile) # check for auth to_lower
        os.system("echo \"irodsUserName '%s'\" >> %s" % (authTestUser, clientEnvFile))
        os.system("echo \"irodsHome '/tempZone/home/%s'\" >> %s" % (authTestUser, clientEnvFile))
        os.system("echo \"irodsCwd '/tempZone/home/%s'\" >> %s" % (authTestUser, clientEnvFile))
        
        # add server.config settings
        serverConfigFile = get_irods_config_dir() + "/server.config"
        os.system("cp %s %sOrig" % (serverConfigFile, serverConfigFile))
        os.system("echo \"pam_password_length 20\" >> %s" % serverConfigFile)
        os.system("echo \"pam_no_extend false\" >> %s" % serverConfigFile)
        os.system("echo \"pam_password_min_time 121\" >> %s" % serverConfigFile)
        os.system("echo \"pam_password_max_time 1209600\" >> %s" % serverConfigFile)


        # server reboot to pick up new irodsEnv and server settings
        os.system(get_irods_top_level_dir() + "/iRODS/irodsctl restart")

        # do the reauth
        assertiCmd(s.adminsession,"iinit %s" % authTestPass) # reinitialize
        # connect and list some files
        assertiCmd(s.adminsession,"icd") # home directory
        assertiCmd(s.adminsession,"ils -L","LIST","home") # should be listed

        # reset client environment to original
        os.system("mv %sOrig %s" % (clientEnvFile, clientEnvFile))
        # reconnect as admin
        assertiCmd(s.adminsession,"iinit %s" % s.users[0]['passwd']) # reinitialize

        # remove auth test user
        assertiCmd(s.adminsession,"iadmin rmuser %s" % authTestUser)

        # clean up
        os.system("rm server.key chain.pem dhparams.pem")
        
        # reset server.config to original
        os.system("mv %sOrig %s" % (serverConfigFile, serverConfigFile))
        
        # server reboot to revert to previous server configuration
        os.system(get_irods_top_level_dir() + "/iRODS/irodsctl stop")
        os.system(get_irods_top_level_dir() + "/tests/zombiereaper.sh")
        os.system(get_irods_top_level_dir() + "/iRODS/irodsctl start")
Beispiel #13
0
    def test_authentication_PAM_with_server_params(self):
        # add auth test user
        authTestUser = "******"
        authTestPass = "******"
        assertiCmd(s.adminsession, "iadmin mkuser %s rodsuser" % authTestUser)

        # set up client and server side for ssl handshake

        # server side certificate setup
        os.system("openssl genrsa -out server.key")
        # os.system("openssl req -batch -new -key server.key -out server.csr")    # if use external CA
        # self-signed certificate
        os.system("openssl req -batch -new -x509 -key server.key -out server.crt -days 365")
        os.system("mv server.crt chain.pem")
        os.system("openssl dhparam -2 -out dhparams.pem 100")  # normally 2048, but smaller size here for speed

        # server side environment variables
        os.environ['irodsSSLCertificateChainFile'] = get_irods_top_level_dir() + "/tests/pydevtest/chain.pem"
        os.environ['irodsSSLCertificateKeyFile'] = get_irods_top_level_dir() + "/tests/pydevtest/server.key"
        os.environ['irodsSSLDHParamsFile'] = get_irods_top_level_dir() + "/tests/pydevtest/dhparams.pem"

        # client side environment variables
        os.environ['irodsSSLVerifyServer'] = "none"

        # add client irodsEnv settings
        clientEnvFile = s.adminsession._session_dir + "/irods_environment.json"
        os.system("cp %s %sOrig" % (clientEnvFile, clientEnvFile))

        env = {}
        env['irods_client_server_policy'] = 'CS_NEG_REQUIRE'
        env['irods_authentication_scheme'] = "PaM"
        env['irods_user_name'] = authTestUser
        env['irods_home'] = '/tempZone/home/' + authTestUser
        env['irods_cwd'] = '/tempZone/home/' + authTestUser
        update_json_file_from_dict(clientEnvFile, env)

        # add server_config.json settings
        serverConfigFile = get_irods_config_dir() + "/server_config.json"
        with open(serverConfigFile) as f:
            contents = json.load(f)
        os.system("cp %s %sOrig" % (serverConfigFile, serverConfigFile))
        contents['pam_password_length'] = 20
        contents['pam_no_extend'] = False
        contents['pam_password_min_time'] = 121
        contents['pam_password_max_time'] = 1209600
        with open(serverConfigFile, 'w') as f:
            json.dump(contents, f)

        # server reboot to pick up new irodsEnv and server settings
        os.system(get_irods_top_level_dir() + "/iRODS/irodsctl restart")

        # do the reauth
        assertiCmd(s.adminsession, "iinit %s" % authTestPass)  # reinitialize
        # connect and list some files
        assertiCmd(s.adminsession, "icd")  # home directory
        assertiCmd(s.adminsession, "ils -L", "LIST", "home")  # should be listed

        # reset client environment to original
        os.system("mv %sOrig %s" % (clientEnvFile, clientEnvFile))
        # reconnect as admin
        assertiCmd(s.adminsession, "iinit %s" % s.adminsession._password)  # reinitialize

        # remove auth test user
        assertiCmd(s.adminsession, "iadmin rmuser %s" % authTestUser)

        # clean up
        os.system("rm server.key chain.pem dhparams.pem")

        # reset server_config.json to original
        os.system("mv %sOrig %s" % (serverConfigFile, serverConfigFile))

        # server reboot to revert to previous server configuration
        os.system(get_irods_top_level_dir() + "/iRODS/irodsctl stop")
        os.system(get_irods_top_level_dir() + "/tests/zombiereaper.sh")
        os.system(get_irods_top_level_dir() + "/iRODS/irodsctl start")
Beispiel #14
0
class Test_AllRules(ResourceBase):

    global rules30dir
    currentdir = os.path.dirname(
        os.path.abspath(inspect.getfile(inspect.currentframe())))
    rules30dir = currentdir + "/../../iRODS/clients/icommands/test/rules3.0/"
    conf_dir = get_irods_config_dir()

    my_test_resource = {
        "setup": [],
        "teardown": [],
    }

    def setUp(self):
        ResourceBase.__init__(self)
        s.twousers_up()
        self.run_resource_setup()

        # testallrules setup
        global rules30dir
        hostname = socket.gethostname()
        progname = __file__
        dir_w = rules30dir + ".."
        s.adminsession.runCmd(
            'icd'
        )  # to get into the home directory (for testallrules assumption)
        s.adminsession.runAdminCmd('iadmin',
                                   ["mkuser", "devtestuser", "rodsuser"])
        s.adminsession.runAdminCmd('iadmin', [
            "mkresc", "testallrulesResc", "unix file system",
            hostname + ":/tmp/pydevtest_testallrulesResc"
        ])
        s.adminsession.runCmd('imkdir', ["sub1"])
        s.adminsession.runCmd('imkdir', ["sub3"])
        s.adminsession.runCmd('imkdir', ["forphymv"])
        s.adminsession.runCmd('imkdir', ["ruletest"])
        s.adminsession.runCmd('imkdir', ["test"])
        s.adminsession.runCmd('imkdir', ["test/phypathreg"])
        s.adminsession.runCmd('imkdir', ["ruletest/subforrmcoll"])
        s.adminsession.runCmd('iput', [progname, "test/foo1"])
        s.adminsession.runCmd('icp', ["test/foo1", "sub1/dcmetadatatarget"])
        s.adminsession.runCmd('icp', ["test/foo1", "sub1/mdcopysource"])
        s.adminsession.runCmd('icp', ["test/foo1", "sub1/mdcopydest"])
        s.adminsession.runCmd('icp', ["test/foo1", "sub1/foo1"])
        s.adminsession.runCmd('icp', ["test/foo1", "sub1/foo2"])
        s.adminsession.runCmd('icp', ["test/foo1", "sub1/foo3"])
        s.adminsession.runCmd('icp', ["test/foo1", "forphymv/phymvfile"])
        s.adminsession.runCmd('icp', ["test/foo1", "sub1/objunlink1"])
        s.adminsession.runCmd('irm',
                              ["sub1/objunlink1"])  # put it in the trash
        s.adminsession.runCmd('icp', ["test/foo1", "sub1/objunlink2"])
        s.adminsession.runCmd('irepl',
                              ["-R", "testallrulesResc", "sub1/objunlink2"])
        s.adminsession.runCmd('icp', ["test/foo1", "sub1/freebuffer"])
        s.adminsession.runCmd('icp', ["test/foo1", "sub1/automove"])
        s.adminsession.runCmd('icp', ["test/foo1", "test/versiontest.txt"])
        s.adminsession.runCmd('icp', ["test/foo1", "test/metadata-target.txt"])
        s.adminsession.runCmd('icp', ["test/foo1", "test/ERAtestfile.txt"])
        s.adminsession.runCmd('ichmod',
                              ["read devtestuser", "test/ERAtestfile.txt"])
        s.adminsession.runCmd(
            'imeta',
            ["add", "-d", "test/ERAtestfile.txt", "Fun", "99", "Balloons"])
        s.adminsession.runCmd('icp', ["test/foo1", "sub1/for_versioning.txt"])
        s.adminsession.runCmd('imkdir', ["sub1/SaveVersions"])
        s.adminsession.runCmd(
            'iput', [dir_w + "/misc/devtestuser-account-ACL.txt", "test"])
        s.adminsession.runCmd('iput',
                              [dir_w + "/misc/load-metadata.txt", "test"])
        s.adminsession.runCmd('iput',
                              [dir_w + "/misc/load-usermods.txt", "test"])
        s.adminsession.runCmd('iput', [dir_w + "/misc/sample.email", "test"])
        s.adminsession.runCmd('iput', [dir_w + "/misc/email.tag", "test"])
        s.adminsession.runCmd(
            'iput', [dir_w + "/misc/sample.email", "test/sample2.email"])
        s.adminsession.runCmd('iput',
                              [dir_w + "/misc/email.tag", "test/email2.tag"])

        # setup for rulemsiAdmChangeCoreRE and the likes
        empty_core_file_name = 'empty.test.re'
        new_core_file_name = 'new.test.re'
        with open(self.conf_dir + "/" + empty_core_file_name, 'w'):
            pass  # create empty file
        shutil.copy(self.conf_dir + "/core.re",
                    self.conf_dir + "/core.re.bckp")  # back up core.re
        shutil.copy(self.conf_dir + "/core.re",
                    self.conf_dir + "/" + new_core_file_name)  # copy core.re

    def tearDown(self):
        # testallrules teardown
        s.adminsession.runCmd('icd')  # for home directory assumption
        s.adminsession.runCmd('ichmod', ["-r", "own", "rods", "."])
        s.adminsession.runCmd('imcoll', [
            "-U",
            "/" + s.adminsession.getZoneName() + "/home/rods/test/phypathreg"
        ])
        s.adminsession.runCmd('irm', [
            "-rf", "test", "ruletest", "forphymv", "sub1", "sub2", "sub3",
            "bagit", "rules", "bagit.tar",
            "/" + s.adminsession.getZoneName() + "/bundle/home/rods"
        ])
        s.adminsession.runAdminCmd('iadmin', ["rmresc", "testallrulesResc"])
        s.adminsession.runAdminCmd('iadmin', ["rmuser", "devtestuser"])
        s.adminsession.runCmd('iqdel', ["-a"])  # remove all/any queued rules

        # cleanup mods in iRODS config dir
        os.system('mv -f %s/core.re.bckp %s/core.re' %
                  (self.conf_dir, self.conf_dir))
        os.system('rm -f %s/*.test.re' % self.conf_dir)

        self.run_resource_teardown()
        s.twousers_down()

    #def create_testallrules_test(self, rulefile):
    #def do_test_expected(self):
    #self.run_irule(rulefile)
    #return do_test_expected

    def run_irule(self, rulefile):
        global rules30dir
        assertiCmd(s.adminsession, "icd")
        assertiCmd(s.adminsession, "irule -vF " + rules30dir + rulefile,
                   "LIST", "completed successfully")

    def test_allrules(self):

        global rules30dir
        print rules30dir

        for rulefile in sorted(os.listdir(rules30dir)):

            skipme = 0
            # skip rules that handle .irb files
            names_to_skip = [
                "rulemsiAdmAppendToTopOfCoreIRB",
                "rulemsiAdmChangeCoreIRB",
                "rulemsiGetRulesFromDBIntoStruct",
            ]
            for n in names_to_skip:
                if n in rulefile:
                    print "skipping " + rulefile + " ----- RE"
                    skipme = 1

            # skip rules that fail by design
            names_to_skip = [
                "GoodFailure",
                "ruleworkflowcut",
                "ruleworkflowfail",
            ]
            for n in names_to_skip:
                if n in rulefile:
                    print "skipping " + rulefile + " ----- failbydesign"
                    skipme = 1

            # skip rules that are for workflows
            names_to_skip = [
                "ruleTestWSO.r",
                "ruleTestWSO1.r",
                "ruleTestWSO2.r",
            ]
            for n in names_to_skip:
                if n in rulefile:
                    print "skipping " + rulefile + " ----- failbydesign"
                    skipme = 1

            # skip if an action (run in the core.re), not enough input/output for irule
            names_to_skip = [
                "rulemsiAclPolicy",
                "rulemsiAddUserToGroup",
                "rulemsiCheckHostAccessControl",
                "rulemsiCheckOwner",
                "rulemsiCheckPermission",
                "rulemsiCommit",
                "rulemsiCreateCollByAdmin",
                "rulemsiCreateUser",
                "rulemsiDeleteCollByAdmin",
                "rulemsiDeleteDisallowed",
                "rulemsiDeleteUser",
                "rulemsiExtractNaraMetadata",
                "rulemsiOprDisallowed",
                "rulemsiRegisterData",
                "rulemsiRenameCollection",
                "rulemsiRenameLocalZone",
                "rulemsiRollback",
                "rulemsiSetBulkPutPostProcPolicy",
                "rulemsiSetDataObjAvoidResc",
                "rulemsiSetDataObjPreferredResc",
                "rulemsiSetDataTypeFromExt",
                "rulemsiSetDefaultResc",
                "rulemsiSetGraftPathScheme",
                "rulemsiSetMultiReplPerResc",
                "rulemsiSetNoDirectRescInp",
                "rulemsiSetNumThreads",
                "rulemsiSetPublicUserOpr",
                "rulemsiSetRandomScheme",
                "rulemsiSetRescQuotaPolicy",
                "rulemsiSetRescSortScheme",
                "rulemsiSetReServerNumProc",
                "rulemsiSetResource",
                "rulemsiSortDataObj",
                "rulemsiStageDataObj",
                "rulemsiSysChksumDataObj",
                "rulemsiSysMetaModify",
                "rulemsiSysReplDataObj",
                "rulemsiVacuum",
                "rulemsiNoChkFilePathPerm",
                "rulemsiNoTrashCan",
                "rulemsiVacuum",
            ]
            for n in names_to_skip:
                if n in rulefile:
                    print "skipping " + rulefile + " ----- input/output"
                    skipme = 1

            # skip rules we are not yet supporting
            names_to_skip = [
                "rulemsiDbo",
                "rulemsiDbr",
                "rulemsiobj",
            ]
            for n in names_to_skip:
                if n in rulefile:
                    print "skipping " + rulefile + " ----- DBO/DBR/msiobj"
                    skipme = 1

            # ERA
            names_to_skip = [
                "rulemsiFlagInfectedObjs",
                "rulemsiGetAuditTrailInfoByActionID",
                "rulemsiGetAuditTrailInfoByKeywords",
                "rulemsiGetAuditTrailInfoByObjectID",
                "rulemsiGetAuditTrailInfoByTimeStamp",
                "rulemsiGetAuditTrailInfoByUserID",
                "rulemsiMergeDataCopies",
                "rulemsiGetCollectionPSmeta-null"  # marked for removal - iquest now handles this natively
            ]
            for n in names_to_skip:
                if n in rulefile:
                    print "skipping " + rulefile + " ----- ERA"
                    skipme = 1

            # XMSG
            names_to_skip = [
                "rulemsiCreateXmsgInp",
                "rulemsiRcvXmsg",
                "rulemsiSendXmsg",
                "rulemsiXmsgCreateStream",
                "rulemsiXmsgServerConnect",
                "rulemsiXmsgServerDisConnect",
                "rulereadXMsg",
                "rulewriteXMsg",
            ]
            for n in names_to_skip:
                if n in rulefile:
                    print "skipping " + rulefile + " ----- XMSG"
                    skipme = 1

            # FTP
            names_to_skip = [
                "rulemsiFtpGet",
                "rulemsiTwitterPost",
            ]
            for n in names_to_skip:
                if n in rulefile:
                    print "skipping " + rulefile + " ----- FTP"
                    skipme = 1

            # webservices
            names_to_skip = [
                "rulemsiConvertCurrency",
                "rulemsiGetQuote",
                "rulemsiIp2location",
                "rulemsiObjByName",
                "rulemsiSdssImgCutout_GetJpeg",
            ]
            for n in names_to_skip:
                if n in rulefile:
                    print "skipping " + rulefile + " ----- webservices"
                    skipme = 1

            # XML
            names_to_skip = [
                "rulemsiLoadMetadataFromXml",
                "rulemsiXmlDocSchemaValidate",
                "rulemsiXsltApply",
            ]
            for n in names_to_skip:
                if n in rulefile:
                    print "skipping " + rulefile + " ----- XML"
                    skipme = 1

            # transition to core microservices only
            names_to_skip = [
                "rulemsiAddKeyVal.r",
                "rulemsiApplyDCMetadataTemplate.r",
                "rulemsiAssociateKeyValuePairsToObj.r",
                "rulemsiCollectionSpider.r",
                "rulemsiCopyAVUMetadata.r",
                "rulemsiExportRecursiveCollMeta.r",
                "rulemsiFlagDataObjwithAVU.r",
                "rulemsiGetCollectionACL.r",
                "rulemsiGetCollectionContentsReport.r",
                "rulemsiGetCollectionPSmeta.r",
                "rulemsiGetCollectionSize.r",
                "rulemsiGetDataObjACL.r",
                "rulemsiGetDataObjAIP.r",
                "rulemsiGetDataObjAVUs.r",
                "rulemsiGetDataObjPSmeta.r",
                "rulemsiGetObjectPath.r",
                "rulemsiGetUserACL.r",
                "rulemsiGetUserInfo.r",
                "rulemsiGuessDataType.r",
                "rulemsiIsColl.r",
                "rulemsiIsData.r",
                "rulemsiLoadACLFromDataObj.r",
                "rulemsiLoadMetadataFromDataObj.r",
                "rulemsiLoadUserModsFromDataObj.r",
                "rulemsiPropertiesAdd.r",
                "rulemsiPropertiesClear.r",
                "rulemsiPropertiesClone.r",
                "rulemsiPropertiesExists.r",
                "rulemsiPropertiesFromString.r",
                "rulemsiPropertiesGet.r",
                "rulemsiPropertiesNew.r",
                "rulemsiPropertiesRemove.r",
                "rulemsiPropertiesSet.r",
                "rulemsiRecursiveCollCopy.r",
                "rulemsiRemoveKeyValuePairsFromObj.r",
                "rulemsiSetDataType.r",
                "rulemsiString2KeyValPair.r",
                "rulemsiStripAVUs.r",
                "rulemsiStructFileBundle.r",
                "rulewriteKeyValPairs.r",
            ]
            for n in names_to_skip:
                if n in rulefile:
                    print "skipping " + rulefile + " ----- transition to core"
                    skipme = 1

            if skipme == 1: continue

            # skipping rules requiring additional .re files in community code
            names_to_skip = [
                "rulemsiAdmAddAppRuleStruct.r",
                "rulemsiAdmClearAppRuleStruct.r",
                "rulemsiAdmInsertRulesFromStructIntoDB.r",
                "rulemsiAdmReadRulesFromFileIntoStruct.r",
                "rulemsiAdmRetrieveRulesFromDBIntoStruct.r",
                "rulemsiAdmWriteRulesFromStructIntoFile.r",
            ]
            for n in names_to_skip:
                if n in rulefile:
                    print "skipping " + rulefile + " ----- community"
                    skipme = 1

            if skipme == 1: continue

            # skipping for now, not sure why it's throwing a stacktrace at the moment
            if "rulemsiPropertiesToString" in rulefile:
                print "skipping " + rulefile + " ----- b/c of stacktrace"
                continue

            # misc / other
            if "ruleintegrity" in rulefile:
                print "skipping " + rulefile + " ----- integrityChecks"
                continue
            if "z3950" in rulefile:
                print "skipping " + rulefile + " ----- z3950"
                continue
            if "rulemsiImage" in rulefile:
                print "skipping " + rulefile + " ----- image"
                continue
            if "rulemsiRda" in rulefile:
                print "skipping " + rulefile + " ----- RDA"
                continue
            if "rulemsiCollRepl" in rulefile:
                print "skipping " + rulefile + " ----- deprecated"
                continue
            if "rulemsiDataObjGetWithOptions" in rulefile:
                print "skipping " + rulefile + " ----- deprecated"
                continue
            if "rulemsiDataObjReplWithOptions" in rulefile:
                print "skipping " + rulefile + " ----- deprecated"
                continue
            if "rulemsiServerBackup" in rulefile:
                print "skipping " + rulefile + " ----- serverbackup"
                continue
            if "rulemsiExecStrCondQueryWithOptions" in rulefile:
                print "skipping " + rulefile + " ----- SYS_HEADER_READ_LEN_ERR, Operation now in progress"
                continue
            if "rulemsiTarFileExtract" in rulefile:
                print "skipping " + rulefile + " ----- CAT_NO_ROWS_FOUND - failed in call to getDataObjInfoIncSpecColl"
                continue
            if "rulemsiDataObjRsync" in rulefile:
                print "skipping " + rulefile + " ----- -130000 SYS_INVALID_INPUT_PARAM - no resource found for name [testResc]"
                continue

            # actually run the test - yield means create a separate test for each rulefile
            print "-- running " + rulefile
            yield self.run_irule, rulefile