Exemplo n.º 1
0
 def __init__(self, *args, **kwargs):
     self.normalized_request = Request('PUT', '/asdf/qwer/1234/title', { 'nonce': '987654321', 'Baseline': '5' }, { 'sample': 'example', 'Host': 'localhost' }, 'testing')
     date = datetime(2014, 11, 21, 13, 43, 15)
     signing_options = SigningOptions(SigningAlgorithms.PDX_HMAC_SHA256, SigningMechanisms.HEADER, '1234567890', 'asdfjklqwerzxcv', date, 90, 'HeaderSigningTest', 'Anonymous', 'Anonymous', 'Anonymous')
     signer = Signer()
     authorized_request = signer.sign(self.normalized_request, signing_options)
     super(when_using_header_signing_mechanism_to_generate_a_new_authorized_request_from_a_given_normalized_request, self).__init__(*args, **kwargs)
Exemplo n.º 2
0
    def create_hosted_document(self, document_id, document_name, document_content, signing_options):

        path = "/api/documents/{0}".format(document_id)

        host = 'hosted.pandexio.com'

        payload = {}
        payload['name'] = document_name
        payload['content'] = document_content
        payload_json = json.dumps(payload)

        normalized_request = Request(
            'PUT',
            path,
            {},
            {'Host': host},
            payload_json)

        signer = Signer()

        authorized_request = signer.sign(normalized_request, signing_options)

        conn = httplib.HTTPSConnection(host)

        query = urllib.urlencode(authorized_request.query_parameters)
        if len(query) > 0:
            query = '?' + query
        path_and_query = authorized_request.path + query

        headers = authorized_request.headers.copy();
        headers['Content-Type'] = 'application/json; charset=utf-8'

        conn.request(authorized_request.method, path_and_query, authorized_request.payload, headers)

        response = conn.getresponse()

        if response.status != 202:
            error_message = 'Hosted document creation failed. Status: {0} Reason: {1} Error: {2}'.format(response.status, response.reason, response.read())
            raise Exception(error_message)
Exemplo n.º 3
0
 def __init__(self, *args, **kwargs):
     normalized_request = Request('PUT', '/asdf/qwer/1234/title', { 'nonce': '987654321', 'Baseline': '5' }, { 'sample': 'example', 'Host': 'localhost' }, 'testing')
     signing_options = SigningOptions(SigningAlgorithms.PDX_HMAC_SHA256, SigningMechanisms.HEADER, '1234567890', 'asdfjklqwerzxcv', datetime(2014, 11, 21, 13, 43, 15), 90, 'HeaderSigningTest', 'Anonymous', 'á Anonymous', None)
     signer = Signer()
     self.authorized_request = signer.sign(normalized_request, signing_options)
     super(when_using_header_signing_mechanism_and_display_name_contains_non_ascii, self).__init__(*args, **kwargs)
 def __init__(self, *args, **kwargs):
     normalized_request = Request('PUT', '/asdf/qwer/1234/title', { 'nonce': '987654321', 'Baseline': '5' }, { 'sample': 'example', 'Host': 'localhost' }, 'testing')
     signing_options = SigningOptions(SigningAlgorithms.PDX_HMAC_SHA256, SigningMechanisms.QUERY_STRING, '1234567890', 'asdfjklqwerzxcv', datetime(2014, 11, 21, 13, 43, 15), 90, 'QueryStringSigningTest', 'ANONYMOUS', 'Anonymous', None)
     signer = Signer()
     self.authorized_request = signer.sign(normalized_request, signing_options)
     super(when_using_query_string_signing_mechanism_and_email_address_contains_all_uppercase_characters, self).__init__(*args, **kwargs)