99
1010from .base import BaseClient
1111from .errors import (
12- CheckPermissionError ,
13- ConnectionsError ,
14- DeleteDataError ,
15- DeletePolicyError ,
16- FileError ,
17- PathNotFoundError ,
18- PolicyNotFoundError ,
19- RegoParseError ,
20- TypeException ,
12+ CheckPermissionError ,
13+ ConnectionsError ,
14+ DeleteDataError ,
15+ DeletePolicyError ,
16+ FileError ,
17+ PathNotFoundError ,
18+ PolicyNotFoundError ,
19+ RegoParseError ,
20+ TypeException ,
2121)
2222
2323
@@ -61,7 +61,9 @@ def _init_session(self) -> requests.Session:
6161 session .mount ("https://" , adapter )
6262
6363 if self .ssl :
64- session .verify = self .cert
64+ session .verify = self .ssl
65+ if self .cert :
66+ session .cert = self .cert
6567
6668 return session
6769
@@ -201,7 +203,9 @@ def update_policy_from_file(self, filepath: str, endpoint: str) -> bool:
201203 bool: True if the policy was successfully updated.
202204 """
203205 if not os .path .isfile (filepath ):
204- raise FileError ("file_not_found" ,f"'{ filepath } ' is not a valid file" )
206+ raise FileError (
207+ "file_not_found" , f"'{ filepath } ' is not a valid file"
208+ )
205209
206210 with open (filepath , "r" , encoding = "utf-8" ) as file :
207211 policy_str = file .read ()
@@ -299,7 +303,9 @@ def policy_to_file(
299303 policy_raw = policy .get ("result" , {}).get ("raw" , "" )
300304
301305 if not policy_raw :
302- raise PolicyNotFoundError ("resource_not_found" , "Policy content is empty" )
306+ raise PolicyNotFoundError (
307+ "resource_not_found" , "Policy content is empty"
308+ )
303309
304310 full_path = os .path .join (path or "" , filename )
305311
@@ -308,7 +314,9 @@ def policy_to_file(
308314 file .write (policy_raw )
309315 return True
310316 except OSError as e :
311- raise PathNotFoundError ("path_not_found" , f"Failed to write to '{ full_path } '" ) from e
317+ raise PathNotFoundError (
318+ "path_not_found" , f"Failed to write to '{ full_path } '"
319+ ) from e
312320
313321 def get_policy (self , policy_name : str ) -> dict :
314322 """
@@ -394,7 +402,8 @@ def check_permission(
394402
395403 if rule_name not in rules :
396404 raise CheckPermissionError (
397- "resource_not_found" , f"Rule '{ rule_name } ' not found in policy '{ policy_name } '"
405+ "resource_not_found" ,
406+ f"Rule '{ rule_name } ' not found in policy '{ policy_name } '" ,
398407 )
399408
400409 url = f"{ self .root_url } /{ package_path } /{ rule_name } "
0 commit comments