Skip to content

Commit 61b6673

Browse files
committed
fix ssl issue for GIS API
.
1 parent bb9f877 commit 61b6673

File tree

4 files changed

+10
-11
lines changed

4 files changed

+10
-11
lines changed

geosyspy/services/gis_service.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def get_municipio_id_from_geometry(self, geometry: str):
2525
payload = {"properties": ["id"], "features": [geometry]}
2626
parameters: str = "/layerservices/api/v1/layers/BRAZIL_MUNICIPIOS/intersect"
2727
gis_url: str = urljoin(self.base_url, parameters)
28-
response = self.http_client.post(gis_url, payload)
28+
response = self.http_client.post(gis_url, payload, verify_ssl=False)
2929
if response.status_code == 200:
3030
dict_response = response.json()
3131

@@ -58,7 +58,7 @@ def get_farm_info_from_location(self, latitude: str, longitude: str):
5858
f"/layerservices/api/v1/layers/BR_CAR_PROPERTIES/feature?LOCATION={latitude},{longitude}&format=wkt"
5959
)
6060
gis_url: str = urljoin(self.base_url, parameters)
61-
response = self.http_client.get(gis_url)
61+
response = self.http_client.get(gis_url, verify_ssl=False)
6262
if response.status_code == 200:
6363
return response.json()
6464

geosyspy/utils/http_client.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ def __init__(
5252
bearer_token=bearer_token
5353
)
5454
self.access_token = self.__client_oauth.token
55-
55+
5656
self.__client = OAuth2Session(self.__client_oauth.client_id,
5757
token=self.__client_oauth.token)
5858

5959
@renew_access_token
60-
def get(self, url_endpoint: str, headers=None):
60+
def get(self, url_endpoint: str, headers=None, verify_ssl = True):
6161
"""Gets the url_endpopint.
6262
6363
Args:
@@ -68,10 +68,10 @@ def get(self, url_endpoint: str, headers=None):
6868
"""
6969
if headers is None:
7070
headers = {}
71-
return self.__client.get(url_endpoint, headers=headers)
71+
return self.__client.get(url_endpoint, headers=headers, verify=verify_ssl)
7272

7373
@renew_access_token
74-
def post(self, url_endpoint: str, payload: dict, headers=None):
74+
def post(self, url_endpoint: str, payload: dict, headers=None, verify_ssl = True):
7575
"""Posts payload to the url_endpoint.
7676
7777
Args:
@@ -83,10 +83,10 @@ def post(self, url_endpoint: str, payload: dict, headers=None):
8383
"""
8484
if headers is None:
8585
headers = {}
86-
return self.__client.post(url_endpoint, json=payload, headers=headers)
86+
return self.__client.post(url_endpoint, json=payload, headers=headers, verify=verify_ssl)
8787

8888
@renew_access_token
89-
def patch(self, url_endpoint: str, payload: dict):
89+
def patch(self, url_endpoint: str, payload: dict, verify_ssl = True):
9090
"""Patchs payload to the url_endpoint.
9191
9292
Args:
@@ -96,7 +96,7 @@ def patch(self, url_endpoint: str, payload: dict):
9696
Returns:
9797
A response object.
9898
"""
99-
return self.__client.patch(url_endpoint, json=payload)
99+
return self.__client.patch(url_endpoint, json=payload, verify=verify_ssl)
100100

101101
def get_access_token(self):
102102
"""Returns the access token.

requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ rasterio
88
xarray
99
retrying
1010
pip-system-certs
11-
PyJWT
11+
PyJWT==1.7.1
1212
cryptography

tests/test_int_geosys.py

-1
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,6 @@ def test_get_mr_time_series(self):
306306
assert '/mrts/' in result
307307

308308

309-
@pytest.mark.skip(reason="soucis SSL dans github")
310309
def test_get_farm_info_from_location(self):
311310
result = self.client.get_farm_info_from_location(
312311
latitude="-15.01402",

0 commit comments

Comments
 (0)