@@ -32,6 +32,30 @@ def mock_profile(self):
3232 "idp_id" : "00u1klkowm8EGah2H357" ,
3333 }
3434
35+ @pytest .fixture
36+ def mock_connection (self ):
37+ return {
38+ "object" : "connection" ,
39+ "id" : "conn_id" ,
40+ "status" : "linked" ,
41+ "name" : "Google OAuth 2.0" ,
42+ "connection_type" : "GoogleOAuth" ,
43+ "oauth_uid" : "oauth-uid.apps.googleusercontent.com" ,
44+ "oauth_secret" : "oauth-secret" ,
45+ "oauth_redirect_uri" : "https://auth.workos.com/sso/oauth/google/chicken/callback" ,
46+ "saml_entity_id" : None ,
47+ "saml_idp_url" : None ,
48+ "saml_relying_party_trust_cert" : None ,
49+ "saml_x509_certs" : None ,
50+ "domains" : [
51+ {
52+ "object" : "connection_domain" ,
53+ "id" : "domain_id" ,
54+ "domain" : "terrace-house.com" ,
55+ },
56+ ],
57+ }
58+
3559 def test_authorization_url_throws_value_error_with_missing_domain_and_provider (
3660 self ,
3761 ):
@@ -120,3 +144,26 @@ def test_get_profile_returns_expected_workosprofile_object(
120144 profile = self .sso .get_profile (123 )
121145
122146 assert profile .to_dict () == mock_profile
147+
148+ def test_create_connection (self , mock_request_method , mock_connection ):
149+ response_dict = {
150+ "object" : "connection" ,
151+ "id" : mock_connection ["id" ],
152+ "name" : mock_connection ["name" ],
153+ "status" : mock_connection ["status" ],
154+ "connection_type" : mock_connection ["connection_type" ],
155+ "oauth_uid" : mock_connection ["oauth_uid" ],
156+ "oauth_secret" : mock_connection ["oauth_secret" ],
157+ "oauth_redirect_uri" : mock_connection ["oauth_redirect_uri" ],
158+ "saml_entity_id" : mock_connection ["saml_entity_id" ],
159+ "saml_idp_url" : mock_connection ["saml_idp_url" ],
160+ "saml_relying_party_trust_cert" : mock_connection [
161+ "saml_relying_party_trust_cert"
162+ ],
163+ "saml_x509_certs" : mock_connection ["saml_x509_certs" ],
164+ "domains" : mock_connection ["domains" ],
165+ }
166+ mock_request_method ("post" , mock_connection , 201 )
167+
168+ connection = self .sso .create_connection ("draft_conn_id" )
169+ assert connection == response_dict
0 commit comments