def _prepare_request(event, payload, _secret=None, headers=None):
    if headers is None:
        headers = dict()

    request = FakeRequest()

    request.uri = b"/change_hook/github"
    request.method = b"GET"
    request.received_headers = {_HEADER_EVENT: event}

    if isinstance(payload, (string_types, bytes)):
        if isinstance(payload, text_type):
            request.content = StringIO(payload)
        elif isinstance(payload, bytes):
            request.content = BytesIO(payload)
        request.received_headers[_HEADER_CT] = _CT_JSON

        if _secret is not None:
            signature = hmac.new(unicode2bytes(_secret),
                                 msg=unicode2bytes(payload),
                                 digestmod=sha1)
            request.received_headers[_HEADER_SIGNATURE] = \
                'sha1={}'.format(signature.hexdigest())
    else:
        request.args['payload'] = payload
        request.received_headers[_HEADER_CT] = _CT_ENCODED

    request.received_headers.update(headers)

    # print request.received_headers

    return request
def _prepare_request(event, payload, _secret=None, headers=None):
    if headers is None:
        headers = dict()

    request = FakeRequest()

    request.uri = b"/change_hook/github"
    request.method = b"GET"
    request.received_headers = {
        _HEADER_EVENT: event
    }

    if isinstance(payload, (string_types, bytes)):
        if isinstance(payload, text_type):
            request.content = StringIO(payload)
        elif isinstance(payload, bytes):
            request.content = BytesIO(payload)
        request.received_headers[_HEADER_CT] = _CT_JSON

        if _secret is not None:
            signature = hmac.new(unicode2bytes(_secret),
                                 msg=unicode2bytes(payload),
                                 digestmod=sha1)
            request.received_headers[_HEADER_SIGNATURE] = \
                'sha1={}'.format(signature.hexdigest())
    else:
        request.args['payload'] = payload
        request.received_headers[_HEADER_CT] = _CT_ENCODED

    request.received_headers.update(headers)

    # print request.received_headers

    return request
def _prepare_request(event, payload, _secret=None, headers=None):
    if headers is None:
        headers = dict()

    request = FakeRequest()

    request.uri = "/change_hook/github"
    request.method = "GET"
    request.received_headers = {
        _HEADER_EVENT: event
    }

    if isinstance(payload, str):
        request.content = StringIO(payload)
        request.received_headers[_HEADER_CT] = _CT_JSON

        if _secret is not None:
            signature = hmac.new(_secret, msg=payload, digestmod=sha1)
            request.received_headers[_HEADER_SIGNATURE] = \
                'sha1=%s' % (signature.hexdigest(),)
    else:
        request.args['payload'] = payload
        request.received_headers[_HEADER_CT] = _CT_ENCODED

    request.received_headers.update(headers)

    # print request.received_headers

    return request
def _prepare_request(event, payload, _secret=None, headers=None):
    if headers is None:
        headers = dict()

    request = FakeRequest()

    request.uri = "/change_hook/github"
    request.method = "GET"
    request.received_headers = {
        _HEADER_EVENT: event
    }

    if isinstance(payload, str):
        request.content = StringIO(payload)
        request.received_headers[_HEADER_CT] = _CT_JSON

        if _secret is not None:
            signature = hmac.new(_secret, msg=payload, digestmod=sha1)
            request.received_headers[_HEADER_SIGNATURE] = \
                'sha1=%s' % (signature.hexdigest(),)
    else:
        request.args['payload'] = payload
        request.received_headers[_HEADER_CT] = _CT_ENCODED

    request.received_headers.update(headers)

    # print request.received_headers

    return request
def _prepare_request(payload, headers=None, change_dict=None):
    headers = headers or {}
    request = FakeRequest(change_dict)
    request.uri = "/change_hook/bitbucketserver"
    request.method = "POST"
    request.content = StringIO(payload)
    request.received_headers['Content-Type'] = _CT_JSON
    request.received_headers.update(headers)
    return request
def _prepare_request(payload, headers=None, change_dict=None):
    headers = headers or {}
    request = FakeRequest(change_dict)
    request.uri = "/change_hook/bitbucketserver"
    request.method = "POST"
    request.content = StringIO(payload)
    request.received_headers['Content-Type'] = _CT_JSON
    request.received_headers.update(headers)
    return request
Example #7
0
def _prepare_request(payload, headers=None, change_dict=None):
    headers = headers or {}
    request = FakeRequest(change_dict)
    request.uri = b"/change_hook/bitbucketcloud"
    request.method = b"POST"
    if isinstance(payload, text_type):
        payload = unicode2bytes(payload)
    request.content = BytesIO(payload)
    request.received_headers[b'Content-Type'] = _CT_JSON
    request.received_headers.update(headers)
    return request