This repository has been archived by the owner on Jan 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 560
/
mockclients.go
631 lines (556 loc) · 21.2 KB
/
mockclients.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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
package armhelpers
import (
"bytes"
"errors"
"fmt"
"io/ioutil"
"net/http"
"time"
"github.com/Azure/azure-sdk-for-go/arm/authorization"
"github.com/Azure/azure-sdk-for-go/arm/compute"
"github.com/Azure/azure-sdk-for-go/arm/disk"
"github.com/Azure/azure-sdk-for-go/arm/graphrbac"
"github.com/Azure/azure-sdk-for-go/arm/resources/resources"
"github.com/Azure/go-autorest/autorest"
log "github.com/sirupsen/logrus"
"k8s.io/api/core/v1"
)
//MockACSEngineClient is an implementation of ACSEngineClient where all requests error out
type MockACSEngineClient struct {
FailDeployTemplate bool
FailDeployTemplateQuota bool
FailDeployTemplateConflict bool
FailDeployTemplateWithProperties bool
FailEnsureResourceGroup bool
FailListVirtualMachines bool
FailListVirtualMachineScaleSets bool
FailGetVirtualMachine bool
FailDeleteVirtualMachine bool
FailDeleteVirtualMachineScaleSetVM bool
FailSetVirtualMachineScaleSetCapacity bool
FailListVirtualMachineScaleSetVMs bool
FailGetStorageClient bool
FailDeleteNetworkInterface bool
FailGetKubernetesClient bool
FailListProviders bool
ShouldSupportVMIdentity bool
FailDeleteRoleAssignment bool
MockKubernetesClient *MockKubernetesClient
}
//MockStorageClient mock implementation of StorageClient
type MockStorageClient struct{}
//MockKubernetesClient mock implementation of KubernetesClient
type MockKubernetesClient struct {
FailListPods bool
FailGetNode bool
UpdateNodeFunc func(*v1.Node) (*v1.Node, error)
FailUpdateNode bool
FailDeleteNode bool
FailSupportEviction bool
FailDeletePod bool
FailEvictPod bool
FailWaitForDelete bool
ShouldSupportEviction bool
PodsList *v1.PodList
}
//ListPods returns all Pods running on the passed in node
func (mkc *MockKubernetesClient) ListPods(node *v1.Node) (*v1.PodList, error) {
if mkc.FailListPods {
return nil, errors.New("ListPods failed")
}
if mkc.PodsList != nil {
return mkc.PodsList, nil
}
return &v1.PodList{}, nil
}
//GetNode returns details about node with passed in name
func (mkc *MockKubernetesClient) GetNode(name string) (*v1.Node, error) {
if mkc.FailGetNode {
return nil, errors.New("GetNode failed")
}
node := &v1.Node{}
node.Status.Conditions = append(node.Status.Conditions, v1.NodeCondition{Type: v1.NodeReady, Status: v1.ConditionTrue})
return node, nil
}
//UpdateNode updates the node in the api server with the passed in info
func (mkc *MockKubernetesClient) UpdateNode(node *v1.Node) (*v1.Node, error) {
if mkc.UpdateNodeFunc != nil {
return mkc.UpdateNodeFunc(node)
}
if mkc.FailUpdateNode {
return nil, errors.New("UpdateNode failed")
}
return node, nil
}
//DeleteNode deregisters node in the api server
func (mkc *MockKubernetesClient) DeleteNode(name string) error {
if mkc.FailDeleteNode {
return errors.New("DeleteNode failed")
}
return nil
}
//SupportEviction queries the api server to discover if it supports eviction, and returns supported type if it is supported
func (mkc *MockKubernetesClient) SupportEviction() (string, error) {
if mkc.FailSupportEviction {
return "", errors.New("SupportEviction failed")
}
if mkc.ShouldSupportEviction {
return "version", nil
}
return "", nil
}
//DeletePod deletes the passed in pod
func (mkc *MockKubernetesClient) DeletePod(pod *v1.Pod) error {
if mkc.FailDeletePod {
return errors.New("DeletePod failed")
}
return nil
}
//EvictPod evicts the passed in pod using the passed in api version
func (mkc *MockKubernetesClient) EvictPod(pod *v1.Pod, policyGroupVersion string) error {
if mkc.FailEvictPod {
return errors.New("EvictPod failed")
}
return nil
}
//WaitForDelete waits until all pods are deleted. Returns all pods not deleted and an error on failure
func (mkc *MockKubernetesClient) WaitForDelete(logger *log.Entry, pods []v1.Pod, usingEviction bool) ([]v1.Pod, error) {
if mkc.FailWaitForDelete {
return nil, errors.New("WaitForDelete failed")
}
return []v1.Pod{}, nil
}
//DeleteBlob mock
func (msc *MockStorageClient) DeleteBlob(container, blob string) error {
return nil
}
//AddAcceptLanguages mock
func (mc *MockACSEngineClient) AddAcceptLanguages(languages []string) {}
//DeployTemplate mock
func (mc *MockACSEngineClient) DeployTemplate(resourceGroup, name string, template, parameters map[string]interface{}, cancel <-chan struct{}) (*resources.DeploymentExtended, error) {
switch {
case mc.FailDeployTemplate:
return nil, errors.New("DeployTemplate failed")
case mc.FailDeployTemplateQuota:
errmsg := `resources.DeploymentsClient#CreateOrUpdate: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error.`
resp := `{
"error":{
"code":"InvalidTemplateDeployment",
"message":"The template deployment is not valid according to the validation procedure. The tracking id is 'b5bd7d6b-fddf-4ec3-a3b0-ce285a48bd31'. See inner errors for details. Please see https://aka.ms/arm-deploy for usage details.",
"details":[{
"code":"QuotaExceeded",
"message":"Operation results in exceeding quota limits of Core. Maximum allowed: 10, Current in use: 10, Additional requested: 2. Please read more about quota increase at http://aka.ms/corequotaincrease."
}]}}`
return &resources.DeploymentExtended{
Response: autorest.Response{
Response: &http.Response{
Status: "400 Bad Request",
StatusCode: 400,
Body: ioutil.NopCloser(bytes.NewReader([]byte(resp))),
}}},
errors.New(errmsg)
case mc.FailDeployTemplateConflict:
errmsg := `resources.DeploymentsClient#CreateOrUpdate: Failure sending request: StatusCode=200 -- Original Error: Long running operation terminated with status 'Failed': Code="DeploymentFailed" Message="At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug for usage details.`
resp := `{
"status":"Failed",
"error":{
"code":"DeploymentFailed",
"message":"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug for usage details.",
"details":[{
"code":"Conflict",
"message":"{\r\n \"error\": {\r\n \"code\": \"PropertyChangeNotAllowed\",\r\n \"target\": \"dataDisk.createOption\",\r\n \"message\": \"Changing property 'dataDisk.createOption' is not allowed.\"\r\n }\r\n}"
}]}}`
return &resources.DeploymentExtended{
Response: autorest.Response{
Response: &http.Response{
Status: "200 OK",
StatusCode: 200,
Body: ioutil.NopCloser(bytes.NewReader([]byte(resp))),
}}},
errors.New(errmsg)
case mc.FailDeployTemplateWithProperties:
errmsg := `resources.DeploymentsClient#CreateOrUpdate: Failure sending request: StatusCode=200 -- Original Error: Long running operation terminated with status 'Failed': Code="DeploymentFailed" Message="At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug for usage details.`
resp := `{
"status":"Failed",
"error":{
"code":"DeploymentFailed",
"message":"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug for usage details.",
"details":[{
"code":"Conflict",
"message":"{\r\n \"error\": {\r\n \"code\": \"PropertyChangeNotAllowed\",\r\n \"target\": \"dataDisk.createOption\",\r\n \"message\": \"Changing property 'dataDisk.createOption' is not allowed.\"\r\n }\r\n}"
}]}}`
provisioningState := "Failed"
return &resources.DeploymentExtended{
Response: autorest.Response{
Response: &http.Response{
Status: "200 OK",
StatusCode: 200,
Body: ioutil.NopCloser(bytes.NewReader([]byte(resp))),
}},
Properties: &resources.DeploymentPropertiesExtended{
ProvisioningState: &provisioningState,
}},
errors.New(errmsg)
default:
return nil, nil
}
}
//EnsureResourceGroup mock
func (mc *MockACSEngineClient) EnsureResourceGroup(resourceGroup, location string, managedBy *string) (*resources.Group, error) {
if mc.FailEnsureResourceGroup {
return nil, errors.New("EnsureResourceGroup failed")
}
return nil, nil
}
//ListVirtualMachines mock
func (mc *MockACSEngineClient) ListVirtualMachines(resourceGroup string) (compute.VirtualMachineListResult, error) {
if mc.FailListVirtualMachines {
return compute.VirtualMachineListResult{}, errors.New("ListVirtualMachines failed")
}
vm1Name := "k8s-agentpool1-12345678-0"
creationSourceString := "creationSource"
orchestratorString := "orchestrator"
resourceNameSuffixString := "resourceNameSuffix"
poolnameString := "poolName"
creationSource := "acsengine-k8s-agentpool1-12345678-0"
orchestrator := "Kubernetes:1.6.9"
resourceNameSuffix := "12345678"
poolname := "agentpool1"
tags := map[string]*string{
creationSourceString: &creationSource,
orchestratorString: &orchestrator,
resourceNameSuffixString: &resourceNameSuffix,
poolnameString: &poolname,
}
vm1 := compute.VirtualMachine{
Name: &vm1Name,
Tags: &tags,
VirtualMachineProperties: &compute.VirtualMachineProperties{
StorageProfile: &compute.StorageProfile{
OsDisk: &compute.OSDisk{
Vhd: &compute.VirtualHardDisk{
URI: &validOSDiskResourceName},
},
},
NetworkProfile: &compute.NetworkProfile{
NetworkInterfaces: &[]compute.NetworkInterfaceReference{
{
ID: &validNicResourceName,
},
},
},
},
}
vmr := compute.VirtualMachineListResult{}
vmr.Value = &[]compute.VirtualMachine{vm1}
return vmr, nil
}
//ListVirtualMachineScaleSets mock
func (mc *MockACSEngineClient) ListVirtualMachineScaleSets(resourceGroup string) (compute.VirtualMachineScaleSetListResult, error) {
if mc.FailListVirtualMachineScaleSets {
return compute.VirtualMachineScaleSetListResult{}, errors.New("ListVirtualMachines failed")
}
return compute.VirtualMachineScaleSetListResult{}, nil
}
//GetVirtualMachine mock
func (mc *MockACSEngineClient) GetVirtualMachine(resourceGroup, name string) (compute.VirtualMachine, error) {
if mc.FailGetVirtualMachine {
return compute.VirtualMachine{}, errors.New("GetVirtualMachine failed")
}
vm1Name := "k8s-agentpool1-12345678-0"
creationSourceString := "creationSource"
orchestratorString := "orchestrator"
resourceNameSuffixString := "resourceNameSuffix"
poolnameString := "poolName"
creationSource := "acsengine-k8s-agentpool1-12345678-0"
orchestrator := "Kubernetes:1.6.9"
resourceNameSuffix := "12345678"
poolname := "agentpool1"
principalID := "00000000-1111-2222-3333-444444444444"
tags := map[string]*string{
creationSourceString: &creationSource,
orchestratorString: &orchestrator,
resourceNameSuffixString: &resourceNameSuffix,
poolnameString: &poolname,
}
var vmIdentity *compute.VirtualMachineIdentity
if mc.ShouldSupportVMIdentity {
vmIdentity = &compute.VirtualMachineIdentity{PrincipalID: &principalID}
}
return compute.VirtualMachine{
Name: &vm1Name,
Tags: &tags,
Identity: vmIdentity,
VirtualMachineProperties: &compute.VirtualMachineProperties{
StorageProfile: &compute.StorageProfile{
OsDisk: &compute.OSDisk{
Vhd: &compute.VirtualHardDisk{
URI: &validOSDiskResourceName},
},
},
NetworkProfile: &compute.NetworkProfile{
NetworkInterfaces: &[]compute.NetworkInterfaceReference{
{
ID: &validNicResourceName,
},
},
},
},
}, nil
}
//DeleteVirtualMachine mock
func (mc *MockACSEngineClient) DeleteVirtualMachine(resourceGroup, name string, cancel <-chan struct{}) (<-chan compute.OperationStatusResponse, <-chan error) {
if mc.FailDeleteVirtualMachine {
errChan := make(chan error)
respChan := make(chan compute.OperationStatusResponse)
go func() {
defer func() {
close(errChan)
}()
defer func() {
close(respChan)
}()
errChan <- errors.New("DeleteVirtualMachine failed")
}()
return respChan, errChan
}
errChan := make(chan error)
respChan := make(chan compute.OperationStatusResponse)
go func() {
defer func() {
close(errChan)
}()
defer func() {
close(respChan)
}()
errChan <- nil
respChan <- compute.OperationStatusResponse{}
}()
return respChan, errChan
}
//DeleteVirtualMachineScaleSetVM mock
func (mc *MockACSEngineClient) DeleteVirtualMachineScaleSetVM(resourceGroup, virtualMachineScaleSet, instanceID string, cancel <-chan struct{}) (<-chan compute.OperationStatusResponse, <-chan error) {
if mc.FailDeleteVirtualMachineScaleSetVM {
errChan := make(chan error)
respChan := make(chan compute.OperationStatusResponse)
go func() {
defer func() {
close(errChan)
}()
defer func() {
close(respChan)
}()
errChan <- errors.New("DeleteVirtualMachineScaleSetVM failed")
}()
return respChan, errChan
}
errChan := make(chan error)
respChan := make(chan compute.OperationStatusResponse)
go func() {
defer func() {
close(errChan)
}()
defer func() {
close(respChan)
}()
errChan <- nil
respChan <- compute.OperationStatusResponse{}
}()
return respChan, errChan
}
//SetVirtualMachineScaleSetCapacity mock
func (mc *MockACSEngineClient) SetVirtualMachineScaleSetCapacity(resourceGroup, virtualMachineScaleSet string, sku compute.Sku, location string, cancel <-chan struct{}) (<-chan compute.VirtualMachineScaleSet, <-chan error) {
if mc.FailSetVirtualMachineScaleSetCapacity {
errChan := make(chan error)
respChan := make(chan compute.VirtualMachineScaleSet)
go func() {
defer func() {
close(errChan)
}()
defer func() {
close(respChan)
}()
errChan <- errors.New("SetVirtualMachineScaleSetCapacity failed")
}()
return respChan, errChan
}
errChan := make(chan error)
respChan := make(chan compute.VirtualMachineScaleSet)
go func() {
defer func() {
close(errChan)
}()
defer func() {
close(respChan)
}()
errChan <- nil
respChan <- compute.VirtualMachineScaleSet{}
}()
return respChan, errChan
}
//ListVirtualMachineScaleSetVMs mock
func (mc *MockACSEngineClient) ListVirtualMachineScaleSetVMs(resourceGroup, virtualMachineScaleSet string) (compute.VirtualMachineScaleSetVMListResult, error) {
if mc.FailDeleteVirtualMachineScaleSetVM {
return compute.VirtualMachineScaleSetVMListResult{}, errors.New("DeleteVirtualMachineScaleSetVM failed")
}
return compute.VirtualMachineScaleSetVMListResult{}, nil
}
//GetStorageClient mock
func (mc *MockACSEngineClient) GetStorageClient(resourceGroup, accountName string) (ACSStorageClient, error) {
if mc.FailGetStorageClient {
return nil, errors.New("GetStorageClient failed")
}
return &MockStorageClient{}, nil
}
//DeleteNetworkInterface mock
func (mc *MockACSEngineClient) DeleteNetworkInterface(resourceGroup, nicName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) {
if mc.FailDeleteNetworkInterface {
errChan := make(chan error)
respChan := make(chan autorest.Response)
go func() {
defer func() {
close(errChan)
}()
defer func() {
close(respChan)
}()
errChan <- errors.New("DeleteNetworkInterface failed")
}()
return respChan, errChan
}
errChan := make(chan error)
respChan := make(chan autorest.Response)
go func() {
defer func() {
close(errChan)
}()
defer func() {
close(respChan)
}()
errChan <- nil
respChan <- autorest.Response{}
}()
return respChan, errChan
}
var validOSDiskResourceName = "https://00k71r4u927seqiagnt0.blob.core.windows.net/osdisk/k8s-agentpool1-12345678-0-osdisk.vhd"
var validNicResourceName = "/subscriptions/DEC923E3-1EF1-4745-9516-37906D56DEC4/resourceGroups/acsK8sTest/providers/Microsoft.Network/networkInterfaces/k8s-agent-12345678-nic-0"
// Active Directory
// Mocks
// Graph Mocks
// CreateGraphApplication creates an application via the graphrbac client
func (mc *MockACSEngineClient) CreateGraphApplication(applicationCreateParameters graphrbac.ApplicationCreateParameters) (graphrbac.Application, error) {
return graphrbac.Application{}, nil
}
// CreateGraphPrincipal creates a service principal via the graphrbac client
func (mc *MockACSEngineClient) CreateGraphPrincipal(servicePrincipalCreateParameters graphrbac.ServicePrincipalCreateParameters) (graphrbac.ServicePrincipal, error) {
return graphrbac.ServicePrincipal{}, nil
}
// CreateApp is a simpler method for creating an application
func (mc *MockACSEngineClient) CreateApp(applicationName, applicationURL string, replyURLs *[]string, requiredResourceAccess *[]graphrbac.RequiredResourceAccess) (applicationID, servicePrincipalObjectID, secret string, err error) {
return "app-id", "client-id", "client-secret", nil
}
// RBAC Mocks
// CreateRoleAssignment creates a role assignment via the authorization client
func (mc *MockACSEngineClient) CreateRoleAssignment(scope string, roleAssignmentName string, parameters authorization.RoleAssignmentCreateParameters) (authorization.RoleAssignment, error) {
return authorization.RoleAssignment{}, nil
}
// CreateRoleAssignmentSimple is a wrapper around RoleAssignmentsClient.Create
func (mc *MockACSEngineClient) CreateRoleAssignmentSimple(applicationID, roleID string) error {
return nil
}
// DeleteManagedDisk is a wrapper around disksClient.Delete
func (mc *MockACSEngineClient) DeleteManagedDisk(resourceGroupName string, diskName string, cancel <-chan struct{}) (<-chan disk.OperationStatusResponse, <-chan error) {
errChan := make(chan error)
respChan := make(chan disk.OperationStatusResponse)
go func() {
defer func() {
close(errChan)
}()
defer func() {
close(respChan)
}()
errChan <- nil
respChan <- disk.OperationStatusResponse{}
}()
return respChan, errChan
}
// ListManagedDisksByResourceGroup is a wrapper around disksClient.ListManagedDisksByResourceGroup
func (mc *MockACSEngineClient) ListManagedDisksByResourceGroup(resourceGroupName string) (result disk.ListType, err error) {
return disk.ListType{}, nil
}
//GetKubernetesClient mock
func (mc *MockACSEngineClient) GetKubernetesClient(masterURL, kubeConfig string, interval, timeout time.Duration) (KubernetesClient, error) {
if mc.FailGetKubernetesClient {
return nil, errors.New("GetKubernetesClient failed")
}
if mc.MockKubernetesClient == nil {
mc.MockKubernetesClient = &MockKubernetesClient{}
}
return mc.MockKubernetesClient, nil
}
// ListProviders mock
func (mc *MockACSEngineClient) ListProviders() (resources.ProviderListResult, error) {
if mc.FailListProviders {
return resources.ProviderListResult{}, errors.New("ListProviders failed")
}
return resources.ProviderListResult{}, nil
}
// ListDeploymentOperations gets all deployments operations for a deployment.
func (mc *MockACSEngineClient) ListDeploymentOperations(resourceGroupName string, deploymentName string, top *int32) (result resources.DeploymentOperationsListResult, err error) {
resp := `{
"properties": {
"provisioningState":"Failed",
"correlationId":"d5062e45-6e9f-4fd3-a0a0-6b2c56b15757",
"error":{
"code":"DeploymentFailed","message":"At least one resource deployment operation failed. Please list deployment operations for details. Please see http://aka.ms/arm-debug for usage details.",
"details":[{"code":"Conflict","message":"{\r\n \"error\": {\r\n \"message\": \"Conflict\",\r\n \"code\": \"Conflict\"\r\n }\r\n}"}]
}
}
}`
provisioningState := "Failed"
id := "00000000"
operationID := "d5062e45-6e9f-4fd3-a0a0-6b2c56b15757"
nextLink := fmt.Sprintf("https://management.azure.com/subscriptions/11111/resourcegroups/%s/deployments/%s/operations?$top=%s&api-version=2018-02-01", resourceGroupName, deploymentName, "5")
return resources.DeploymentOperationsListResult{
Response: autorest.Response{
Response: &http.Response{
Status: "200 OK",
StatusCode: 200,
Body: ioutil.NopCloser(bytes.NewReader([]byte(resp))),
},
},
Value: &[]resources.DeploymentOperation{
{
ID: &id,
OperationID: &operationID,
Properties: &resources.DeploymentOperationProperties{
ProvisioningState: &provisioningState,
},
},
},
NextLink: &nextLink,
}, nil
}
// ListDeploymentOperationsNextResults retrieves the next set of results, if any.
func (mc *MockACSEngineClient) ListDeploymentOperationsNextResults(lastResults resources.DeploymentOperationsListResult) (result resources.DeploymentOperationsListResult, err error) {
return resources.DeploymentOperationsListResult{}, nil
}
// DeleteRoleAssignmentByID deletes a roleAssignment via its unique identifier
func (mc *MockACSEngineClient) DeleteRoleAssignmentByID(roleAssignmentID string) (authorization.RoleAssignment, error) {
if mc.FailDeleteRoleAssignment {
return authorization.RoleAssignment{}, errors.New("DeleteRoleAssignmentByID failed")
}
return authorization.RoleAssignment{}, nil
}
// ListRoleAssignmentsForPrincipal (e.g. a VM) via the scope and the unique identifier of the principal
func (mc *MockACSEngineClient) ListRoleAssignmentsForPrincipal(scope string, principalID string) (authorization.RoleAssignmentListResult, error) {
roleAssignments := []authorization.RoleAssignment{}
if mc.ShouldSupportVMIdentity {
var assignmentID = "role-assignment-id"
var assignment = authorization.RoleAssignment{
ID: &assignmentID}
roleAssignments = append(roleAssignments, assignment)
}
return authorization.RoleAssignmentListResult{
Value: &roleAssignments}, nil
}