# Path: apiritif/ssl_adapter.py
# class SSLAdapter(HTTPAdapter):
#     def __init__(self, *args, **kwargs):
#         certificate_file_path = kwargs.pop('certificate_file_path', None)
#         passphrase = kwargs.pop('passphrase', None)
# 
#         pkcs12_obj = CertificateReader.create_pkcs12_obj(certificate_file_path, passphrase)
#         self.ssl_context = CertificateReader.create_ssl_context(pkcs12_obj)
# 
#         super(SSLAdapter, self).__init__(*args, **kwargs)
# 
#     def init_poolmanager(self, *args, **kwargs):
#         if self.ssl_context:
#             kwargs['ssl_context'] = self.ssl_context
#         return super(SSLAdapter, self).init_poolmanager(*args, **kwargs)
# 
#     def proxy_manager_for(self, *args, **kwargs):
#         if self.ssl_context:
#             kwargs['ssl_context'] = self.ssl_context
#         return super(SSLAdapter, self).proxy_manager_for(*args, **kwargs)
# 
# Path: apiritif/thread.py
# def get_from_thread_store(names=None):
#     if names and hasattr(_thread_local, "kwargs"):
#         only_one = False
#         if isinstance(names, str):
#             names = [names]
#             only_one = True
#         kwargs = [_thread_local.kwargs.get(key) for key in names]
#         if only_one:
#             return kwargs[0]
#         else:
#             return kwargs
# 
#     elif hasattr(_thread_local, "args"):
#         return _thread_local.args
# 
# def put_into_thread_store(*args, **kwargs):
#     if args:
#         _thread_local.args = args
#     if kwargs:
#         current_kwargs = getattr(_thread_local, "kwargs", {})
#         current_kwargs.update(kwargs)
#         _thread_local.kwargs = current_kwargs
# 
# Path: apiritif/utils.py
# VERSION = "1.1.3"
# def get_trace(error):
# def graceful():
# def headers_as_text(headers_dict):
# def shorten(string, upto, end_with="..."):
# def assert_regexp(regex, text, match=False, msg=None):
# def assert_not_regexp(regex, text, match=False, msg=None):
# class NormalShutdown(BaseException):


import copy
import os
import threading
import time
import requests
import apiritif
from functools import wraps
from io import BytesIO
from jsonpath_ng.ext import parse as jsonpath_parse
from lxml import etree, html
from requests.structures import CaseInsensitiveDict
from apiritif.ssl_adapter import SSLAdapter
from apiritif.thread import get_from_thread_store, put_into_thread_store
from apiritif.utilities import *
from apiritif.utils import headers_as_text, assert_regexp, assert_not_regexp, log, get_trace, NormalShutdown, graceful
        return self

    # TODO: assert_content_type?

    @recorder.assertion_decorator
    def assert_has_header(self, header, msg=None):
        if header not in self.headers:
            msg = msg or "Header %s wasn't found in response headers: %r" % (header, self.headers)
            raise AssertionError(msg)
        return self

    @recorder.assertion_decorator
    def assert_header_value(self, header, value, msg=None):
        self.assert_has_header(header)
        actual = self.headers[header]
        if actual != value:
            msg = msg or "Actual header value (%r) isn't equal to expected (%r)" % (actual, value)
            raise AssertionError(msg)
        return self

    @recorder.assertion_decorator
    def assert_in_headers(self, member, msg=None):
        headers_text = headers_as_text(self.headers)
        if member not in headers_text:
            msg = msg or "Header %s wasn't found in response headers text: %r" % (member, headers_text)
            raise AssertionError(msg)
        return self

    @recorder.assertion_decorator
    def assert_not_in_headers(self, member, msg=None):

# Path: apiritif/ssl_adapter.py
# class SSLAdapter(HTTPAdapter):
#     def __init__(self, *args, **kwargs):
#         certificate_file_path = kwargs.pop('certificate_file_path', None)
#         passphrase = kwargs.pop('passphrase', None)
# 
#         pkcs12_obj = CertificateReader.create_pkcs12_obj(certificate_file_path, passphrase)
#         self.ssl_context = CertificateReader.create_ssl_context(pkcs12_obj)
# 
#         super(SSLAdapter, self).__init__(*args, **kwargs)
# 
#     def init_poolmanager(self, *args, **kwargs):
#         if self.ssl_context:
#             kwargs['ssl_context'] = self.ssl_context
#         return super(SSLAdapter, self).init_poolmanager(*args, **kwargs)
# 
#     def proxy_manager_for(self, *args, **kwargs):
#         if self.ssl_context:
#             kwargs['ssl_context'] = self.ssl_context
#         return super(SSLAdapter, self).proxy_manager_for(*args, **kwargs)
# 
# Path: apiritif/thread.py
# def get_from_thread_store(names=None):
#     if names and hasattr(_thread_local, "kwargs"):
#         only_one = False
#         if isinstance(names, str):
#             names = [names]
#             only_one = True
#         kwargs = [_thread_local.kwargs.get(key) for key in names]
#         if only_one:
#             return kwargs[0]
#         else:
#             return kwargs
# 
#     elif hasattr(_thread_local, "args"):
#         return _thread_local.args
# 
# def put_into_thread_store(*args, **kwargs):
#     if args:
#         _thread_local.args = args
#     if kwargs:
#         current_kwargs = getattr(_thread_local, "kwargs", {})
#         current_kwargs.update(kwargs)
#         _thread_local.kwargs = current_kwargs
# 
# Path: apiritif/utils.py
# VERSION = "1.1.3"
# def get_trace(error):
# def graceful():
# def headers_as_text(headers_dict):
# def shorten(string, upto, end_with="..."):
# def assert_regexp(regex, text, match=False, msg=None):
# def assert_not_regexp(regex, text, match=False, msg=None):
# class NormalShutdown(BaseException):


# Path: apiritif/http.py
import copy
import os
import threading
import time
import requests
import apiritif
from functools import wraps
from io import BytesIO
from jsonpath_ng.ext import parse as jsonpath_parse
from lxml import etree, html
from requests.structures import CaseInsensitiveDict
from apiritif.ssl_adapter import SSLAdapter
from apiritif.thread import get_from_thread_store, put_into_thread_store
from apiritif.utilities import *
from apiritif.utils import headers_as_text, assert_regexp, assert_not_regexp, log, get_trace, NormalShutdown, graceful

        return self

    # TODO: assert_content_type?

    @recorder.assertion_decorator
    def assert_has_header(self, header, msg=None):
        if header not in self.headers:
            msg = msg or "Header %s wasn't found in response headers: %r" % (header, self.headers)
            raise AssertionError(msg)
        return self

    @recorder.assertion_decorator
    def assert_header_value(self, header, value, msg=None):
        self.assert_has_header(header)
        actual = self.headers[header]
        if actual != value:
            msg = msg or "Actual header value (%r) isn't equal to expected (%r)" % (actual, value)
            raise AssertionError(msg)
        return self

    @recorder.assertion_decorator
    def assert_in_headers(self, member, msg=None):
        headers_text = headers_as_text(self.headers)
        if member not in headers_text:
            msg = msg or "Header %s wasn't found in response headers text: %r" % (member, headers_text)
            raise AssertionError(msg)
        return self

    @recorder.assertion_decorator
    def assert_not_in_headers(self, member, msg=None):

        if member in headers_as_text(self.headers):