Beispiel #1
0
    def test_generate_telesign_headers_default_date_and_nonce(self):
        method_name = 'GET'
        resource = '/v1/resource'

        actual_headers = RestClient.generate_telesign_headers(
            self.customer_id,
            self.api_key,
            method_name,
            resource,
            '',
            user_agent='unit_test')

        self.assertFalse(parsedate_tz(actual_headers.get('Date')) is None)

        try:
            UUID(actual_headers.get('x-ts-nonce'))
        except (TypeError, ValueError):
            self.fail("x-ts-nonce is not a UUID")
Beispiel #2
0
    def test_generate_telesign_headers_with_get(self):
        method_name = 'GET'
        date_rfc2616 = 'Wed, 14 Dec 2016 18:20:12 GMT'
        nonce = 'A1592C6F-E384-4CDB-BC42-C3AB970369E9'
        resource = '/v1/resource'

        expected_authorization_header = (
            'TSA FFFFFFFF-EEEE-DDDD-1234-AB1234567890:'
            'aUm7I+9GKl3ww7PNeeJntCT0iS7b+EmRKEE4LnRzChQ=')

        actual_headers = RestClient.generate_telesign_headers(
            self.customer_id,
            self.api_key,
            method_name,
            resource,
            '',
            date_rfc2616=date_rfc2616,
            nonce=nonce,
            user_agent='unit_test')

        self.assertEqual(expected_authorization_header,
                         actual_headers['Authorization'])
Beispiel #3
0
    def test_generate_telesign_headers_unicode_content(self):
        method_name = 'POST'
        date_rfc2616 = 'Wed, 14 Dec 2016 18:20:12 GMT'
        nonce = 'A1592C6F-E384-4CDB-BC42-C3AB970369E9'
        resource = '/v1/resource'
        body_params_url_encoded = 'test=%CF%BF'

        expected_authorization_header = (
            'TSA FFFFFFFF-EEEE-DDDD-1234-AB1234567890:'
            'h8d4I0RTxErbxYXuzCOtNqb/f0w3Ck8e5SEkGNj01+8=')

        actual_headers = RestClient.generate_telesign_headers(
            self.customer_id,
            self.api_key,
            method_name,
            resource,
            body_params_url_encoded,
            date_rfc2616=date_rfc2616,
            nonce=nonce,
            user_agent='unit_test')

        self.assertEqual(expected_authorization_header,
                         actual_headers['Authorization'])
Beispiel #4
0
    def test_generate_telesign_headers_with_post(self):
        method_name = 'POST'
        date_rfc2616 = 'Wed, 14 Dec 2016 18:20:12 GMT'
        nonce = 'A1592C6F-E384-4CDB-BC42-C3AB970369E9'
        resource = '/v1/resource'
        body_params_url_encoded = 'test=param'

        expected_authorization_header = (
            'TSA FFFFFFFF-EEEE-DDDD-1234-AB1234567890:'
            '2xVlmbrxLjYrrPun3G3WMNG6Jon4yKcTeOoK9DjXJ/Q=')

        actual_headers = RestClient.generate_telesign_headers(
            self.customer_id,
            self.api_key,
            method_name,
            resource,
            body_params_url_encoded,
            date_rfc2616=date_rfc2616,
            nonce=nonce,
            user_agent='unit_test')

        self.assertEqual(expected_authorization_header,
                         actual_headers['Authorization'])