def setUp(self): "initialization" self.mgr = RequestHandler() #self.ckey = os.path.join(os.environ['HOME'], '.globus/userkey.pem') #self.cert = os.path.join(os.environ['HOME'], '.globus/usercert.pem') self.ckey = getKeyCertFromEnv()[0] self.cert = getKeyCertFromEnv()[1] self.cricheader = 'Date: Tue, 06 Nov 2018 14:50:29 GMT\r\nServer: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips mod_wsgi/3.4 Python/2.7.5 mod_gridsite/2.3.4\r\nVary: Cookie\r\nX-Frame-Options: SAMEORIGIN\r\nSet-Cookie: sessionid=bc1xu8zi5rbbsd5fgjuklb2tk2r3f6tw; expires=Sun, 11-Nov-2018 14:50:29 GMT; httponly; Max-Age=432000; Path=/\r\nContent-Length: 32631\r\nContent-Type: application/json\r\n\r\n' self.dbsheader = 'Date: Tue, 06 Nov 2018 14:39:07 GMT\r\nServer: Apache\r\nCMS-Server-Time: D=1503 t=1541515147806112\r\nTransfer-Encoding: chunked\r\nContent-Type: text/html\r\n\r\n' self.HTTPheader = 'Date: Tue, 06 Nov 2018 14:50:29 GMT\r\nServer: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips mod_wsgi/3.4 Python/2.7.5 mod_gridsite/2.3.4\r\nVary: Cookie\r\nX-Frame-Options: SAMEORIGIN\r\nSet-Cookie: GRIDHTTP_PASSCODE=2c6da9c96efa2ad0farhda; domain=cms-cric.cern.ch; path=/; secure\r\nContent-Length: 32631\r\nContent-Type: application/json\r\n\r\n'
def getdata(url, params, headers=None): "Helper function to get data from the service" ckey, cert = getKeyCertFromEnv() mgr = RequestHandler() res = mgr.getdata(url, params=params, headers=headers, ckey=ckey, cert=cert) return json.loads(res)
def getKeyCert(self): """ _getKeyCert_ Get the user credentials if they exist, otherwise throw an exception. This code was modified from DBSAPI/dbsHttpService.py """ # Zeroth case is if the class has over ridden the key/cert and has it # stored in self if self['cert'] and self['key']: key = self['key'] cert = self['cert'] else: key, cert = getKeyCertFromEnv() # Set but not found if key is None or cert is None: raise WMException('Request requires a host certificate and key', "WMCORE-11") # All looks OK, still doesn't guarantee proxy's validity etc. return key, cert
def getKeyCert(self): """ _getKeyCert_ Get the user credentials if they exist, otherwise throw an exception. This code was modified from DBSAPI/dbsHttpService.py """ # Zeroth case is if the class has over ridden the key/cert and has it # stored in self if self['cert'] and self['key']: key = self['key'] cert = self['cert'] else: key, cert = getKeyCertFromEnv() # Set but not found if key is None or cert is None: raise WMException('Request requires a host certificate and key', "WMCORE-11") # All looks OK, still doesn't guarantee proxy's validity etc. return key, cert
def cert(): "Return user CA cert either from proxy or usercert.pem" pair = getKeyCertFromEnv() return pair[1]
def ckey(): "Return user CA key either from proxy or userkey.pem" pair = getKeyCertFromEnv() return pair[0]
def getdata(url, params, headers=None): "Helper function to get data from the service" ckey, cert = getKeyCertFromEnv() mgr = RequestHandler() res = mgr.getdata(url, params=params, headers=headers, ckey=ckey, cert=cert) return json.loads(res)
def cert(): "Return user CA cert either from proxy or usercert.pem" pair = getKeyCertFromEnv() return pair[1]
def ckey(): "Return user CA key either from proxy or userkey.pem" pair = getKeyCertFromEnv() return pair[0]