Esempio n. 1
0
 def flaky_request(method, url, **kwargs):
     if method == "GET" and url.find("/3/Jobs/") != -1:
         global job_request_counter
         job_request_counter += 1
         if job_request_counter == 2:
             raise H2OConnectionError("Simulated connection failure")
     return requests.request_orig(method, url, **kwargs)
Esempio n. 2
0
def request(*args, **kwargs):
    pkcs12_data = kwargs.pop('pkcs12_data', None)
    pkcs12_filename = kwargs.pop('pkcs12_filename', None)
    pkcs12_password = kwargs.pop('pkcs12_password', None)
    if pkcs12_data is None and pkcs12_filename is None and pkcs12_password is None:
        return request_orig(*args, **kwargs)
    if 'cert' in kwargs:
        raise ValueError('Argument "cert" conflicts with "pkcs12_*" arguments')
    with Session() as session:
        pkcs12_adapter = Pkcs12Adapter(
            pkcs12_data=pkcs12_data,
            pkcs12_filename=pkcs12_filename,
            pkcs12_password=pkcs12_password,
        )
        session.mount('https://', pkcs12_adapter)
        return session.request(*args, **kwargs)