8
8
)
9
9
10
10
func setupGroup (name string ) (* Group , * APIResponse , error ) {
11
- req := apiClient .GroupApi .CreateGroup (apiClient .cfg .Context )
11
+ req := apiClient .GroupAPI .CreateGroup (apiClient .cfg .Context )
12
12
gp := NewGroupProfile ()
13
13
gp .SetName (name )
14
14
payload := Group {Profile : gp }
@@ -17,20 +17,20 @@ func setupGroup(name string) (*Group, *APIResponse, error) {
17
17
}
18
18
19
19
func cleanUpGroup (groupId string ) (err error ) {
20
- _ , err = apiClient .GroupApi .DeleteGroup (apiClient .cfg .Context , groupId ).Execute ()
20
+ _ , err = apiClient .GroupAPI .DeleteGroup (apiClient .cfg .Context , groupId ).Execute ()
21
21
return
22
22
}
23
23
24
24
func cleanUpGroupRule (groupRuleId string ) (err error ) {
25
- _ , err = apiClient .GroupApi .DeleteGroupRule (apiClient .cfg .Context , groupRuleId ).Execute ()
25
+ _ , err = apiClient .GroupAPI .DeleteGroupRule (apiClient .cfg .Context , groupRuleId ).Execute ()
26
26
return
27
27
}
28
28
29
29
func Test_Get_Group (t * testing.T ) {
30
30
group , _ , err := setupGroup (randomTestString ())
31
31
require .NoError (t , err , "Creating a new group should not error" )
32
32
t .Run ("get group by id" , func (t * testing.T ) {
33
- gid , _ , err := apiClient .GroupApi .GetGroup (apiClient .cfg .Context , group .GetId ()).Execute ()
33
+ gid , _ , err := apiClient .GroupAPI .GetGroup (apiClient .cfg .Context , group .GetId ()).Execute ()
34
34
require .NoError (t , err , "Could not get group by ID" )
35
35
assert .Equal (t , group .GetId (), gid .GetId ())
36
36
})
@@ -42,7 +42,7 @@ func Test_Get_List_Group(t *testing.T) {
42
42
group , _ , err := setupGroup (randomTestString ())
43
43
require .NoError (t , err , "Creating a new group should not error" )
44
44
t .Run ("get list group" , func (t * testing.T ) {
45
- gs , _ , err := apiClient .GroupApi .ListGroups (apiClient .cfg .Context ).Execute ()
45
+ gs , _ , err := apiClient .GroupAPI .ListGroups (apiClient .cfg .Context ).Execute ()
46
46
require .NoError (t , err , "Could not get list group" )
47
47
var createdGroupInList bool
48
48
for _ , g := range gs {
@@ -61,7 +61,7 @@ func Test_Search_Group(t *testing.T) {
61
61
group , _ , err := setupGroup (groupName )
62
62
require .NoError (t , err , "Creating a new group should not error" )
63
63
t .Run ("search group" , func (t * testing.T ) {
64
- req := apiClient .GroupApi .ListGroups (apiClient .cfg .Context )
64
+ req := apiClient .GroupAPI .ListGroups (apiClient .cfg .Context )
65
65
req = req .Q (groupName )
66
66
gs , _ , err := req .Execute ()
67
67
require .NoError (t , err , "Could not get result from search keyword" )
@@ -87,7 +87,7 @@ func Test_Update_Group(t *testing.T) {
87
87
ngp .SetName (newGroupName )
88
88
ng := Group {}
89
89
ng .SetProfile (ngp )
90
- req := apiClient .GroupApi .ReplaceGroup (apiClient .cfg .Context , group .GetId ())
90
+ req := apiClient .GroupAPI .ReplaceGroup (apiClient .cfg .Context , group .GetId ())
91
91
req = req .Group (ng )
92
92
g , _ , err := req .Execute ()
93
93
require .NoError (t , err , "Could not update group" )
@@ -104,9 +104,9 @@ func Test_Group_User_Operation(t *testing.T) {
104
104
user , _ , _ , err := setupUser (true )
105
105
require .NoError (t , err , "Creating a new user should not error" )
106
106
t .Run ("add user to group" , func (t * testing.T ) {
107
- _ , err := apiClient .GroupApi .AssignUserToGroup (apiClient .cfg .Context , group .GetId (), user .GetId ()).Execute ()
107
+ _ , err := apiClient .GroupAPI .AssignUserToGroup (apiClient .cfg .Context , group .GetId (), user .GetId ()).Execute ()
108
108
require .NoError (t , err , "Could not add user to group" )
109
- users , _ , err := apiClient .GroupApi .ListGroupUsers (apiClient .cfg .Context , group .GetId ()).Execute ()
109
+ users , _ , err := apiClient .GroupAPI .ListGroupUsers (apiClient .cfg .Context , group .GetId ()).Execute ()
110
110
require .NoError (t , err )
111
111
found := false
112
112
for _ , u := range users {
@@ -117,9 +117,9 @@ func Test_Group_User_Operation(t *testing.T) {
117
117
assert .True (t , found , "Could not find user in group" )
118
118
})
119
119
t .Run ("remove user from group" , func (t * testing.T ) {
120
- _ , err := apiClient .GroupApi .UnassignUserFromGroup (apiClient .cfg .Context , group .GetId (), user .GetId ()).Execute ()
120
+ _ , err := apiClient .GroupAPI .UnassignUserFromGroup (apiClient .cfg .Context , group .GetId (), user .GetId ()).Execute ()
121
121
require .NoError (t , err , "Could not remove user from group" )
122
- users , _ , err := apiClient .GroupApi .ListGroupUsers (apiClient .cfg .Context , group .GetId ()).Execute ()
122
+ users , _ , err := apiClient .GroupAPI .ListGroupUsers (apiClient .cfg .Context , group .GetId ()).Execute ()
123
123
require .NoError (t , err )
124
124
found := false
125
125
for _ , u := range users {
@@ -154,14 +154,14 @@ func Test_Group_Rule_Operation(t *testing.T) {
154
154
gr .SetConditions (* grc )
155
155
gr .SetType ("group_rule" )
156
156
gr .SetName (randomTestString ())
157
- req := apiClient .GroupApi .CreateGroupRule (apiClient .cfg .Context )
157
+ req := apiClient .GroupAPI .CreateGroupRule (apiClient .cfg .Context )
158
158
req = req .GroupRule (* gr )
159
159
groupRule , _ , err := req .Execute ()
160
160
require .NoError (t , err , "Creating a new group rule should not error" )
161
161
t .Run ("activate group rule" , func (t * testing.T ) {
162
- _ , err = apiClient .GroupApi .ActivateGroupRule (apiClient .cfg .Context , groupRule .GetId ()).Execute ()
162
+ _ , err = apiClient .GroupAPI .ActivateGroupRule (apiClient .cfg .Context , groupRule .GetId ()).Execute ()
163
163
require .NoError (t , err , "Should not error when activating rule" )
164
- groupRules , _ , err := apiClient .GroupApi .ListGroupRules (apiClient .cfg .Context ).Execute ()
164
+ groupRules , _ , err := apiClient .GroupAPI .ListGroupRules (apiClient .cfg .Context ).Execute ()
165
165
require .NoError (t , err , "Should not error when listing group rule" )
166
166
found := false
167
167
for _ , grs := range groupRules {
@@ -172,7 +172,7 @@ func Test_Group_Rule_Operation(t *testing.T) {
172
172
assert .True (t , found , "Found group rule in list" )
173
173
})
174
174
t .Run ("deactivate group rule" , func (t * testing.T ) {
175
- _ , err = apiClient .GroupApi .DeactivateGroupRule (apiClient .cfg .Context , groupRule .GetId ()).Execute ()
175
+ _ , err = apiClient .GroupAPI .DeactivateGroupRule (apiClient .cfg .Context , groupRule .GetId ()).Execute ()
176
176
require .NoError (t , err , "Should not error when deactivating rule" )
177
177
})
178
178
t .Run ("update group rule" , func (t * testing.T ) {
@@ -190,13 +190,13 @@ func Test_Group_Rule_Operation(t *testing.T) {
190
190
gr .SetConditions (* grc )
191
191
gr .SetType ("group_rule" )
192
192
gr .SetName (randomTestString ())
193
- req := apiClient .GroupApi .ReplaceGroupRule (apiClient .cfg .Context , groupRule .GetId ())
193
+ req := apiClient .GroupAPI .ReplaceGroupRule (apiClient .cfg .Context , groupRule .GetId ())
194
194
req = req .GroupRule (* gr )
195
195
newGroupRule , _ , err := req .Execute ()
196
196
require .NoError (t , err , "Should not error when updating rule" )
197
- _ , err = apiClient .GroupApi .ActivateGroupRule (apiClient .cfg .Context , newGroupRule .GetId ()).Execute ()
197
+ _ , err = apiClient .GroupAPI .ActivateGroupRule (apiClient .cfg .Context , newGroupRule .GetId ()).Execute ()
198
198
require .NoError (t , err , "Should not error when activating rule" )
199
- _ , err = apiClient .GroupApi .DeactivateGroupRule (apiClient .cfg .Context , groupRule .GetId ()).Execute ()
199
+ _ , err = apiClient .GroupAPI .DeactivateGroupRule (apiClient .cfg .Context , groupRule .GetId ()).Execute ()
200
200
require .NoError (t , err , "Should not error when deactivating rule" )
201
201
})
202
202
err = cleanUpUser (user .GetId ())
@@ -212,16 +212,16 @@ func Test_List_Assigned_Applications_For_Group(t *testing.T) {
212
212
require .NoError (t , err , "Creating a new group should not error" )
213
213
var createdApp * ListApplications200ResponseInner
214
214
t .Run ("get list assigned application for group" , func (t * testing.T ) {
215
- apps , _ , err := apiClient .GroupApi .ListAssignedApplicationsForGroup (apiClient .cfg .Context , group .GetId ()).Execute ()
215
+ apps , _ , err := apiClient .GroupAPI .ListAssignedApplicationsForGroup (apiClient .cfg .Context , group .GetId ()).Execute ()
216
216
require .NoError (t , err , "Should not error when listing assigned apps for group" )
217
217
assert .Equal (t , 0 , len (apps ), "there shouldn't be any apps assigned to group" )
218
218
createdApp , _ , err = setupBookmarkApplication (randomTestString ())
219
219
require .NoError (t , err , "Creating an application should not error" )
220
- aareq := apiClient .ApplicationGroupsApi .AssignGroupToApplication (apiClient .cfg .Context , createdApp .BookmarkApplication .GetId (), group .GetId ())
220
+ aareq := apiClient .ApplicationGroupsAPI .AssignGroupToApplication (apiClient .cfg .Context , createdApp .BookmarkApplication .GetId (), group .GetId ())
221
221
aareq .applicationGroupAssignment = NewApplicationGroupAssignment ()
222
222
_ , _ , err = aareq .Execute ()
223
223
require .NoError (t , err , "Assigning application to group should not error" )
224
- apps , _ , err = apiClient .GroupApi .ListAssignedApplicationsForGroup (apiClient .cfg .Context , group .GetId ()).Execute ()
224
+ apps , _ , err = apiClient .GroupAPI .ListAssignedApplicationsForGroup (apiClient .cfg .Context , group .GetId ()).Execute ()
225
225
require .NoError (t , err , "Should not error when listing assigned apps for group" )
226
226
assert .Equal (t , 1 , len (apps ), "there shouldn't be any apps assigned to group" )
227
227
})
@@ -236,13 +236,13 @@ func Test_Assigned_Role_To_Group_Operation(t *testing.T) {
236
236
require .NoError (t , err , "Creating a new group should not error" )
237
237
var createdRole * Role
238
238
t .Run ("assigned role to group" , func (t * testing.T ) {
239
- req := apiClient .RoleAssignmentApi .AssignRoleToGroup (apiClient .cfg .Context , group .GetId ())
239
+ req := apiClient .RoleAssignmentAPI .AssignRoleToGroup (apiClient .cfg .Context , group .GetId ())
240
240
assignedRoleSA := NewAssignRoleRequest ()
241
241
assignedRoleSA .SetType ("SUPER_ADMIN" )
242
242
req = req .AssignRoleRequest (* assignedRoleSA )
243
243
createdRole , _ , err = req .Execute ()
244
244
require .NoError (t , err , "Assigned role to group should not error" )
245
- roles , _ , err := apiClient .RoleAssignmentApi .ListGroupAssignedRoles (apiClient .cfg .Context , group .GetId ()).Execute ()
245
+ roles , _ , err := apiClient .RoleAssignmentAPI .ListGroupAssignedRoles (apiClient .cfg .Context , group .GetId ()).Execute ()
246
246
require .NoError (t , err , "Listing group assigned role should not error" )
247
247
var found bool
248
248
for _ , r := range roles {
@@ -253,9 +253,9 @@ func Test_Assigned_Role_To_Group_Operation(t *testing.T) {
253
253
assert .True (t , found )
254
254
})
255
255
t .Run ("unassigned role to group" , func (t * testing.T ) {
256
- _ , err = apiClient .RoleAssignmentApi .UnassignRoleFromGroup (apiClient .cfg .Context , group .GetId (), createdRole .GetId ()).Execute ()
256
+ _ , err = apiClient .RoleAssignmentAPI .UnassignRoleFromGroup (apiClient .cfg .Context , group .GetId (), createdRole .GetId ()).Execute ()
257
257
require .NoError (t , err , "Unassigned role to group should not error" )
258
- roles , _ , err := apiClient .RoleAssignmentApi .ListGroupAssignedRoles (apiClient .cfg .Context , group .GetId ()).Execute ()
258
+ roles , _ , err := apiClient .RoleAssignmentAPI .ListGroupAssignedRoles (apiClient .cfg .Context , group .GetId ()).Execute ()
259
259
require .NoError (t , err , "Listing group assigned role should not error" )
260
260
assert .Empty (t , roles )
261
261
})
0 commit comments