20
20
21
21
import pytest
22
22
23
- from umapi_client import IdentityTypes
24
- from umapi_client import UserAction
23
+ from umapi_client import IdentityTypes , GroupTypes , RoleTypes
24
+ from umapi_client import UserAction , UserGroupAction
25
25
26
26
27
27
def test_user_emptyid ():
28
28
with pytest .raises (ValueError ):
29
- user = UserAction (id_type = IdentityTypes .federatedID )
29
+ UserAction (id_type = IdentityTypes .federatedID )
30
30
31
31
32
32
def test_user_adobeid ():
33
33
user = UserAction (
email = "[email protected] " )
34
- assert user .
wire_dict ()
== {
"do" : [],
"user" :
"[email protected] " }
34
+ assert user .wire_dict () == {"do" : [],
35
+
36
+ "useAdobeID" : True }
35
37
36
38
37
39
def test_user_enterpriseid ():
@@ -41,7 +43,7 @@ def test_user_enterpriseid():
41
43
42
44
def test_user_enterpriseid_username ():
43
45
with pytest .raises (ValueError ):
44
- user = UserAction (id_type = IdentityTypes .enterpriseID , username = "dbrotsky" , domain = "o.on-the-side.net" )
46
+ UserAction (id_type = IdentityTypes .enterpriseID , username = "dbrotsky" , domain = "o.on-the-side.net" )
45
47
46
48
47
49
def test_user_federatedid ():
@@ -58,7 +60,8 @@ def test_create_user_adobeid():
58
60
user = UserAction (
email = "[email protected] " )
59
61
user .create ()
60
62
assert user .
wire_dict ()
== {
"do" : [{
"addAdobeID" : {
"email" :
"[email protected] " }}],
61
-
63
+
64
+ "useAdobeID" : True }
62
65
63
66
64
67
def test_create_user_adobeid_country ():
@@ -95,7 +98,7 @@ def test_create_user_federatedid_username():
95
98
96
99
97
100
def test_create_user_federatedid_username_email ():
98
- user = UserAction (id_type = IdentityTypes .federatedID ,username = "dbrotsky" , domain = "k.on-the-side.net" ,
101
+ user = UserAction (id_type = IdentityTypes .federatedID , username = "dbrotsky" , domain = "k.on-the-side.net" ,
99
102
100
103
user .create (first_name = "Daniel" , last_name = "Brotsky" , country = "US" )
101
104
assert user .
wire_dict ()
== {
"do" : [{
"createFederatedID" : {
"email" :
"[email protected] " ,
@@ -131,38 +134,77 @@ def test_update_user_federatedid_username():
131
134
132
135
133
136
134
- def test_add_product_federatedid ():
137
+ def test_add_org_federatedid ():
138
+ user = UserAction (
id_type = IdentityTypes .
federatedID ,
email = "[email protected] " )
139
+ user .add_to_groups ()
140
+ assert user .wire_dict () == {"do" : [{"add" : {"product" : []}}],
141
+
142
+
143
+
144
+ def test_add_products_federatedid ():
135
145
user = UserAction (
id_type = IdentityTypes .
federatedID ,
email = "[email protected] " )
136
- user .add_group (groups = ["Photoshop" , "Illustrator" ])
146
+ user .add_to_groups (groups = ["Photoshop" , "Illustrator" ])
137
147
assert user .wire_dict () == {"do" : [{"add" : {"product" : ["Photoshop" , "Illustrator" ]}}],
138
148
139
149
140
150
141
- def test_remove_product_federatedid ():
151
+ def test_add_to_groups_federatedid_all ():
152
+ user = UserAction (
id_type = IdentityTypes .
federatedID ,
email = "[email protected] " )
153
+ user .add_to_groups (all_groups = True )
154
+ assert user .wire_dict () == {"do" : [{"add" : "all" }],
155
+
156
+
157
+
158
+ def test_add_to_groups_federatedid_all_error ():
159
+ user = UserAction (
id_type = "federatedID" ,
email = "[email protected] " )
160
+ with pytest .raises (ValueError ):
161
+ user .add_to_groups (all_groups = True , groups = ["Photoshop" ])
162
+
163
+
164
+ def test_add_to_usergroups_federatedid ():
165
+ user = UserAction (
id_type = IdentityTypes .
federatedID ,
email = "[email protected] " )
166
+ user .add_to_groups (groups = ["Photoshop" , "Illustrator" ], group_type = GroupTypes .usergroup )
167
+ assert user .wire_dict () == {"do" : [{"add" : {"usergroup" : ["Photoshop" , "Illustrator" ]}}],
168
+
169
+
170
+
171
+ def test_remove_from_products_federatedid ():
142
172
user = UserAction (
id_type = IdentityTypes .
federatedID ,
email = "[email protected] " )
143
- user .remove_group (groups = ["Photoshop" , "Illustrator" ])
173
+ user .remove_from_groups (groups = ["Photoshop" , "Illustrator" ], group_type = "product" )
144
174
assert user .wire_dict () == {"do" : [{"remove" : {"product" : ["Photoshop" , "Illustrator" ]}}],
145
175
146
176
147
177
148
- def test_remove_product_federatedid_all ():
178
+ def test_remove_from_groups_federatedid_all ():
149
179
user = UserAction (
id_type = 'federatedID' ,
email = "[email protected] " )
150
- user .remove_group (all_groups = True )
180
+ user .remove_from_groups (all_groups = True )
151
181
assert user .wire_dict () == {"do" : [{"remove" : "all" }],
152
182
153
183
154
184
185
+ def test_remove_from_groups_federatedid_all_error ():
186
+ user = UserAction (
id_type = 'federatedID' ,
email = "[email protected] " )
187
+ with pytest .raises (ValueError ):
188
+ user .remove_from_groups (all_groups = True , group_type = "usergroup" )
189
+
190
+
155
191
def test_add_role_enterpriseid ():
156
192
user = UserAction (
id_type = IdentityTypes .
enterpriseID ,
email = "[email protected] " )
157
193
user .add_role (groups = ["Photoshop" , "Illustrator" ])
158
194
assert user .wire_dict () == {"do" : [{"addRoles" : {"admin" : ["Photoshop" , "Illustrator" ]}}],
159
195
160
196
161
197
198
+ def test_add_role_enterpriseid_error ():
199
+ user = UserAction (
id_type = IdentityTypes .
enterpriseID ,
email = "[email protected] " )
200
+ with pytest .raises (ValueError ):
201
+ user .add_role (groups = [], role_type = RoleTypes .admin )
202
+
203
+
162
204
def test_remove_role_enterpriseid ():
163
205
user = UserAction (
id_type = 'enterpriseID' ,
email = "[email protected] " )
164
- user .remove_role (groups = ["Photoshop" , "Illustrator" ])
165
- assert user .wire_dict () == {"do" : [{"removeRoles" : {"admin " : ["Photoshop" , "Illustrator" ]}}],
206
+ user .remove_role (groups = ["Photoshop" , "Illustrator" ], role_type = "productAdmin" )
207
+ assert user .wire_dict () == {"do" : [{"removeRoles" : {"productAdmin " : ["Photoshop" , "Illustrator" ]}}],
166
208
167
209
168
210
@@ -177,13 +219,14 @@ def test_remove_from_organization_adobeid():
177
219
user = UserAction (
id_type = 'adobeID' ,
email = "[email protected] " )
178
220
user .remove_from_organization ()
179
221
assert user .wire_dict () == {"do" : [{"removeFromOrg" : {}}],
180
-
222
+
223
+ "useAdobeID" : True }
181
224
182
225
183
226
def test_remove_from_organization_delete_federatedid ():
184
227
user = UserAction (
id_type = IdentityTypes .
federatedID ,
email = "[email protected] " )
185
228
user .remove_from_organization (delete_account = True )
186
- assert user .wire_dict () == {"do" : [{"removeFromOrg" : {"removedDomain " : "k.on-the-side.net" }}],
229
+ assert user .wire_dict () == {"do" : [{"removeFromOrg" : {}}, { "removeFromDomain " : { }}],
187
230
188
231
189
232
@@ -196,11 +239,77 @@ def test_remove_from_organization_delete_adobeid():
196
239
def test_delete_account_enterpriseid ():
197
240
user = UserAction (
id_type = IdentityTypes .
enterpriseID ,
email = "[email protected] " )
198
241
user .delete_account ()
199
- assert user .wire_dict () == {"do" : [{"removeFromDomain" : {"domain" : "o.on-the-side.net" }}],
242
+ assert user .wire_dict () == {"do" : [{"removeFromDomain" : {}}],
200
243
201
244
202
245
203
246
def test_delete_account_adobeid ():
204
247
user = UserAction (
id_type = IdentityTypes .
adobeID ,
email = "[email protected] " )
205
248
with pytest .raises (ValueError ):
206
249
user .delete_account ()
250
+
251
+
252
+ def test_add_to_products ():
253
+ group = UserGroupAction (group_name = "SampleUsers" )
254
+ group .add_to_products (products = ["Photoshop" , "Illustrator" ])
255
+ assert group .wire_dict () == {"do" : [{"add" : {"product" : ["Photoshop" , "Illustrator" ]}}],
256
+ "usergroup" : "SampleUsers" }
257
+
258
+
259
+ def test_add_to_products_all ():
260
+ group = UserGroupAction (group_name = "SampleUsers" )
261
+ group .add_to_products (all_products = True )
262
+ assert group .wire_dict () == {"do" : [{"add" : "all" }],
263
+ "usergroup" : "SampleUsers" }
264
+
265
+
266
+ def test_add_to_products_all_error ():
267
+ group = UserGroupAction (group_name = "SampleUsers" )
268
+ with pytest .raises (ValueError ):
269
+ group .add_to_products (all_products = True , products = ["Photoshop" ])
270
+
271
+
272
+ def test_remove_from_products ():
273
+ group = UserGroupAction (group_name = "SampleUsers" )
274
+ group .remove_from_products (products = ["Photoshop" , "Illustrator" ])
275
+ assert group .wire_dict () == {"do" : [{"remove" : {"product" : ["Photoshop" , "Illustrator" ]}}],
276
+ "usergroup" : "SampleUsers" }
277
+
278
+
279
+ def test_remove_from_products_all ():
280
+ group = UserGroupAction (group_name = "SampleUsers" )
281
+ group .remove_from_products (all_products = True )
282
+ assert group .wire_dict () == {"do" : [{"remove" : "all" }],
283
+ "usergroup" : "SampleUsers" }
284
+
285
+
286
+ def test_remove_from_products_all_error ():
287
+ group = UserGroupAction (group_name = "SampleUsers" )
288
+ with pytest .raises (ValueError ):
289
+ group .remove_from_products (all_products = True , products = ["Photoshop" ])
290
+
291
+
292
+ def test_add_users ():
293
+ group = UserGroupAction (group_name = "SampleUsers" )
294
+
295
+ assert group .
wire_dict ()
== {
"do" : [{
"add" : {
"user" : [
"[email protected] " ,
"[email protected] " ]}}],
296
+ "usergroup" : "SampleUsers" }
297
+
298
+
299
+ def test_add_users_error ():
300
+ group = UserGroupAction (group_name = "SampleUsers" )
301
+ with pytest .raises (ValueError ):
302
+ group .add_users (users = [])
303
+
304
+
305
+ def test_remove_users ():
306
+ group = UserGroupAction (group_name = "SampleUsers" )
307
+ group .
remove_users (
users = [
"[email protected] " ,
"[email protected] " ])
308
+ assert group .
wire_dict ()
== {
"do" : [{
"remove" : {
"user" : [
"[email protected] " ,
"[email protected] " ]}}],
309
+ "usergroup" : "SampleUsers" }
310
+
311
+
312
+ def test_remove_users_error ():
313
+ group = UserGroupAction (group_name = "SampleUsers" )
314
+ with pytest .raises (ValueError ):
315
+ group .remove_users (users = [])
0 commit comments