forked from juju/juju-gui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-credentials.js
715 lines (693 loc) · 27.1 KB
/
test-credentials.js
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
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
/*
This file is part of the Juju GUI, which lets users view and manage Juju
environments within a graphical interface (https://launchpad.net/juju-gui).
Copyright (C) 2015 Canonical Ltd.
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU Affero General Public License version 3, as published by
the Free Software Foundation.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
General Public License for more details.
You should have received a copy of the GNU Affero General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>.
*/
'use strict';
var juju = {components: {}}; // eslint-disable-line no-unused-vars
describe('AccountCredentials', () => {
let acl, controllerIsReady, getCloudCredentialNames, getCloudProviderDetails,
listClouds;
beforeAll((done) => {
// By loading this file it adds the component to the juju components.
YUI().use('account-credentials', () => { done(); });
});
beforeEach(() => {
acl = {isReadOnly: sinon.stub().returns(false)};
controllerIsReady = sinon.stub().withArgs().returns(true);
getCloudProviderDetails = sinon.stub();
getCloudProviderDetails.withArgs('aws').returns({title: 'Amazon'});
getCloudProviderDetails.withArgs('gce').returns({title: 'Google'});
listClouds = sinon.stub().callsArgWith(0, null, {
aws: 'aws',
gce: 'gce'
});
getCloudCredentialNames = sinon.stub().callsArgWith(1, null, [{
names: ['aws_spinach@external_test1'],
displayNames: ['test1']
}, {
names: ['gce_spinach@external_test2'],
displayNames: ['test2']
}]);
});
it('can display a spinner when loading credentials', () => {
getCloudCredentialNames = sinon.stub();
const component = jsTestUtils.shallowRender(
<juju.components.AccountCredentials
acl={acl}
addNotification={sinon.stub()}
controllerIsReady={controllerIsReady}
generateCloudCredentialName={sinon.stub()}
getCloudCredentialNames={getCloudCredentialNames}
getCloudProviderDetails={getCloudProviderDetails}
listClouds={listClouds}
revokeCloudCredential={sinon.stub()}
sendAnalytics={sinon.stub()}
updateCloudCredential={sinon.stub()}
username="spinach@external"
validateForm={sinon.stub()} />, true);
const instance = component.getMountedInstance();
const output = component.getRenderOutput();
const expected = (
<div className="account__section account__credentials twelve-col">
<div className="user-profile__header twelve-col no-margin-bottom">
<div className="left">
Cloud credentials
</div>
<div className="right">
<juju.components.GenericButton
action={instance._toggleAdd}
type="inline-neutral"
title="Add" />
</div>
</div>
<juju.components.ExpandingRow
classes={{'twelve-col': true}}
clickable={false}
expanded={false}>
<div></div>
<div className="twelve-col">
{null}
</div>
</juju.components.ExpandingRow>
<juju.components.Spinner />
</div>);
expect(output).toEqualJSX(expected);
});
it('does not allow for adding/removing credentials on local cloud', () => {
listClouds = sinon.stub().callsArgWith(0, null, {localhost: {}});
getCloudCredentialNames = sinon.stub().callsArgWith(1, null, [{
names: ['localhost_admin'],
displayNames: ['localcred']
}]);
const component = jsTestUtils.shallowRender(
<juju.components.AccountCredentials
acl={acl}
addNotification={sinon.stub()}
controllerIsReady={controllerIsReady}
generateCloudCredentialName={sinon.stub()}
getCloudCredentialNames={getCloudCredentialNames}
getCloudProviderDetails={getCloudProviderDetails}
listClouds={listClouds}
revokeCloudCredential={sinon.stub()}
sendAnalytics={sinon.stub()}
updateCloudCredential={sinon.stub()}
username="spinach@external"
validateForm={sinon.stub()} />, true);
const output = component.getRenderOutput();
const credentials = output.props.children[2].props.children[1];
const expectedOutput = (
<div className="account__section account__credentials twelve-col">
<div className="user-profile__header twelve-col no-margin-bottom">
<div className="left">
Cloud credentials
</div>
<div className="right" />
</div>
<juju.components.ExpandingRow
classes={{'twelve-col': true}}
clickable={false}
expanded={false}>
<div></div>
<div className="twelve-col">
{null}
</div>
</juju.components.ExpandingRow>
<ul className="user-profile__list twelve-col">
<li className="user-profile__list-header twelve-col">
<span className="six-col user-profile__list-col">
Name
</span>
<span className="six-col last-col user-profile__list-col">
Provider
</span>
</li>
{[
<li className="user-profile__list-row twelve-col"
key="aws_spinach@external_test1">
<span className="six-col user-profile__list-col">
localcred
</span>
<span className="four-col user-profile__list-col">
localhost
</span>
<span className="two-col last-col user-profile__list-col
no-margin-bottom">
<juju.components.GenericButton
action={
credentials[0].props.children[2].props.children
.props.action}
disabled={true}
type="neutral"
title="Remove" />
</span>
</li>
]}
</ul>
</div>);
expect(output).toEqualJSX(expectedOutput);
});
it('can render', () => {
const component = jsTestUtils.shallowRender(
<juju.components.AccountCredentials
acl={acl}
addNotification={sinon.stub()}
controllerIsReady={controllerIsReady}
generateCloudCredentialName={sinon.stub()}
getCloudCredentialNames={getCloudCredentialNames}
getCloudProviderDetails={getCloudProviderDetails}
listClouds={listClouds}
revokeCloudCredential={sinon.stub()}
sendAnalytics={sinon.stub()}
updateCloudCredential={sinon.stub()}
username="spinach@external"
validateForm={sinon.stub()} />, true);
const instance = component.getMountedInstance();
const output = component.getRenderOutput();
const credentials = output.props.children[2].props.children[1];
const expected = (
<div className="account__section account__credentials twelve-col">
<div className="user-profile__header twelve-col no-margin-bottom">
<div className="left">
Cloud credentials
</div>
<div className="right">
<juju.components.GenericButton
action={instance._toggleAdd}
type="inline-neutral"
title="Add" />
</div>
</div>
<juju.components.ExpandingRow
classes={{'twelve-col': true}}
clickable={false}
expanded={false}>
<div></div>
<div className="twelve-col">
{null}
</div>
</juju.components.ExpandingRow>
<ul className="user-profile__list twelve-col">
<li className="user-profile__list-header twelve-col">
<span className="six-col user-profile__list-col">
Name
</span>
<span className="six-col last-col user-profile__list-col">
Provider
</span>
</li>
{[
<li className="user-profile__list-row twelve-col"
key="aws_spinach@external_test1">
<span className="six-col user-profile__list-col">
test1
</span>
<span className="four-col user-profile__list-col">
Amazon
</span>
<span className="two-col last-col user-profile__list-col
no-margin-bottom">
<juju.components.GenericButton
action={
credentials[0].props.children[2].props.children
.props.action}
disabled={false}
type="neutral"
title="Remove" />
</span>
</li>,
<li className="user-profile__list-row twelve-col"
key="gce_spinach@external_test2">
<span className="six-col user-profile__list-col">
test2
</span>
<span className="four-col user-profile__list-col">
Google
</span>
<span className="two-col last-col user-profile__list-col
no-margin-bottom">
<juju.components.GenericButton
action={
credentials[1].props.children[2].props.children
.props.action}
disabled={false}
type="neutral"
title="Remove" />
</span>
</li>]}
</ul>
</div>);
expect(output).toEqualJSX(expected);
});
it('can render when there are no credentials', () => {
getCloudCredentialNames = sinon.stub().callsArgWith(1, null, []);
const component = jsTestUtils.shallowRender(
<juju.components.AccountCredentials
acl={acl}
addNotification={sinon.stub()}
controllerIsReady={controllerIsReady}
generateCloudCredentialName={sinon.stub()}
getCloudCredentialNames={getCloudCredentialNames}
getCloudProviderDetails={getCloudProviderDetails}
listClouds={listClouds}
revokeCloudCredential={sinon.stub()}
sendAnalytics={sinon.stub()}
updateCloudCredential={sinon.stub()}
username="spinach@external"
validateForm={sinon.stub()} />, true);
const instance = component.getMountedInstance();
const output = component.getRenderOutput();
const expected = (
<div className="account__section account__credentials twelve-col">
<div className="user-profile__header twelve-col no-margin-bottom">
<div className="left">
Cloud credentials
</div>
<div className="right">
<juju.components.GenericButton
action={instance._toggleAdd}
type="inline-neutral"
title="Add" />
</div>
</div>
<juju.components.ExpandingRow
classes={{'twelve-col': true}}
clickable={false}
expanded={false}>
<div></div>
<div className="twelve-col">
{null}
</div>
</juju.components.ExpandingRow>
<div>
No credentials available.
</div>
</div>);
expect(output).toEqualJSX(expected);
});
it('can display errors when getting clouds', () => {
const addNotification = sinon.stub();
listClouds.callsArgWith(0, 'Uh oh!', null);
jsTestUtils.shallowRender(
<juju.components.AccountCredentials
acl={acl}
addNotification={addNotification}
controllerIsReady={controllerIsReady}
generateCloudCredentialName={sinon.stub()}
getCloudCredentialNames={getCloudCredentialNames}
getCloudProviderDetails={getCloudProviderDetails}
listClouds={listClouds}
revokeCloudCredential={sinon.stub()}
sendAnalytics={sinon.stub()}
updateCloudCredential={sinon.stub()}
username="spinach@external"
validateForm={sinon.stub()} />);
assert.equal(addNotification.callCount, 1);
assert.deepEqual(addNotification.args[0][0], {
title: 'Unable to list clouds',
message: 'Unable to list clouds: Uh oh!',
level: 'error'
});
});
it('can display errors when getting credential names', () => {
const addNotification = sinon.stub();
getCloudCredentialNames = sinon.stub().callsArgWith(
1, 'Uh oh!', null);
jsTestUtils.shallowRender(
<juju.components.AccountCredentials
acl={acl}
addNotification={addNotification}
controllerIsReady={controllerIsReady}
generateCloudCredentialName={sinon.stub()}
getCloudCredentialNames={getCloudCredentialNames}
getCloudProviderDetails={getCloudProviderDetails}
listClouds={listClouds}
revokeCloudCredential={sinon.stub()}
sendAnalytics={sinon.stub()}
updateCloudCredential={sinon.stub()}
username="spinach@external"
validateForm={sinon.stub()} />);
assert.equal(addNotification.callCount, 1);
assert.deepEqual(addNotification.args[0][0], {
title: 'Unable to get names for credentials',
message: 'Unable to get names for credentials: Uh oh!',
level: 'error'
});
});
it('can display a remove credentials confirmation', () => {
const revokeCloudCredential = sinon.stub();
const component = jsTestUtils.shallowRender(
<juju.components.AccountCredentials
acl={acl}
addNotification={sinon.stub()}
controllerIsReady={controllerIsReady}
generateCloudCredentialName={sinon.stub()}
getCloudCredentialNames={getCloudCredentialNames}
getCloudProviderDetails={getCloudProviderDetails}
listClouds={listClouds}
revokeCloudCredential={revokeCloudCredential}
sendAnalytics={sinon.stub()}
updateCloudCredential={sinon.stub()}
username="spinach@external"
validateForm={sinon.stub()} />, true);
const instance = component.getMountedInstance();
let output = component.getRenderOutput();
output.props.children[2].props.children[1][0].props
.children[2].props.children.props.action();
output = component.getRenderOutput();
const expected = (
<window.juju.components.Popup
buttons={[{
title: 'Cancel',
action: instance._handleDeleteCredential,
type: 'inline-neutral'
}, {
title: 'Continue',
action: instance._deleteCredential,
type: 'destructive'
}]}
title="Remove credentials">
<p>
Are you sure you want to remove these credentials?
</p>
</window.juju.components.Popup>);
expect(output.props.children[3]).toEqualJSX(expected);
});
it('can remove credentials', () => {
const revokeCloudCredential = sinon.stub();
const component = jsTestUtils.shallowRender(
<juju.components.AccountCredentials
acl={acl}
addNotification={sinon.stub()}
controllerIsReady={controllerIsReady}
generateCloudCredentialName={sinon.stub()}
getCloudCredentialNames={getCloudCredentialNames}
getCloudProviderDetails={getCloudProviderDetails}
listClouds={listClouds}
revokeCloudCredential={revokeCloudCredential}
sendAnalytics={sinon.stub()}
updateCloudCredential={sinon.stub()}
username="spinach@external"
validateForm={sinon.stub()} />, true);
let output = component.getRenderOutput();
output.props.children[2].props.children[1][0].props
.children[2].props.children.props.action();
output = component.getRenderOutput();
output.props.children[3].props.buttons[1].action();
assert.equal(revokeCloudCredential.callCount, 1);
assert.equal(
revokeCloudCredential.args[0][0], 'aws_spinach@external_test1');
});
it('can display errors when deleting credentials', () => {
const addNotification = sinon.stub();
const revokeCloudCredential = sinon.stub().callsArgWith(1, 'Uh oh!');
const component = jsTestUtils.shallowRender(
<juju.components.AccountCredentials
acl={acl}
addNotification={addNotification}
controllerIsReady={controllerIsReady}
generateCloudCredentialName={sinon.stub()}
getCloudCredentialNames={getCloudCredentialNames}
getCloudProviderDetails={getCloudProviderDetails}
listClouds={listClouds}
revokeCloudCredential={revokeCloudCredential}
sendAnalytics={sinon.stub()}
updateCloudCredential={sinon.stub()}
username="spinach@external"
validateForm={sinon.stub()} />, true);
let output = component.getRenderOutput();
output.props.children[2].props.children[1][0].props
.children[2].props.children.props.action();
output = component.getRenderOutput();
output.props.children[3].props.buttons[1].action();
assert.equal(addNotification.callCount, 1);
assert.deepEqual(addNotification.args[0][0], {
title: 'Unable to revoke the cloud credential',
message: 'Unable to revoke the cloud credential: Uh oh!',
level: 'error'
});
});
it('removes the credential from the list', () => {
const revokeCloudCredential = sinon.stub().callsArgWith(1, null);
const component = jsTestUtils.shallowRender(
<juju.components.AccountCredentials
acl={acl}
addNotification={sinon.stub()}
controllerIsReady={controllerIsReady}
generateCloudCredentialName={sinon.stub()}
getCloudCredentialNames={getCloudCredentialNames}
getCloudProviderDetails={getCloudProviderDetails}
listClouds={listClouds}
revokeCloudCredential={revokeCloudCredential}
sendAnalytics={sinon.stub()}
updateCloudCredential={sinon.stub()}
username="spinach@external"
validateForm={sinon.stub()} />, true);
const instance = component.getMountedInstance();
let output = component.getRenderOutput();
let credentials = output.props.children[2].props.children[1];
credentials[0].props.children[2].props.children.props.action();
output = component.getRenderOutput();
output.props.children[3].props.buttons[1].action();
output = component.getRenderOutput();
credentials = output.props.children[2].props.children[1];
const expected = (
<div className="account__section account__credentials twelve-col">
<div className="user-profile__header twelve-col no-margin-bottom">
<div className="left">
Cloud credentials
</div>
<div className="right">
<juju.components.GenericButton
action={instance._toggleAdd}
type="inline-neutral"
title="Add" />
</div>
</div>
<juju.components.ExpandingRow
classes={{'twelve-col': true}}
clickable={false}
expanded={false}>
<div></div>
<div className="twelve-col">
{null}
</div>
</juju.components.ExpandingRow>
<ul className="user-profile__list twelve-col">
<li className="user-profile__list-header twelve-col">
<span className="six-col user-profile__list-col">
Name
</span>
<span className="six-col last-col user-profile__list-col">
Provider
</span>
</li>
{[<li className="user-profile__list-row twelve-col"
key="gce_spinach@external_test2">
<span className="six-col user-profile__list-col">
test2
</span>
<span className="four-col user-profile__list-col">
Google
</span>
<span className="two-col last-col user-profile__list-col
no-margin-bottom">
<juju.components.GenericButton
action={
credentials[0].props.children[2].props.children
.props.action}
disabled={false}
type="neutral"
title="Remove" />
</span>
</li>]}
</ul>
</div>);
expect(output).toEqualJSX(expected);
});
it('can abort the requests when unmounting', () => {
const abort = sinon.stub();
getCloudCredentialNames = sinon.stub().returns({abort: abort});
const component = jsTestUtils.shallowRender(
<juju.components.AccountCredentials
acl={acl}
addNotification={sinon.stub()}
controllerIsReady={controllerIsReady}
generateCloudCredentialName={sinon.stub()}
getCloudCredentialNames={getCloudCredentialNames}
getCloudProviderDetails={getCloudProviderDetails}
listClouds={listClouds}
revokeCloudCredential={sinon.stub()}
sendAnalytics={sinon.stub()}
updateCloudCredential={sinon.stub()}
username="spinach@external"
validateForm={sinon.stub()} />, true);
component.unmount();
assert.equal(abort.callCount, 1);
});
it('can show the add credentials form', () => {
getCloudCredentialNames = sinon.stub().callsArgWith(1, null, []);
const component = jsTestUtils.shallowRender(
<juju.components.AccountCredentials
acl={acl}
addNotification={sinon.stub()}
controllerIsReady={controllerIsReady}
generateCloudCredentialName={sinon.stub()}
getCloudCredentialNames={getCloudCredentialNames}
getCloudProviderDetails={getCloudProviderDetails}
listClouds={listClouds}
revokeCloudCredential={sinon.stub()}
sendAnalytics={sinon.stub()}
updateCloudCredential={sinon.stub()}
username="spinach@external"
validateForm={sinon.stub()} />, true);
const instance = component.getMountedInstance();
let output = component.getRenderOutput();
output.props.children[0].props.children[1].props.children.props.action();
output = component.getRenderOutput();
const expected = (
<div className="account__section account__credentials twelve-col">
<div className="user-profile__header twelve-col no-margin-bottom">
<div className="left">
Cloud credentials
</div>
<div className="right">
<juju.components.GenericButton
action={instance._toggleAdd}
type="inline-neutral"
title="Cancel" />
</div>
</div>
<juju.components.ExpandingRow
classes={{'twelve-col': true}}
clickable={false}
expanded={true}>
<div></div>
<div className="twelve-col">
<div>
{null}
<juju.components.DeploymentCloud
acl={acl}
cloud={null}
controllerIsReady={controllerIsReady}
listClouds={listClouds}
getCloudProviderDetails={getCloudProviderDetails}
setCloud={instance._setCloud} />
{null}
</div>
</div>
</juju.components.ExpandingRow>
<div>
No credentials available.
</div>
</div>);
expect(output).toEqualJSX(expected);
});
it('can display correctly with a chosen cloud', () => {
const addNotification = sinon.stub();
const generateCloudCredentialName = sinon.stub();
const updateCloudCredential = sinon.stub();
const validateForm = sinon.stub();
const sendAnalytics = sinon.stub();
const component = jsTestUtils.shallowRender(
<juju.components.AccountCredentials
acl={acl}
addNotification={addNotification}
controllerIsReady={controllerIsReady}
generateCloudCredentialName={generateCloudCredentialName}
getCloudCredentialNames={getCloudCredentialNames}
getCloudProviderDetails={getCloudProviderDetails}
listClouds={listClouds}
revokeCloudCredential={sinon.stub()}
sendAnalytics={sendAnalytics}
updateCloudCredential={updateCloudCredential}
username="spinach@external"
validateForm={validateForm} />, true);
const instance = component.getMountedInstance();
let output = component.getRenderOutput();
output.props.children[0].props.children[1].props.children.props.action();
instance._setCloud({title: 'aws'});
output = component.getRenderOutput();
const expected = (
<juju.components.ExpandingRow
classes={{'twelve-col': true}}
clickable={false}
expanded={true}>
<div></div>
<div className="twelve-col">
<div>
<div className="account__credentials-choose-cloud">
<juju.components.GenericButton
action={
output.props.children[1].props.children[1].props.children
.props.children[0].props.children.props.action}
type="inline-neutral"
title="Change cloud" />
</div>
<juju.components.DeploymentCloud
acl={acl}
cloud={{title: 'aws'}}
controllerIsReady={controllerIsReady}
listClouds={listClouds}
getCloudProviderDetails={getCloudProviderDetails}
setCloud={instance._setCloud} />
<juju.components.DeploymentCredentialAdd
acl={acl}
addNotification={addNotification}
close={instance._toggleAdd}
cloud={{title: 'aws'}}
credentials={['test1', 'test2']}
getCloudProviderDetails={getCloudProviderDetails}
generateCloudCredentialName={generateCloudCredentialName}
getCredentials={instance._getClouds}
sendAnalytics={sendAnalytics}
setCredential={instance._setCredential}
updateCloudCredential={updateCloudCredential}
user="spinach@external"
validateForm={validateForm} />
</div>
</div>
</juju.components.ExpandingRow>);
expect(output.props.children[1]).toEqualJSX(expected);
});
it('clears the cloud when the form is closed', () => {
getCloudCredentialNames = sinon.stub().callsArgWith(1, null, []);
const addNotification = sinon.stub();
const generateCloudCredentialName = sinon.stub();
const updateCloudCredential = sinon.stub();
const validateForm = sinon.stub();
const component = jsTestUtils.shallowRender(
<juju.components.AccountCredentials
acl={acl}
addNotification={addNotification}
controllerIsReady={controllerIsReady}
generateCloudCredentialName={generateCloudCredentialName}
getCloudCredentialNames={getCloudCredentialNames}
getCloudProviderDetails={getCloudProviderDetails}
listClouds={listClouds}
revokeCloudCredential={sinon.stub()}
sendAnalytics={sinon.stub()}
updateCloudCredential={updateCloudCredential}
username="spinach@external"
validateForm={validateForm} />, true);
const instance = component.getMountedInstance();
let output = component.getRenderOutput();
// Open the form.
output.props.children[0].props.children[1].props.children.props.action();
instance._setCloud({title: 'aws'});
// Close the form.
output = component.getRenderOutput();
output.props.children[1].props.children[1].props.children
.props.children[2].props.close();
assert.isNull(instance.state.cloud);
});
});