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)
Example #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)
 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)
Example #4
0
 def __init__(self, *args, **kwargs):
     normalized_request = Request('GET', '/asdf/documents/123', { 'DocumentIds': '456,789', 'Baseline': '5' }, { 'sample': 'example', 'Host': 'localhost' }, 'testing')
     signing_options = SigningOptions(SigningAlgorithms.PDX_HMAC_SHA256, SigningMechanisms.HEADER, '1234567890', 'asdfjklqwerzxcv', datetime.utcnow(), 90, 'HeaderSigningTest', 'Anonymous', 'Anonymous', 'Anonymous')
     signer = Signer()
     self.scope, authorized_request = signer.scope_and_sign(normalized_request, signing_options)
     super(when_scoping_and_signing_a_normalized_request_with_document_ids_in_the_path_and_query_string, 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)