Beispiel #1
0
    def get_base_string(self, request, nonce, timestamp):
        # if there are query string params, remove them from the basic string,
        # as encode_parameters already took care of including them
        parsed = port.urlparse(request.uri)
        uri = port.urlunparse((parsed.scheme, parsed.netloc, parsed.path,
                               parsed.params, '', parsed.fragment))

        return (self.encode(request.method) + '&' + self.encode(uri) + '&' +
                self.normalized_params(request, nonce, timestamp))
Beispiel #2
0
    def encode_qs_params(self, request):
        # If there is a query string, split it out and include in the
        # parameters. In typical libsaas usage there will never be a query
        # string, since parameters should be passed as Request.params, but just
        # in case someone tried, check it.
        query = port.urlparse(request.uri).query
        params = port.parse_qsl(query, True)

        return tuple(
            (self.encode(key), self.encode(val)) for key, val in params)
Beispiel #3
0
    def encode_qs_params(self, request):
        # If there is a query string, split it out and include in the
        # parameters. In typical libsaas usage there will never be a query
        # string, since parameters should be passed as Request.params, but just
        # in case someone tried, check it.
        query = port.urlparse(request.uri).query
        params = port.parse_qsl(query, True)

        return tuple((self.encode(key), self.encode(val))
                     for key, val in params)
Beispiel #4
0
    def get_base_string(self, request, nonce, timestamp):
        # if there are query string params, remove them from the basic string,
        # as encode_parameters already took care of including them
        parsed = port.urlparse(request.uri)
        uri = port.urlunparse((parsed.scheme, parsed.netloc, parsed.path,
                               parsed.params, '', parsed.fragment))

        return (self.encode(request.method) + '&' +
                self.encode(uri) + '&' +
                self.normalized_params(request, nonce, timestamp))
Beispiel #5
0
    def test_urlmetrics(self):
        params = {'Cols': '9', 'Signature': '/pZ83jzQ+0589L0giwQkHg5yui0=',
                     'AccessID': 'access-id', 'Expires': '946688761'}

        self.service.urlmetrics('example.org/dir',
                                constants.TITLE + constants.SUBDOMAIN)
        self.expect('GET', '/url-metrics/example.org/dir/', params)

        urls = ['example.org/dir', 'example.net/other']
        self.service.urlmetrics(urls, constants.TITLE + constants.SUBDOMAIN)
        self.assertEqual(self.executor.request.method, 'POST')

        parsed = port.urlparse(self.executor.request.uri)
        self.assertEqual(
            (parsed.scheme, parsed.netloc, parsed.path),
            ('https', 'lsapi.seomoz.com', '/linkscape/url-metrics/'))
        self.assertEqual(dict(port.parse_qsl(parsed.query)), params)
        self.assertEqual(json.loads(self.executor.request.params), urls)