-
Notifications
You must be signed in to change notification settings - Fork 107
Expand file tree
/
Copy pathtest-cli.sh
More file actions
executable file
·1484 lines (1297 loc) · 41.9 KB
/
test-cli.sh
File metadata and controls
executable file
·1484 lines (1297 loc) · 41.9 KB
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
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env bash
# Copyright (c) 2020, salesforce.com, inc.
# All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause
# For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
###############################################################################
###### Bootstrap
###############################################################################
# ensure jq is available
TEST_JQ=`hash jq`
if [ $? -eq 1 ]; then
echo -e "jq is required to run the cli tests. Get jq from https://stedolan.github.io/jq/"
exit 1
fi
# reset to track the time elapsed
SECONDS=0
# pass parameters in the following order:
# $ bin/test-cli.sh <CLIENT_ID> <CLIENT_SECRET> <USER> <USER_PW> <HOST> <SANDBOX_REALM> <TEST_ORG> <TEST_USER>
# mapping input parameters
ARG_CLIENT_ID=$1
ARG_CLIENT_SECRET=$2
ARG_USER=$3
ARG_USER_PW=$4
ARG_HOST=$5
ARG_SANDBOX_REALM=$6
ARG_TEST_ORG=$7
ARG_TEST_USER=$8
# check on host
if [ "$ARG_HOST" = "" ]; then
echo -e "Host is unknown. Using host of created sandbox for instance tests."
else
echo -e "Using passed host for instance tests."
fi
# check on realm
if [ "$ARG_SANDBOX_REALM" = "" ]; then
echo -e "Realm for sandbox API unknown."
echo
exit 1
fi
###############################################################################
###### Testing ´sfcc-ci´
###############################################################################
echo "Testing command ´sfcc-ci´ without command and option:"
node ./cli.js
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci´ without command and --help option:"
node ./cli.js --help
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci´ without command and --version option:"
node ./cli.js --version
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci´ and unknown command (expected to fail):"
node ./cli.js unknown
if [ $? -eq 1 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
###############################################################################
###### Testing ´sfcc-ci client:auth´
###############################################################################
echo "Testing command ´sfcc-ci client:auth´ without option:"
node ./cli.js client:auth "$ARG_CLIENT_ID" "$ARG_CLIENT_SECRET"
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci client:auth´ with valid client, but invalid user credentials (expected to fail):"
node ./cli.js client:auth "$ARG_CLIENT_ID" "$ARG_CLIENT_SECRET" "foo" "bar"
if [ $? -eq 1 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci client:auth´ with valid client and user credentials:"
node ./cli.js client:auth "$ARG_CLIENT_ID" "$ARG_CLIENT_SECRET" "$ARG_USER" "$ARG_USER_PW"
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
###############################################################################
###### Testing ´sfcc-ci client:auth:token´
###############################################################################
echo "Testing command ´sfcc-ci client:auth:token´:"
TEST_RESULT=`node ./cli.js client:auth:token`
if [ $? -eq 0 ] && [ ! -z "$TEST_RESULT" ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
###############################################################################
###### Testing ´sfcc-ci client:auth:renew´
###############################################################################
echo "Testing command ´sfcc-ci client:auth:renew´ (expected to fail):"
node ./cli.js client:auth:renew
if [ $? -eq 1 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci client:auth´ with --renew option:"
node ./cli.js client:auth $ARG_CLIENT_ID $ARG_CLIENT_SECRET --renew
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci client:auth:renew´ (expected to succeed):"
node ./cli.js client:auth:renew
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci client:auth´ with --renew option and resource owner grant:"
node ./cli.js client:auth $ARG_CLIENT_ID $ARG_CLIENT_SECRET $ARG_USER $ARG_USER_PW --renew
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci client:renew´ (expected to succeed):"
node ./cli.js client:auth:renew
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
###############################################################################
###### Testing ´sfcc-ci auth:logout´
###############################################################################
echo "Testing command ´sfcc-ci auth:logout´:"
node ./cli.js auth:logout
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
# Acquire new access token beforehand
echo "Acquire new access token using ´sfcc-ci client:auth <api_key>´:"
node ./cli.js client:auth "$ARG_CLIENT_ID" "$ARG_CLIENT_SECRET"
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
###############################################################################
###### Testing ´sfcc-ci client:create´
###############################################################################
echo "Testing command ´sfcc-ci client:create´ without option (expected to fail):"
node ./cli.js client:create
if [ $? -eq 1 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci client:create --configuration <configuration>´ --noprompt:"
TEST_NEW_CLIENT_RESULT=`node ./cli.js client:create --configuration '{"name": "Temp test client", "password": "%2secret(Sauce7?!"}' --noprompt --json`
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
# grab some client details for next set of tests
TEST_NEW_CLIENT_ID=`echo $TEST_NEW_CLIENT_RESULT | jq '.client.id' -r`
###############################################################################
###### Testing ´sfcc-ci client:list´
###############################################################################
echo "Testing command ´sfcc-ci client:list´:"
node ./cli.js client:list
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci client:list´ --clientid <INVALID_CLIENT>´ (expected to fail):"
node ./cli.js client:list --clientid INVALID_CLIENT
if [ $? -eq 1 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci client:list´ --clientid <client_id>´:"
node ./cli.js client:list --clientid $TEST_NEW_CLIENT_ID
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
###############################################################################
###### Testing ´sfcc-ci client:update´
###############################################################################
echo "Testing command ´sfcc-ci client:update´ without option (expected to fail):"
node ./cli.js client:update
if [ $? -eq 1 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci client:update --clientid <client_id> --changes <changes> --noprompt´:"
node ./cli.js client:update --clientid $TEST_NEW_CLIENT_ID --changes '{"active": false}' --noprompt
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
###############################################################################
###### Testing ´sfcc-ci client:rotate´
###############################################################################
echo "Testing command ´sfcc-ci client:rotate´ without option (expected to fail):"
node ./cli.js client:rotate
if [ $? -eq 1 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci client:rotate --clientid <client_id> --noprompt´:"
TEST_ROTATION_RESULT=`node ./cli.js client:rotate --clientid $TEST_NEW_CLIENT_ID --noprompt --json`
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
# grab some client details for cleanup
TEST_ROTATION_ID=`echo $TEST_ROTATION_RESULT | jq '.client.id' -r`
###############################################################################
###### Testing ´sfcc-ci client:delete´
###############################################################################
echo "Testing command ´sfcc-ci client:delete´ without option (expected to fail):"
node ./cli.js client:delete
if [ $? -eq 1 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci client:delete --clientid <client_id> --noprompt´:"
node ./cli.js client:delete --clientid $TEST_NEW_CLIENT_ID --noprompt
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
# cleanup client created during rotation
node ./cli.js client:delete --clientid $TEST_ROTATION_ID --noprompt
###############################################################################
###### Testing ´sfcc-ci sandbox:realm:list´
###############################################################################
echo "Testing command ´sfcc-ci sandbox:realm:list´:"
node ./cli.js sandbox:realm:list
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci sandbox:realm:list --json´:"
node ./cli.js sandbox:realm:list --json
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci sandbox:realm:list --realm´ (expected to fail):"
node ./cli.js sandbox:realm:list --realm
if [ $? -eq 1 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci sandbox:realm:list --realm <realm>´:"
node ./cli.js sandbox:realm:list --realm $ARG_SANDBOX_REALM
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci sandbox:realm:list --realm <realm> --json´:"
node ./cli.js sandbox:realm:list --realm $ARG_SANDBOX_REALM --json
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci sandbox:realm:list --realm <realm> --show-usage´:"
node ./cli.js sandbox:realm:list --realm $ARG_SANDBOX_REALM --show-usage
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
###############################################################################
###### Testing ´sfcc-ci sandbox:realm:update´
###############################################################################
echo "Testing command ´sfcc-ci sandbox:realm:update´ (expected to fail):"
node ./cli.js sandbox:realm:update
if [ $? -eq 1 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci sandbox:realm:update --realm <INVALID_REALM>´ (expected to fail):"
node ./cli.js sandbox:realm:update --realm INVALID_REALM
if [ $? -eq 1 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
# memorize realm settings before tests
TEST_REALM_MAX_SANDBOX_TTL=`node ./cli.js sandbox:realm:list --realm $ARG_SANDBOX_REALM --json | jq '.configuration.sandbox.sandboxTTL.maximum' -r`
TEST_REALM_DEFAULT_SANDBOX_TTL=`node ./cli.js sandbox:realm:list --realm $ARG_SANDBOX_REALM --json | jq '.configuration.sandbox.sandboxTTL.defaultValue' -r`
echo "Testing command ´sfcc-ci sandbox:realm:update --realm <realm> --max-sandbox-ttl 144´:"
node ./cli.js sandbox:realm:update --realm $ARG_SANDBOX_REALM --max-sandbox-ttl 144
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci sandbox:realm:update --realm <realm> --max-sandbox-ttl <previous>´ (restore):"
node ./cli.js sandbox:realm:update --realm $ARG_SANDBOX_REALM --max-sandbox-ttl $TEST_REALM_MAX_SANDBOX_TTL
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci sandbox:realm:update --realm <realm> --default-sandbox-ttl 12´:"
node ./cli.js sandbox:realm:update --realm $ARG_SANDBOX_REALM --default-sandbox-ttl 12
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci sandbox:realm:update --realm <realm> --default-sandbox-ttl <previous>´ (restore):"
node ./cli.js sandbox:realm:update --realm $ARG_SANDBOX_REALM --default-sandbox-ttl $TEST_REALM_DEFAULT_SANDBOX_TTL
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci sandbox:realm:update --realm <realm> --start-scheduler '{"weekdays":["MONDAY","TUESDAY","WEDNESDAY","THURSDAY","FRIDAY"],"time":"08:00:00+03:00"}' --stop-scheduler '{"weekdays":["MONDAY","TUESDAY","WEDNESDAY","THURSDAY","FRIDAY"],"time":"19:00:00Z"}':"
node ./cli.js sandbox:realm:update --realm $ARG_SANDBOX_REALM --start-scheduler '{"weekdays":["MONDAY","TUESDAY","WEDNESDAY","THURSDAY","FRIDAY"],"time":"08:00:00+03:00"}' --stop-scheduler '{"weekdays":["MONDAY","TUESDAY","WEDNESDAY","THURSDAY","FRIDAY"],"time":"19:00:00Z"}'
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci sandbox:realm:update --realm <realm> --start-scheduler 'null' --stop-scheduler 'null':"
node ./cli.js sandbox:realm:update --realm $ARG_SANDBOX_REALM --start-scheduler 'null' --stop-scheduler 'null'
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
###############################################################################
###### Testing ´sfcc-ci sandbox:ips´
###############################################################################
echo "Testing command ´sfcc-ci sandbox:ips´:"
node ./cli.js sandbox:ips
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci sandbox:ips --realm (expected to fail)´:"
node ./cli.js sandbox:ips --realm
if [ $? -eq 1 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci sandbox:ips --realm <realm>´:"
node ./cli.js sandbox:ips --realm $ARG_SANDBOX_REALM
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
###############################################################################
###### Testing ´sfcc-ci sandbox:list´
###############################################################################
echo "Testing command ´sfcc-ci sandbox:list´:"
node ./cli.js sandbox:list
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci sandbox:list --json´:"
node ./cli.js sandbox:list --json
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci sandbox:list --sortby´ (expected to fail):"
node ./cli.js sandbox:list --sortby
if [ $? -eq 1 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci sandbox:list --sortby createdAt´:"
node ./cli.js sandbox:list --sortby createdAt
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci sandbox:list --sortby createdAt --json´:"
node ./cli.js sandbox:list --sortby createdAt --json
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci sandbox:list --show-deleted´:"
node ./cli.js sandbox:list --show-deleted
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
###############################################################################
###### Testing ´sfcc-ci sandbox:create´
###############################################################################
echo "Testing command ´sfcc-ci sandbox:create --realm <INVALID_REALM>´ (expected to fail):"
node ./cli.js sandbox:create --realm INVALID_REALM
if [ $? -eq 1 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci sandbox:create --realm <realm> --ttl 1 --auto-scheduled´:"
node ./cli.js sandbox:create --realm $ARG_SANDBOX_REALM --ttl 1 --auto-scheduled
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci sandbox:create --realm <realm> --profile <INVALID_PROFILE>´ (expected to fail):"
node ./cli.js sandbox:create --realm $ARG_SANDBOX_REALM --profile INVALID_PROFILE
if [ $? -eq 1 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci sandbox:create --realm <realm> --profile large´ --ttl 3:"
node ./cli.js sandbox:create --realm $ARG_SANDBOX_REALM --profile large --ttl 3
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci sandbox:create --realm <realm> --ttl 1 --sync´:"
node ./cli.js sandbox:create --realm $ARG_SANDBOX_REALM --ttl 1 --sync
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci sandbox:create --realm <realm> --ttl 1 --start-scheduler '{"weekdays":["MONDAY","TUESDAY","WEDNESDAY","THURSDAY","FRIDAY"],"time":"08:00:00+03:00"}' --stop-scheduler '{"weekdays":["MONDAY","TUESDAY","WEDNESDAY","THURSDAY","FRIDAY"],"time":"19:00:00Z"}':"
node ./cli.js sandbox:create --realm $ARG_SANDBOX_REALM --ttl 1 --start-scheduler '{"weekdays":["MONDAY","TUESDAY","WEDNESDAY","THURSDAY","FRIDAY"],"time":"08:00:00+03:00"}' --stop-scheduler '{"weekdays":["MONDAY","TUESDAY","WEDNESDAY","THURSDAY","FRIDAY"],"time":"19:00:00Z"}'
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci sandbox:create --realm <realm> --ttl 1 --sync --json´:"
TEST_NEW_SANDBOX_RESULT=`node ./cli.js sandbox:create --realm $ARG_SANDBOX_REALM --ttl 1 --sync --json`
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
# grab some sandbox details for next set of tests
TEST_NEW_SANDBOX_ID=`echo $TEST_NEW_SANDBOX_RESULT | jq '.sandbox.id' -r`
TEST_NEW_SANDBOX_INSTANCE=`echo $TEST_NEW_SANDBOX_RESULT | jq '.sandbox.instance' -r`
TEST_NEW_SANDBOX_HOST=`node ./cli.js sandbox:get --sandbox $TEST_NEW_SANDBOX_ID --host`
if [ "$ARG_HOST" = "" ]; then
ARG_HOST=$TEST_NEW_SANDBOX_HOST
fi
###############################################################################
###### Testing ´sfcc-ci sandbox:get´
###############################################################################
echo "Testing command ´sfcc-ci sandbox:get´ (expected to fail):"
node ./cli.js sandbox:get
if [ $? -eq 1 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci sandbox:get --sandbox <INVALID_ID>´ (expected to fail):"
node ./cli.js sandbox:get --sandbox INVALID_ID
if [ $? -eq 1 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci sandbox:get --sandbox <sandbox>´:"
node ./cli.js sandbox:get --sandbox $TEST_NEW_SANDBOX_ID
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci sandbox:get --sandbox <sandbox> --json´:"
node ./cli.js sandbox:get --sandbox $TEST_NEW_SANDBOX_ID --json
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci sandbox:get --sandbox <sandbox>´ (using <realm>-<instance> as id):"
node ./cli.js sandbox:get --sandbox $ARG_SANDBOX_REALM"_"$TEST_NEW_SANDBOX_INSTANCE
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci sandbox:get --sandbox <sandbox> --host´:"
node ./cli.js sandbox:get --sandbox $TEST_NEW_SANDBOX_ID --host
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci sandbox:get --sandbox <sandbox> --show-usage´:"
node ./cli.js sandbox:get --sandbox $TEST_NEW_SANDBOX_ID --show-usage
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci sandbox:get --sandbox <sandbox> --show-operations´:"
node ./cli.js sandbox:get --sandbox $TEST_NEW_SANDBOX_ID --show-operations
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci sandbox:get --sandbox <sandbox> --show-settings´:"
node ./cli.js sandbox:get --sandbox $TEST_NEW_SANDBOX_ID --show-settings
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci sandbox:get --sandbox <sandbox> --show-storage´:"
node ./cli.js sandbox:get --sandbox $TEST_NEW_SANDBOX_ID --show-storage
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
###############################################################################
###### Testing ´sfcc-ci sandbox:update´
###############################################################################
echo "Testing command ´sfcc-ci sandbox:update´ (expected to fail):"
node ./cli.js sandbox:update
if [ $? -eq 1 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci sandbox:update --sandbox <INVALID_ID>´ (expected to fail):"
node ./cli.js sandbox:update --sandbox INVALID_ID
if [ $? -eq 1 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci sandbox:update <sandbox> --ttl 0´:"
node ./cli.js sandbox:update --sandbox $TEST_NEW_SANDBOX_ID --ttl 0
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci sandbox:update <sandbox> --ttl 2´:"
node ./cli.js sandbox:update --sandbox $TEST_NEW_SANDBOX_ID --ttl 1
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci sandbox:update <sandbox> --start-scheduler '{"weekdays":["MONDAY","TUESDAY","WEDNESDAY","THURSDAY","FRIDAY"],"time":"08:00:00+03:00"}' --stop-scheduler '{"weekdays":["MONDAY","TUESDAY","WEDNESDAY","THURSDAY","FRIDAY"],"time":"19:00:00Z"}'´:"
node ./cli.js sandbox:update --sandbox $TEST_NEW_SANDBOX_ID --start-scheduler '{"weekdays":["MONDAY","TUESDAY","WEDNESDAY","THURSDAY","FRIDAY"],"time":"08:00:00+03:00"}' --stop-scheduler '{"weekdays":["MONDAY","TUESDAY","WEDNESDAY","THURSDAY","FRIDAY"],"time":"19:00:00Z"}'
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci sandbox:update <sandbox> --start-scheduler 'null' --stop-scheduler 'null'´:"
node ./cli.js sandbox:update --sandbox $TEST_NEW_SANDBOX_ID --start-scheduler 'null' --stop-scheduler 'null'
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
###############################################################################
###### Testing ´sfcc-ci sandbox:alias:*´
###############################################################################
echo "Testing command ´sfcc-ci sandbox:alias:list´ invalid alias (expected to fail):"
node ./cli.js sandbox:alias:list --sandbox $TEST_NEW_SANDBOX_ID -a invalidId
if [ $? -eq 1 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci sandbox:alias:add´ without sbx and alias (expected to fail):"
node ./cli.js sandbox:alias:add
if [ $? -eq 1 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci sandbox:alias:add´ without alias (expected to fail):"
node ./cli.js sandbox:alias:add --sandbox $TEST_NEW_SANDBOX_ID
if [ $? -eq 1 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci sandbox:alias:add´:"
ALIAS_RESULT=`node ./cli.js sandbox:alias:add --sandbox $TEST_NEW_SANDBOX_ID -h my.newalias.com --json`
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
TEST_NEW_ALIAS_ID=`echo $ALIAS_RESULT | jq '.id' -r`
echo "Testing command ´sfcc-ci sandbox:alias:list´ with sbx and alias:"
node ./cli.js sandbox:alias:list --sandbox $TEST_NEW_SANDBOX_ID -a $TEST_NEW_ALIAS_ID --json
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci sandbox:alias:list´ without sbx (expected to fail)):"
node ./cli.js sandbox:alias:list
if [ $? -eq 1 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci sandbox:alias:list:´ with sbx"
node ./cli.js sandbox:alias:list --sandbox $TEST_NEW_SANDBOX_ID
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci sandbox:alias:delete´ (invalid alias):"
node ./cli.js sandbox:alias:delete --sandbox $TEST_NEW_SANDBOX_ID -a $TEST_NEW_ALIAS_ID --noprompt
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci sandbox:alias:add´ with request for letsencrypt:"
ALIAS_RESULT=`node ./cli.js sandbox:alias:add --sandbox $TEST_NEW_SANDBOX_ID -h my.newalias.com --unique --request-letsencrypt-certificate --json`
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci sandbox:alias:add´ with request for letsencrypt and unique as false ( should fail ) :"
ALIAS_RESULT=`node ./cli.js sandbox:alias:add --sandbox $TEST_NEW_SANDBOX_ID -h my.newalias.com --request-letsencrypt-certificate --json`
if [ $? -eq 1 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
TEST_NEW_ALIAS_ID=`echo $ALIAS_RESULT | jq '.id' -r`
echo "Testing command ´sfcc-ci sandbox:alias:delete´ (invalid alias):"
node ./cli.js sandbox:alias:delete --sandbox $TEST_NEW_SANDBOX_ID -a $TEST_NEW_ALIAS_ID --noprompt
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
###############################################################################
###### Testing ´sfcc-ci instance:clear´
###############################################################################
echo "Testing command ´sfcc-ci instance:add´ (without alias):"
node ./cli.js instance:add $ARG_HOST
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci instance:clear´:"
node ./cli.js instance:clear
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
###############################################################################
###### Testing ´sfcc-ci instance:add´
###############################################################################
echo "Testing command ´sfcc-ci instance:add´ (with alias):"
node ./cli.js instance:add $ARG_HOST my
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci instance:add´ with invalid instance (expected to fail):"
node ./cli.js instance:add my-instance.demandware.net
if [ $? -eq 1 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci instance:add´:"
node ./cli.js instance:add $ARG_HOST someotheralias
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
###############################################################################
###### Testing ´sfcc-ci instance:set´
###############################################################################
echo "Testing command ´sfcc-ci instance:set´ with host name:"
node ./cli.js instance:set $ARG_HOST
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci instance:set´ with alias:"
node ./cli.js instance:set my
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
###############################################################################
###### Testing ´sfcc-ci instance:upload´
###############################################################################
echo "Testing command ´sfcc-ci instance:upload´:"
node ./cli.js instance:upload ./test/cli/site_import.zip
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci instance:upload´ with --instance option:"
node ./cli.js instance:upload ./test/cli/site_import.zip --instance $ARG_HOST
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
echo "Testing command ´sfcc-ci instance:upload´ with non-existing file (expected to fail):"
node ./cli.js instance:upload ./test/does/not/exist/site_import.zip
if [ $? -eq 1 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1
fi
###############################################################################
###### Testing ´sfcc-ci instance:import´
###############################################################################
echo "Testing command ´sfcc-ci instance:import´ with --sync option:"
node ./cli.js instance:import site_import.zip --sync
if [ $? -eq 0 ]; then
echo -e "\t> OK"
else
echo -e "\t> FAILED"
exit 1