@@ -354,6 +354,45 @@ defmodule Valentine.ComposerTest do
354
354
355
355
assert assumption . mitigations == [ ]
356
356
end
357
+
358
+ test "add_threat_to_assumption/2 adds an threat to a assumption" do
359
+ assumption = assumption_fixture ( )
360
+ threat = threat_fixture ( )
361
+
362
+ assert { :ok , % Assumption { } = assumption } =
363
+ Composer . add_threat_to_assumption ( assumption , threat )
364
+
365
+ assert assumption . threats == [ threat ]
366
+ end
367
+
368
+ test "add_threat_to_assumption/2 adds an threat to existing assumption threats" do
369
+ assumption = assumption_fixture ( )
370
+ threat = threat_fixture ( )
371
+
372
+ Composer . add_threat_to_assumption ( assumption , threat )
373
+
374
+ threat2 = threat_fixture ( )
375
+
376
+ assert { :ok , % Assumption { } = assumption } =
377
+ Composer . add_threat_to_assumption ( assumption , threat2 )
378
+
379
+ assert assumption . threats == [ threat , threat2 ]
380
+ end
381
+
382
+ test "remove_threat_from_assumption/2 removes an threat from a assumption" do
383
+ assumption = assumption_fixture ( )
384
+ threat = threat_fixture ( )
385
+
386
+ { :ok , % Assumption { } = assumption } =
387
+ Composer . add_threat_to_assumption ( assumption , threat )
388
+
389
+ assert assumption . threats == [ threat ]
390
+
391
+ { :ok , % Assumption { } = assumption } =
392
+ Composer . remove_threat_from_assumption ( assumption , threat )
393
+
394
+ assert assumption . threats == [ ]
395
+ end
357
396
end
358
397
359
398
describe "mitigations" do
@@ -477,6 +516,45 @@ defmodule Valentine.ComposerTest do
477
516
478
517
assert mitigation . assumptions == [ ]
479
518
end
519
+
520
+ test "add_threat_to_mitigation/2 adds an threat to a mitigation" do
521
+ mitigation = mitigation_fixture ( )
522
+ threat = threat_fixture ( )
523
+
524
+ assert { :ok , % Mitigation { } = mitigation } =
525
+ Composer . add_threat_to_mitigation ( mitigation , threat )
526
+
527
+ assert mitigation . threats == [ threat ]
528
+ end
529
+
530
+ test "add_threat_to_mitigation/2 adds an threat to existing mitigation threats" do
531
+ mitigation = mitigation_fixture ( )
532
+ threat = threat_fixture ( )
533
+
534
+ Composer . add_threat_to_mitigation ( mitigation , threat )
535
+
536
+ threat2 = threat_fixture ( )
537
+
538
+ assert { :ok , % Mitigation { } = mitigation } =
539
+ Composer . add_threat_to_mitigation ( mitigation , threat2 )
540
+
541
+ assert mitigation . threats == [ threat , threat2 ]
542
+ end
543
+
544
+ test "remove_threat_from_mitigation/2 removes an threat from a mitigation" do
545
+ mitigation = mitigation_fixture ( )
546
+ threat = threat_fixture ( )
547
+
548
+ { :ok , % Mitigation { } = mitigation } =
549
+ Composer . add_threat_to_mitigation ( mitigation , threat )
550
+
551
+ assert mitigation . threats == [ threat ]
552
+
553
+ { :ok , % Mitigation { } = mitigation } =
554
+ Composer . remove_threat_from_mitigation ( mitigation , threat )
555
+
556
+ assert mitigation . threats == [ ]
557
+ end
480
558
end
481
559
482
560
describe "application_informations" do
0 commit comments