diff --git a/webservice/components/request_adapter.py b/webservice/components/request_adapter.py index 4d7d00cb..4356bcf2 100644 --- a/webservice/components/request_adapter.py +++ b/webservice/components/request_adapter.py @@ -65,8 +65,14 @@ def _get_headers_for_api_key(self, **kw): def _get_url(self, url=None, url_params=None, **kwargs): if not url: - # TODO: if url is given, we should validate the domain - # to avoid abusing a webservice backend for different calls. url = self.collection.url + elif not url.startswith(self.collection.url): + if not url.startswith("http"): + url = self.collection.url + url + else: + # TODO: if url is given, we should validate the domain + # to avoid abusing a webservice backend for different calls. + pass + url_params = url_params or kwargs return url.format(**url_params) diff --git a/webservice/tests/test_webservice.py b/webservice/tests/test_webservice.py index aee0ca54..c80c1df7 100644 --- a/webservice/tests/test_webservice.py +++ b/webservice/tests/test_webservice.py @@ -88,6 +88,17 @@ def test_web_service_get(self): responses.calls[0].request.headers["Content-Type"], "application/xml" ) + @responses.activate + def test_web_service_get_url_compine(self): + endpoint = "api/test" + responses.add(responses.GET, self.url + endpoint, body="{}") + result = self.webservice.call("get", url="api/test") + self.assertEqual(result, b"{}") + self.assertEqual(len(responses.calls), 1) + self.assertEqual( + responses.calls[0].request.headers["Content-Type"], "application/xml" + ) + @responses.activate def test_web_service_post(self): responses.add(responses.POST, self.url, body="{}")