forked from raystack/guardian
/
GcloudIamClient.go
386 lines (316 loc) · 13.9 KB
/
GcloudIamClient.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
// Code generated by mockery v2.33.0. DO NOT EDIT.
package mocks
import (
context "context"
domain "github.com/goto/guardian/domain"
iam "google.golang.org/api/iam/v1"
mock "github.com/stretchr/testify/mock"
)
// GcloudIamClient is an autogenerated mock type for the GcloudIamClient type
type GcloudIamClient struct {
mock.Mock
}
type GcloudIamClient_Expecter struct {
mock *mock.Mock
}
func (_m *GcloudIamClient) EXPECT() *GcloudIamClient_Expecter {
return &GcloudIamClient_Expecter{mock: &_m.Mock}
}
// GetGrantableRoles provides a mock function with given fields: ctx, resourceType
func (_m *GcloudIamClient) GetGrantableRoles(ctx context.Context, resourceType string) ([]*iam.Role, error) {
ret := _m.Called(ctx, resourceType)
var r0 []*iam.Role
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, string) ([]*iam.Role, error)); ok {
return rf(ctx, resourceType)
}
if rf, ok := ret.Get(0).(func(context.Context, string) []*iam.Role); ok {
r0 = rf(ctx, resourceType)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).([]*iam.Role)
}
}
if rf, ok := ret.Get(1).(func(context.Context, string) error); ok {
r1 = rf(ctx, resourceType)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// GcloudIamClient_GetGrantableRoles_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetGrantableRoles'
type GcloudIamClient_GetGrantableRoles_Call struct {
*mock.Call
}
// GetGrantableRoles is a helper method to define mock.On call
// - ctx context.Context
// - resourceType string
func (_e *GcloudIamClient_Expecter) GetGrantableRoles(ctx interface{}, resourceType interface{}) *GcloudIamClient_GetGrantableRoles_Call {
return &GcloudIamClient_GetGrantableRoles_Call{Call: _e.mock.On("GetGrantableRoles", ctx, resourceType)}
}
func (_c *GcloudIamClient_GetGrantableRoles_Call) Run(run func(ctx context.Context, resourceType string)) *GcloudIamClient_GetGrantableRoles_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(string))
})
return _c
}
func (_c *GcloudIamClient_GetGrantableRoles_Call) Return(_a0 []*iam.Role, _a1 error) *GcloudIamClient_GetGrantableRoles_Call {
_c.Call.Return(_a0, _a1)
return _c
}
func (_c *GcloudIamClient_GetGrantableRoles_Call) RunAndReturn(run func(context.Context, string) ([]*iam.Role, error)) *GcloudIamClient_GetGrantableRoles_Call {
_c.Call.Return(run)
return _c
}
// GrantAccess provides a mock function with given fields: ctx, accountType, accountID, role
func (_m *GcloudIamClient) GrantAccess(ctx context.Context, accountType string, accountID string, role string) error {
ret := _m.Called(ctx, accountType, accountID, role)
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, string, string, string) error); ok {
r0 = rf(ctx, accountType, accountID, role)
} else {
r0 = ret.Error(0)
}
return r0
}
// GcloudIamClient_GrantAccess_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GrantAccess'
type GcloudIamClient_GrantAccess_Call struct {
*mock.Call
}
// GrantAccess is a helper method to define mock.On call
// - ctx context.Context
// - accountType string
// - accountID string
// - role string
func (_e *GcloudIamClient_Expecter) GrantAccess(ctx interface{}, accountType interface{}, accountID interface{}, role interface{}) *GcloudIamClient_GrantAccess_Call {
return &GcloudIamClient_GrantAccess_Call{Call: _e.mock.On("GrantAccess", ctx, accountType, accountID, role)}
}
func (_c *GcloudIamClient_GrantAccess_Call) Run(run func(ctx context.Context, accountType string, accountID string, role string)) *GcloudIamClient_GrantAccess_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(string))
})
return _c
}
func (_c *GcloudIamClient_GrantAccess_Call) Return(_a0 error) *GcloudIamClient_GrantAccess_Call {
_c.Call.Return(_a0)
return _c
}
func (_c *GcloudIamClient_GrantAccess_Call) RunAndReturn(run func(context.Context, string, string, string) error) *GcloudIamClient_GrantAccess_Call {
_c.Call.Return(run)
return _c
}
// GrantServiceAccountAccess provides a mock function with given fields: ctx, sa, accountType, accountID, roles
func (_m *GcloudIamClient) GrantServiceAccountAccess(ctx context.Context, sa string, accountType string, accountID string, roles string) error {
ret := _m.Called(ctx, sa, accountType, accountID, roles)
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, string, string, string, string) error); ok {
r0 = rf(ctx, sa, accountType, accountID, roles)
} else {
r0 = ret.Error(0)
}
return r0
}
// GcloudIamClient_GrantServiceAccountAccess_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GrantServiceAccountAccess'
type GcloudIamClient_GrantServiceAccountAccess_Call struct {
*mock.Call
}
// GrantServiceAccountAccess is a helper method to define mock.On call
// - ctx context.Context
// - sa string
// - accountType string
// - accountID string
// - roles string
func (_e *GcloudIamClient_Expecter) GrantServiceAccountAccess(ctx interface{}, sa interface{}, accountType interface{}, accountID interface{}, roles interface{}) *GcloudIamClient_GrantServiceAccountAccess_Call {
return &GcloudIamClient_GrantServiceAccountAccess_Call{Call: _e.mock.On("GrantServiceAccountAccess", ctx, sa, accountType, accountID, roles)}
}
func (_c *GcloudIamClient_GrantServiceAccountAccess_Call) Run(run func(ctx context.Context, sa string, accountType string, accountID string, roles string)) *GcloudIamClient_GrantServiceAccountAccess_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(string), args[4].(string))
})
return _c
}
func (_c *GcloudIamClient_GrantServiceAccountAccess_Call) Return(_a0 error) *GcloudIamClient_GrantServiceAccountAccess_Call {
_c.Call.Return(_a0)
return _c
}
func (_c *GcloudIamClient_GrantServiceAccountAccess_Call) RunAndReturn(run func(context.Context, string, string, string, string) error) *GcloudIamClient_GrantServiceAccountAccess_Call {
_c.Call.Return(run)
return _c
}
// ListAccess provides a mock function with given fields: ctx, resources
func (_m *GcloudIamClient) ListAccess(ctx context.Context, resources []*domain.Resource) (domain.MapResourceAccess, error) {
ret := _m.Called(ctx, resources)
var r0 domain.MapResourceAccess
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, []*domain.Resource) (domain.MapResourceAccess, error)); ok {
return rf(ctx, resources)
}
if rf, ok := ret.Get(0).(func(context.Context, []*domain.Resource) domain.MapResourceAccess); ok {
r0 = rf(ctx, resources)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(domain.MapResourceAccess)
}
}
if rf, ok := ret.Get(1).(func(context.Context, []*domain.Resource) error); ok {
r1 = rf(ctx, resources)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// GcloudIamClient_ListAccess_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListAccess'
type GcloudIamClient_ListAccess_Call struct {
*mock.Call
}
// ListAccess is a helper method to define mock.On call
// - ctx context.Context
// - resources []*domain.Resource
func (_e *GcloudIamClient_Expecter) ListAccess(ctx interface{}, resources interface{}) *GcloudIamClient_ListAccess_Call {
return &GcloudIamClient_ListAccess_Call{Call: _e.mock.On("ListAccess", ctx, resources)}
}
func (_c *GcloudIamClient_ListAccess_Call) Run(run func(ctx context.Context, resources []*domain.Resource)) *GcloudIamClient_ListAccess_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].([]*domain.Resource))
})
return _c
}
func (_c *GcloudIamClient_ListAccess_Call) Return(_a0 domain.MapResourceAccess, _a1 error) *GcloudIamClient_ListAccess_Call {
_c.Call.Return(_a0, _a1)
return _c
}
func (_c *GcloudIamClient_ListAccess_Call) RunAndReturn(run func(context.Context, []*domain.Resource) (domain.MapResourceAccess, error)) *GcloudIamClient_ListAccess_Call {
_c.Call.Return(run)
return _c
}
// ListServiceAccounts provides a mock function with given fields: _a0
func (_m *GcloudIamClient) ListServiceAccounts(_a0 context.Context) ([]*iam.ServiceAccount, error) {
ret := _m.Called(_a0)
var r0 []*iam.ServiceAccount
var r1 error
if rf, ok := ret.Get(0).(func(context.Context) ([]*iam.ServiceAccount, error)); ok {
return rf(_a0)
}
if rf, ok := ret.Get(0).(func(context.Context) []*iam.ServiceAccount); ok {
r0 = rf(_a0)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).([]*iam.ServiceAccount)
}
}
if rf, ok := ret.Get(1).(func(context.Context) error); ok {
r1 = rf(_a0)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// GcloudIamClient_ListServiceAccounts_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListServiceAccounts'
type GcloudIamClient_ListServiceAccounts_Call struct {
*mock.Call
}
// ListServiceAccounts is a helper method to define mock.On call
// - _a0 context.Context
func (_e *GcloudIamClient_Expecter) ListServiceAccounts(_a0 interface{}) *GcloudIamClient_ListServiceAccounts_Call {
return &GcloudIamClient_ListServiceAccounts_Call{Call: _e.mock.On("ListServiceAccounts", _a0)}
}
func (_c *GcloudIamClient_ListServiceAccounts_Call) Run(run func(_a0 context.Context)) *GcloudIamClient_ListServiceAccounts_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context))
})
return _c
}
func (_c *GcloudIamClient_ListServiceAccounts_Call) Return(_a0 []*iam.ServiceAccount, _a1 error) *GcloudIamClient_ListServiceAccounts_Call {
_c.Call.Return(_a0, _a1)
return _c
}
func (_c *GcloudIamClient_ListServiceAccounts_Call) RunAndReturn(run func(context.Context) ([]*iam.ServiceAccount, error)) *GcloudIamClient_ListServiceAccounts_Call {
_c.Call.Return(run)
return _c
}
// RevokeAccess provides a mock function with given fields: ctx, accountType, accountID, role
func (_m *GcloudIamClient) RevokeAccess(ctx context.Context, accountType string, accountID string, role string) error {
ret := _m.Called(ctx, accountType, accountID, role)
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, string, string, string) error); ok {
r0 = rf(ctx, accountType, accountID, role)
} else {
r0 = ret.Error(0)
}
return r0
}
// GcloudIamClient_RevokeAccess_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RevokeAccess'
type GcloudIamClient_RevokeAccess_Call struct {
*mock.Call
}
// RevokeAccess is a helper method to define mock.On call
// - ctx context.Context
// - accountType string
// - accountID string
// - role string
func (_e *GcloudIamClient_Expecter) RevokeAccess(ctx interface{}, accountType interface{}, accountID interface{}, role interface{}) *GcloudIamClient_RevokeAccess_Call {
return &GcloudIamClient_RevokeAccess_Call{Call: _e.mock.On("RevokeAccess", ctx, accountType, accountID, role)}
}
func (_c *GcloudIamClient_RevokeAccess_Call) Run(run func(ctx context.Context, accountType string, accountID string, role string)) *GcloudIamClient_RevokeAccess_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(string))
})
return _c
}
func (_c *GcloudIamClient_RevokeAccess_Call) Return(_a0 error) *GcloudIamClient_RevokeAccess_Call {
_c.Call.Return(_a0)
return _c
}
func (_c *GcloudIamClient_RevokeAccess_Call) RunAndReturn(run func(context.Context, string, string, string) error) *GcloudIamClient_RevokeAccess_Call {
_c.Call.Return(run)
return _c
}
// RevokeServiceAccountAccess provides a mock function with given fields: ctx, sa, accountType, accountID, role
func (_m *GcloudIamClient) RevokeServiceAccountAccess(ctx context.Context, sa string, accountType string, accountID string, role string) error {
ret := _m.Called(ctx, sa, accountType, accountID, role)
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, string, string, string, string) error); ok {
r0 = rf(ctx, sa, accountType, accountID, role)
} else {
r0 = ret.Error(0)
}
return r0
}
// GcloudIamClient_RevokeServiceAccountAccess_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RevokeServiceAccountAccess'
type GcloudIamClient_RevokeServiceAccountAccess_Call struct {
*mock.Call
}
// RevokeServiceAccountAccess is a helper method to define mock.On call
// - ctx context.Context
// - sa string
// - accountType string
// - accountID string
// - role string
func (_e *GcloudIamClient_Expecter) RevokeServiceAccountAccess(ctx interface{}, sa interface{}, accountType interface{}, accountID interface{}, role interface{}) *GcloudIamClient_RevokeServiceAccountAccess_Call {
return &GcloudIamClient_RevokeServiceAccountAccess_Call{Call: _e.mock.On("RevokeServiceAccountAccess", ctx, sa, accountType, accountID, role)}
}
func (_c *GcloudIamClient_RevokeServiceAccountAccess_Call) Run(run func(ctx context.Context, sa string, accountType string, accountID string, role string)) *GcloudIamClient_RevokeServiceAccountAccess_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(string), args[4].(string))
})
return _c
}
func (_c *GcloudIamClient_RevokeServiceAccountAccess_Call) Return(_a0 error) *GcloudIamClient_RevokeServiceAccountAccess_Call {
_c.Call.Return(_a0)
return _c
}
func (_c *GcloudIamClient_RevokeServiceAccountAccess_Call) RunAndReturn(run func(context.Context, string, string, string, string) error) *GcloudIamClient_RevokeServiceAccountAccess_Call {
_c.Call.Return(run)
return _c
}
// NewGcloudIamClient creates a new instance of GcloudIamClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
// The first argument is typically a *testing.T value.
func NewGcloudIamClient(t interface {
mock.TestingT
Cleanup(func())
}) *GcloudIamClient {
mock := &GcloudIamClient{}
mock.Mock.Test(t)
t.Cleanup(func() { mock.AssertExpectations(t) })
return mock
}