<commit_before>import glob
import os
import osgtest.library.core as core
import osgtest.library.osgunittest as osgunittest
import pwd
import re
import shutil
import socket
import time
import unittest

# ==========================================================================
# Note: March 2012 version, add checking prerequisites such as globus-proxy-utils,
# to avoid confusion.

class TestGlexec(osgunittest.OSGTestCase):

    # Constants
    __glexec_client_cert = '/tmp/x509_client_cert'
    __grid_mapfile = core.config['system.mapfile']   # typically '/etc/grid-security/grid-mapfile'

    # attributes to be filled later
    __uid = ''
    __user_proxy_path = ''
    __good_gridmap = False

    # ==========================================================================

    def test_01_check_gridmap(self):
        core.skip_ok_unless_installed('glexec')

        pwd_entry = pwd.getpwnam(core.options.username)
        cert_path = os.path.join(pwd_entry.pw_dir, '.globus', 'usercert.pem')
        user_cert_dn, user_cert_issuer = core.certificate_info(cert_path)

        key_dn = '"'+user_cert_dn+'"'+' '+core.options.username

        command = ('/bin/grep', key_dn, self.__grid_mapfile)
        status, stdout, stderr = core.system(command)
        self.assert_(status==0, 'Grid-mapfile entry for user '+core.options.username+' missing')
        TestGlexec.__good_gridmap = True

    def test_02_define_user_proxy_path(self):
        core.skip_ok_unless_installed('glexec')
        command = ('/usr/bin/id','-u')
        status, stdout, stderr = core.system(command, True)
        TestGlexec.__uid = stdout.rstrip()
        TestGlexec.__user_proxy_path = '/tmp/x509up_u'+self.__uid

    def test_03_create_user_proxy(self):
        core.skip_ok_unless_installed('globus-proxy-utils')<commit_msg>test_03 requires __user_proxy_path to be defined (SOFTWARE-1064)<commit_after>import glob
import os
import osgtest.library.core as core
import osgtest.library.osgunittest as osgunittest
import pwd
import re
import shutil
import socket
import time
import unittest

# ==========================================================================
# Note: March 2012 version, add checking prerequisites such as globus-proxy-utils,
# to avoid confusion.

class TestGlexec(osgunittest.OSGTestCase):

    # Constants
    __glexec_client_cert = '/tmp/x509_client_cert'
    __grid_mapfile = core.config['system.mapfile']   # typically '/etc/grid-security/grid-mapfile'

    # attributes to be filled later
    __uid = ''
    __user_proxy_path = ''
    __good_gridmap = False

    # ==========================================================================

    def test_01_check_gridmap(self):
        core.skip_ok_unless_installed('glexec')
        
        pwd_entry = pwd.getpwnam(core.options.username)
        cert_path = os.path.join(pwd_entry.pw_dir, '.globus', 'usercert.pem')
        user_cert_dn, user_cert_issuer = core.certificate_info(cert_path)

        key_dn = '"'+user_cert_dn+'"'+' '+core.options.username

        command = ('/bin/grep', key_dn, self.__grid_mapfile)
        status, stdout, stderr = core.system(command)
        self.assert_(status==0, 'Grid-mapfile entry for user '+core.options.username+' missing')
        TestGlexec.__good_gridmap = True

    def test_02_define_user_proxy_path(self):
        core.skip_ok_unless_installed('glexec')
        command = ('/usr/bin/id','-u')
        status, stdout, stderr = core.system(command, True)
        TestGlexec.__uid = stdout.rstrip()
        TestGlexec.__user_proxy_path = '/tmp/x509up_u'+self.__uid

    def test_03_create_user_proxy(self):
        core.skip_ok_unless_installed('globus-proxy-utils')
        self.skip_ok_if(self.__user_proxy_path == '' , "User proxy path does not exist.")
{'fraction_non_alphanumeric': 0.17837264776040287, 'fraction_numerical': 0.010601643254704479, 'mean_word_length': 3.9854689564068693, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2467087', 'n_tokens_mistral': 1242, 'n_tokens_neox': 1162, 'n_words': 220}