File tree Expand file tree Collapse file tree 4 files changed +15
-30
lines changed
Expand file tree Collapse file tree 4 files changed +15
-30
lines changed Original file line number Diff line number Diff line change @@ -42,28 +42,10 @@ def test_initialize_sso_missing_api_key_and_project_id(self):
4242
4343 assert all (setting in message for setting in ("api_key" , "project_id" ,))
4444
45- def test_initialize_audit_log_missing_api_key (self , set_project_id ):
45+ def test_initialize_audit_log_missing_api_key (self ):
4646 with pytest .raises (ConfigurationException ) as ex :
4747 client .audit_log
4848
4949 message = str (ex )
5050
5151 assert "api_key" in message
52- assert "project_id" not in message
53-
54- def test_initialize_audit_log_missing_project_id (self , set_api_key ):
55- with pytest .raises (ConfigurationException ) as ex :
56- client .audit_log
57-
58- message = str (ex )
59-
60- assert "project_id" in message
61- assert "api_key" not in message
62-
63- def test_initialize_audit_log_missing_api_key_and_project_id (self ):
64- with pytest .raises (ConfigurationException ) as ex :
65- client .audit_log
66-
67- message = str (ex )
68-
69- assert all (setting in message for setting in ("api_key" , "project_id" ,))
Original file line number Diff line number Diff line change 11import workos
22from workos .exceptions import ConfigurationException
33from workos .utils .request import RequestHelper , REQUEST_METHOD_POST
4- from workos .utils .validation import validate_api_key_and_project_id
4+ from workos .utils .validation import AUDIT_LOG_MODULE , validate_settings
55
66EVENTS_PATH = "events"
77METADATA_LIMIT = 50
1010class AuditLog (object ):
1111 """Offers methods through the WorkOS Audit Log service."""
1212
13- @validate_api_key_and_project_id ( "Audit Log" )
13+ @validate_settings ( AUDIT_LOG_MODULE )
1414 def __init__ (self ):
1515 pass
1616
Original file line number Diff line number Diff line change 77from workos .resources .sso import WorkOSProfile
88from workos .utils .connection_types import ConnectionType
99from workos .utils .request import RequestHelper , RESPONSE_TYPE_CODE , REQUEST_METHOD_POST
10- from workos .utils .validation import validate_api_key_and_project_id
10+ from workos .utils .validation import SSO_MODULE , validate_settings
1111
1212AUTHORIZATION_PATH = "sso/authorize"
1313TOKEN_PATH = "sso/token"
1818class SSO (object ):
1919 """Offers methods to assist in authenticating through the WorkOS SSO service."""
2020
21- @validate_api_key_and_project_id ( "SSO" )
21+ @validate_settings ( SSO_MODULE )
2222 def __init__ (self ):
2323 pass
2424
Original file line number Diff line number Diff line change 33import workos
44from workos .exceptions import ConfigurationException
55
6+ AUDIT_LOG_MODULE = "AuditLog"
7+ SSO_MODULE = "SSO"
68
7- def validate_api_key_and_project_id (module_name ):
9+ REQUIRED_SETTINGS_FOR_MODULE = {
10+ AUDIT_LOG_MODULE : ["api_key" ,],
11+ SSO_MODULE : ["api_key" , "project_id" ,],
12+ }
13+
14+
15+ def validate_settings (module_name ):
816 def decorator (fn ):
917 @wraps (fn )
1018 def wrapper (* args , ** kwargs ):
11- required_settings = [
12- "api_key" ,
13- "project_id" ,
14- ]
15-
1619 missing_settings = []
17- for setting in required_settings :
20+ for setting in REQUIRED_SETTINGS_FOR_MODULE [ module_name ] :
1821 if not getattr (workos , setting , None ):
1922 missing_settings .append (setting )
2023
You can’t perform that action at this time.
0 commit comments