当前位置: 首页>>代码示例>>Python>>正文


Python Proxy.renewMyProxy方法代码示例

本文整理汇总了Python中WMCore.Credential.Proxy.Proxy.renewMyProxy方法的典型用法代码示例。如果您正苦于以下问题:Python Proxy.renewMyProxy方法的具体用法?Python Proxy.renewMyProxy怎么用?Python Proxy.renewMyProxy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WMCore.Credential.Proxy.Proxy的用法示例。


在下文中一共展示了Proxy.renewMyProxy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: MyProxyTest

# 需要导入模块: from WMCore.Credential.Proxy import Proxy [as 别名]
# 或者: from WMCore.Credential.Proxy.Proxy import renewMyProxy [as 别名]
class MyProxyTest(unittest.TestCase):

    def setUp(self):
        """
        Setup for unit tests
        """
        logging.basicConfig(level=logging.DEBUG,
                            format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
                            datefmt='%m-%d %H:%M',
                            filename='proxy_unittests.log',
                            filemode='w')
        logger_name = 'ProxyTest'
        self.logger = logging.getLogger(logger_name)
        self.dict = {'logger': self.logger, 'vo': 'cms', 'group': group, 'role': role,
                     'myProxySvr': myProxySvr, 'proxyValidity' : '192:00', 'min_time_left' : 36000,
                     'uisource' : uiPath, 'serverDN' : serverDN}

        self.proxyPath = None
        self.proxy = Proxy( self.dict )
        self.serverDN = self.dict['serverDN']

    def tearDown(self):
        """
        _tearDown_
        """
        return

    @attr("integration")
    def testAAACreateMyProxy( self ):
        """
        Test if delegate method create correctly the MyProxy.
        """
        self.proxy.create()
        self.proxy.delegate( credential = self.proxyPath )
        valid = self.proxy.checkMyProxy( )
        self.assertTrue(valid, 'Could not create MyProxy')

    @attr("integration")
    def testDelegateServer( self ):
        """
        Test if delegate method create MyProxy and delegate
        the retrieval to the server correctly.
        """
        self.proxy.delegate( credential = self.proxyPath, serverRenewer = True )
        valid = self.proxy.checkMyProxy( checkRenewer = True )
        self.assertTrue(valid)

    @attr("integration")
    def testCheckMyProxy( self ):
        """
        Test if checkMyProxy checks correctly the MyProxy validity.
        """
        valid = self.proxy.checkMyProxy( )
        self.assertTrue(valid)

    @attr("integration")
    def testRenewMyProxy( self ):
        """
        Test if renewMyProxy method renews correctly the MyProxy.
        """
        self.proxy.renewMyProxy( proxy = self.proxyPath )
        time.sleep( 5 )
        timeLeft = self.proxy.getMyProxyTimeLeft( proxy = self.proxyPath )
        self.assertEqual(int(timeLeft) / 3600, 167)

    @attr("integration")
    def testRenewMyProxyForServer( self ):
        """
        Renew MyProxy which the retrieval is delegated to a server.
        """
        time.sleep( 70 )
        self.proxy.renewMyProxy( proxy = self.proxyPath, serverRenewer = True )
        time.sleep( 5 )
        timeLeft = self.proxy.getMyProxyTimeLeft( proxy = self.proxyPath, serverRenewer = True )
        self.assertEqual(int(timeLeft) / 3600, 167)

    @attr("integration")
    def testMyProxyEnvironment(self):
        """
        Test the myProxyEnvironment context manager
        In this test a new Proxy and MyProxy are initialized
        """
        myProxy = Proxy(self.dict)

        # Create the proxy
        myProxy.create()
        proxyPath = myProxy.getProxyFilename()
        userDN = myProxy.getSubject()
        self.assertTrue(os.path.exists(proxyPath))

        # Delegate and check the proxy
        myProxy.delegate(credential=proxyPath, serverRenewer=True)
        valid = myProxy.checkMyProxy()
        self.assertTrue(valid)

        # Make sure X509_USER_PROXY exists only in the context manager and corresponds to a file
        if 'X509_USER_PROXY' in os.environ:
            del os.environ['X509_USER_PROXY']
        self.assertFalse('X509_USER_PROXY' in os.environ)
        with myProxyEnvironment(userDN=userDN, serverCert=serverCert, serverKey=serverKey,
#.........这里部分代码省略.........
开发者ID:AndresTanasijczuk,项目名称:WMCore,代码行数:103,代码来源:MyProxy_t.py


注:本文中的WMCore.Credential.Proxy.Proxy.renewMyProxy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。