<commit_before>import osgtest.library.core as core
import osgtest.library.osgunittest as osgunittest
import pprint
import errno

class TestGridProxyInit(osgunittest.OSGTestCase):

    def test_00_list_proxies(self):
        command = ('ls', '-lF', '/tmp/x509up_u*')
        status, stdout, _ = core.system(command, 'List proxies')
        core.log_message(stdout)

    def test_01_grid_proxy_init(self):
        core.state['proxy.created'] = False
        core.skip_ok_unless_installed('globus-proxy-utils')
        command = ('grid-proxy-init', '-debug')
        password = core.options.password + <PASSWORD>'
        try:
            core.check_system(command, 'Run grid-proxy-init', user=True,
                              stdin=password)
        except OSError, e:
            attributes = {}
            for x in dir(e):
                attributes[x] = getattr(e,x, None)
            core.log_message(pprint.pformat(attributes))
            raise
        core.state['proxy.created'] = True

    def test_02_grid_proxy_info(self):
        core.skip_ok_unless_installed('globus-proxy-utils')
        self.skip_bad_unless(core.state['proxy.created'], 'missing proxy')
        command = ('grid-proxy-info', '-debug')
        core.check_system(command, 'Run grid-proxy-info', user=True)<commit_msg>Extend the grid-proxy-init tests to destroy a pre-existing proxy first, then test for failure without a password.  Tidied up a bit.<commit_after>import osgtest.library.core as core
import osgtest.library.osgunittest as osgunittest

class TestGridProxyInit(osgunittest.OSGTestCase):

    def test_01_remove_proxy(self):
        core.skip_ok_unless_installed('globus-proxy-utils')
        # If there is no pre-existing proxy file, the following command will
        # produce error output and have exit status 1; because this is the
        # expected (but not the only valid) case, do not check the output or
        # exit status.  This test exists only to clear out a pre-existing proxy.
        command = ('grid-proxy-destroy', '-debug')
        core.system(command, user=True)

    def test_02_grid_proxy_init_no_password(self):
        core.skip_ok_unless_installed('globus-proxy-utils')
        command = ('grid-proxy-init', '-debug')
        exit_status, _, _ = core.system(command, user=True)
        if exit_status == 0:
            core.system(('grid-proxy-destroy',), user=True)
            self.fail('grid-proxy-init succeeded with no password')

    def test_03_grid_proxy_init(self):
        core.state['proxy.created'] = False
        core.skip_ok_unless_installed('globus-proxy-utils')
        command = ('grid-proxy-init', '-debug')
        password = <PASSWORD> + <PASSWORD>'
        core.check_system(command, 'Normal grid-proxy-init', user=True, stdin=password)
        core.state['proxy.created'] = True

    def test_04_grid_proxy_info(self):
        core.skip_ok_unless_installed('globus-proxy-utils')
        self.skip_bad_unless(core.state['proxy.created'], 'Proxy creation failed')
        command = ('grid-proxy-info', '-debug')
        core.check_system(command, 'Normal grid-proxy-info', user=True)
{'fraction_non_alphanumeric': 0.11648, 'fraction_numerical': 0.00608, 'mean_word_length': 2.997442455242967, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, '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': '7462300', 'n_tokens_mistral': 962, 'n_tokens_neox': 922, 'n_words': 207}