def hash_from_data(data): if not data: return "" signed_url = URLObject(data["url"]) signature_keys = [ key for key in signed_url.query_dict.keys() if key.startswith("X-Amz") ] unsigned_url = signed_url.del_query_params(signature_keys) unsigned_data = copy(data) unsigned_data["url"] = unsigned_url return MicroServiceResource.hash_from_data(unsigned_data)
def request_without_auth(self): """ Get the ``request`` that this resource will make with authentication headers and parameters from ``auth_headers`` and ``auth_parameters`` removed. :return: (dict) a copy of the ``request`` dictionary with authentication removed """ url = URLObject(self.request.get("url")) url = url.del_query_params(self.auth_parameters()) request = deepcopy(self.request) request["url"] = str(url) for key in self.auth_headers().keys(): if key in request["headers"]: del request["headers"][key] return request
def test_del_query_params_removes_multiple_query_parameters(self): url = URLObject('https://github.com/zacharyvoase/urlobject?foo=bar&baz=spam#foo') assert (url.del_query_params(['foo', 'baz']) == 'https://github.com/zacharyvoase/urlobject#foo')
def test_del_query_params_removes_multiple_query_parameters(self): url = URLObject(u'https://github.com/zacharyvoase/urlobject?foo=bar&baz=spam#foo') assert (url.del_query_params(['foo', 'baz']) == u'https://github.com/zacharyvoase/urlobject#foo')