@@ -11,6 +11,7 @@ def test_init_with_optionals(self):
11
11
telemetry_header = t .client .base_headers .get ('Auth0-Client' , None )
12
12
self .assertEqual (telemetry_header , None )
13
13
14
+ # Organizations
14
15
@mock .patch ('auth0.v3.management.organizations.RestClient' )
15
16
def test_all_organizations (self , mock_rc ):
16
17
mock_instance = mock_rc .return_value
@@ -80,4 +81,76 @@ def test_delete_organization(self, mock_rc):
80
81
81
82
mock_instance .delete .assert_called_with (
82
83
'https://domain/api/v2/organizations/this-id'
84
+ )
85
+
86
+ # Organization Connections
87
+ @mock .patch ('auth0.v3.management.organizations.RestClient' )
88
+ def test_all_organization_connections (self , mock_rc ):
89
+ mock_instance = mock_rc .return_value
90
+
91
+ c = Organizations (domain = 'domain' , token = 'jwttoken' )
92
+
93
+ # Default parameters are requested
94
+ c .all_organization_connections ('test-org' )
95
+
96
+ args , kwargs = mock_instance .get .call_args
97
+
98
+ self .assertEqual ('https://domain/api/v2/organizations/test-org/enabled_connections' , args [0 ])
99
+ self .assertEqual (kwargs ['params' ], {'page' : None ,
100
+ 'per_page' : None })
101
+
102
+ # Specific pagination
103
+ c .all_organization_connections ('test-org' , page = 7 , per_page = 25 )
104
+
105
+ args , kwargs = mock_instance .get .call_args
106
+
107
+ self .assertEqual ('https://domain/api/v2/organizations/test-org/enabled_connections' , args [0 ])
108
+ self .assertEqual (kwargs ['params' ], {'page' : 7 ,
109
+ 'per_page' : 25 })
110
+
111
+ @mock .patch ('auth0.v3.management.organizations.RestClient' )
112
+ def test_get_organization_connection (self , mock_rc ):
113
+ mock_instance = mock_rc .return_value
114
+
115
+ c = Organizations (domain = 'domain' , token = 'jwttoken' )
116
+ c .get_organization_connection ('test-org' , 'test-con' )
117
+
118
+ args , kwargs = mock_instance .get .call_args
119
+
120
+ self .assertEqual ('https://domain/api/v2/organizations/test-org/enabled_connections/test-con' , args [0 ])
121
+ self .assertEqual (kwargs ['params' ], {})
122
+
123
+ @mock .patch ('auth0.v3.management.organizations.RestClient' )
124
+ def test_create_organization_connection (self , mock_rc ):
125
+ mock_instance = mock_rc .return_value
126
+
127
+ c = Organizations (domain = 'domain' , token = 'jwttoken' )
128
+ c .create_organization_connection ('test-org' , {'a' : 'b' , 'c' : 'd' })
129
+
130
+ mock_instance .post .assert_called_with (
131
+ 'https://domain/api/v2/organizations/test-org/enabled_connections' ,
132
+ data = {'a' : 'b' , 'c' : 'd' }
133
+ )
134
+
135
+ @mock .patch ('auth0.v3.management.organizations.RestClient' )
136
+ def test_update_organization_connection (self , mock_rc ):
137
+ mock_instance = mock_rc .return_value
138
+
139
+ c = Organizations (domain = 'domain' , token = 'jwttoken' )
140
+ c .update_organization_connection ('test-org' , 'test-con' , {'a' : 'b' , 'c' : 'd' })
141
+
142
+ args , kwargs = mock_instance .patch .call_args
143
+
144
+ self .assertEqual ('https://domain/api/v2/organizations/test-org/enabled_connections/test-con' , args [0 ])
145
+ self .assertEqual (kwargs ['data' ], {'a' : 'b' , 'c' : 'd' })
146
+
147
+ @mock .patch ('auth0.v3.management.organizations.RestClient' )
148
+ def test_delete_organization_connection (self , mock_rc ):
149
+ mock_instance = mock_rc .return_value
150
+
151
+ c = Organizations (domain = 'domain' , token = 'jwttoken' )
152
+ c .delete_organization_connection ('test-org' , 'test-con' )
153
+
154
+ mock_instance .delete .assert_called_with (
155
+ 'https://domain/api/v2/organizations/test-org/enabled_connections/test-con'
83
156
)
0 commit comments