9
9
10
10
// @ts -check
11
11
/* eslint-disable camelcase */
12
+ /* eslint-disable complexity */
12
13
13
14
import { FakeMessageHeader , fakeBrowser } from "../helpers/initWebExtensions.mjs.js" ;
14
15
import AuthVerifier from "../../modules/authVerifier.mjs.js" ;
@@ -402,7 +403,6 @@ describe("AuthVerifier [unittest]", function () {
402
403
expect ( res . dkim [ 0 ] ?. result_str ) . to . be . equal ( "Invalid (No Signature, should be signed by paypal.com)" ) ;
403
404
} ) ;
404
405
405
- // eslint-disable-next-line complexity
406
406
it ( "Failure because of wrong SDID keeps signature meta data" , async function ( ) {
407
407
const message = await fakeBrowser . messages . addMsg ( "rfc6376-A.2.eml" ) ;
408
408
@@ -492,6 +492,30 @@ describe("AuthVerifier [unittest]", function () {
492
492
expect ( ( res . spf ?? [ ] ) [ 0 ] ?. result ) . to . be . equal ( "pass" ) ;
493
493
} ) ;
494
494
495
+ it ( "SPF and DMARC results should be sorted" , async function ( ) {
496
+ await prefs . setValue ( "arh.read" , true ) ;
497
+
498
+ const message = await fakeBrowser . messages . addMsg ( "arh/multiple_spf_and_dmarc_results.eml" ) ;
499
+ const res = await authVerifier . verify ( message ) ;
500
+ const spf = res . spf ?? [ ] ;
501
+ expect ( spf . length ) . to . be . equal ( 8 ) ;
502
+ expect ( spf [ 0 ] ?. result ) . to . be . equal ( "pass" ) ;
503
+ expect ( spf [ 1 ] ?. result ) . to . be . equal ( "neutral" ) ;
504
+ expect ( spf [ 2 ] ?. result ) . to . be . equal ( "policy" ) ;
505
+ expect ( spf [ 3 ] ?. result ) . to . be . equal ( "fail" ) ;
506
+ expect ( spf [ 4 ] ?. result ) . to . be . equal ( "softfail" ) ;
507
+ expect ( spf [ 5 ] ?. result ) . to . be . equal ( "permerror" ) ;
508
+ expect ( spf [ 6 ] ?. result ) . to . be . equal ( "temperror" ) ;
509
+ expect ( spf [ 7 ] ?. result ) . to . be . equal ( "none" ) ;
510
+ const dmarc = res . dmarc ?? [ ] ;
511
+ expect ( dmarc . length ) . to . be . equal ( 5 ) ;
512
+ expect ( dmarc [ 0 ] ?. result ) . to . be . equal ( "pass" ) ;
513
+ expect ( dmarc [ 1 ] ?. result ) . to . be . equal ( "fail" ) ;
514
+ expect ( dmarc [ 2 ] ?. result ) . to . be . equal ( "permerror" ) ;
515
+ expect ( dmarc [ 3 ] ?. result ) . to . be . equal ( "temperror" ) ;
516
+ expect ( dmarc [ 4 ] ?. result ) . to . be . equal ( "none" ) ;
517
+ } ) ;
518
+
495
519
describe ( "Converting of ARH result to DKIM result" , function ( ) {
496
520
beforeEach ( async function ( ) {
497
521
await prefs . setValue ( "dkim.enable" , false ) ;
@@ -644,7 +668,7 @@ describe("AuthVerifier [unittest]", function () {
644
668
645
669
it ( "DKIM results should be sorted" , async function ( ) {
646
670
const message = await fakeBrowser . messages . addMsg ( "arh/multiple_dkim_results.eml" ) ;
647
- const res = await authVerifier . verify ( message ) ;
671
+ let res = await authVerifier . verify ( message ) ;
648
672
expect ( res . dkim . length ) . to . be . equal ( 7 ) ;
649
673
expect ( res . dkim [ 0 ] ?. result ) . to . be . equal ( "SUCCESS" ) ;
650
674
expect ( res . dkim [ 0 ] ?. sdid ) . to . be . equal ( "example.com" ) ;
@@ -660,6 +684,28 @@ describe("AuthVerifier [unittest]", function () {
660
684
expect ( res . dkim [ 5 ] ?. result_str ) . to . be . equal ( "Invalid" ) ;
661
685
expect ( res . dkim [ 6 ] ?. result ) . to . be . equal ( "PERMFAIL" ) ;
662
686
expect ( res . dkim [ 6 ] ?. result_str ) . to . be . equal ( "Invalid (test failure signed by unrelated)" ) ;
687
+
688
+ await prefs . setValue ( "arh.replaceAddonResult" , false ) ;
689
+
690
+ res = await authVerifier . verify ( message ) ;
691
+ expect ( res . dkim . length ) . to . be . equal ( 1 ) ;
692
+ expect ( res . dkim [ 0 ] ?. result ) . to . be . equal ( "none" ) ;
693
+ const arhDkim = res . arh ?. dkim ?? [ ] ;
694
+ expect ( arhDkim . length ) . to . be . equal ( 7 ) ;
695
+ expect ( arhDkim [ 0 ] ?. result ) . to . be . equal ( "SUCCESS" ) ;
696
+ expect ( arhDkim [ 0 ] ?. sdid ) . to . be . equal ( "example.com" ) ;
697
+ expect ( arhDkim [ 1 ] ?. result ) . to . be . equal ( "SUCCESS" ) ;
698
+ expect ( arhDkim [ 1 ] ?. sdid ) . to . be . equal ( "example.org" ) ;
699
+ expect ( arhDkim [ 2 ] ?. result ) . to . be . equal ( "SUCCESS" ) ;
700
+ expect ( arhDkim [ 2 ] ?. sdid ) . to . be . equal ( "unrelated.org" ) ;
701
+ expect ( arhDkim [ 3 ] ?. result ) . to . be . equal ( "PERMFAIL" ) ;
702
+ expect ( arhDkim [ 3 ] ?. result_str ) . to . be . equal ( "Invalid (test failure)" ) ;
703
+ expect ( arhDkim [ 4 ] ?. result ) . to . be . equal ( "PERMFAIL" ) ;
704
+ expect ( arhDkim [ 4 ] ?. result_str ) . to . be . equal ( "Invalid" ) ;
705
+ expect ( arhDkim [ 5 ] ?. result ) . to . be . equal ( "PERMFAIL" ) ;
706
+ expect ( arhDkim [ 5 ] ?. result_str ) . to . be . equal ( "Invalid" ) ;
707
+ expect ( arhDkim [ 6 ] ?. result ) . to . be . equal ( "PERMFAIL" ) ;
708
+ expect ( arhDkim [ 6 ] ?. result_str ) . to . be . equal ( "Invalid (test failure signed by unrelated)" ) ;
663
709
} ) ;
664
710
665
711
it ( "With secure signature algorithm" , async function ( ) {
@@ -751,9 +797,9 @@ describe("AuthVerifier [unittest]", function () {
751
797
const arhDkim = res . arh ?. dkim ?? [ ] ;
752
798
expect ( arhDkim . length ) . to . be . equal ( 3 ) ;
753
799
expect ( arhDkim [ 0 ] ?. result ) . to . be . equal ( "SUCCESS" ) ;
754
- expect ( arhDkim [ 0 ] ?. sdid ) . to . be . equal ( "example.com" ) ;
800
+ expect ( arhDkim [ 0 ] ?. sdid ) . to . be . equal ( "football. example.com" ) ;
755
801
expect ( arhDkim [ 1 ] ?. result ) . to . be . equal ( "SUCCESS" ) ;
756
- expect ( arhDkim [ 1 ] ?. sdid ) . to . be . equal ( "football. example.com" ) ;
802
+ expect ( arhDkim [ 1 ] ?. sdid ) . to . be . equal ( "example.com" ) ;
757
803
expect ( arhDkim [ 2 ] ?. result ) . to . be . equal ( "SUCCESS" ) ;
758
804
expect ( arhDkim [ 2 ] ?. sdid ) . to . be . equal ( "last.example.com" ) ;
759
805
expect ( ( res . spf ?? [ ] ) [ 0 ] ?. result ) . to . be . equal ( "pass" ) ;
@@ -830,9 +876,9 @@ describe("AuthVerifier [unittest]", function () {
830
876
const arhDkim = res . arh ?. dkim ?? [ ] ;
831
877
expect ( arhDkim . length ) . to . be . equal ( 3 ) ;
832
878
expect ( arhDkim [ 0 ] ?. result ) . to . be . equal ( "SUCCESS" ) ;
833
- expect ( arhDkim [ 0 ] ?. sdid ) . to . be . equal ( "example.com" ) ;
879
+ expect ( arhDkim [ 0 ] ?. sdid ) . to . be . equal ( "football. example.com" ) ;
834
880
expect ( arhDkim [ 1 ] ?. result ) . to . be . equal ( "SUCCESS" ) ;
835
- expect ( arhDkim [ 1 ] ?. sdid ) . to . be . equal ( "football. example.com" ) ;
881
+ expect ( arhDkim [ 1 ] ?. sdid ) . to . be . equal ( "example.com" ) ;
836
882
expect ( arhDkim [ 2 ] ?. result ) . to . be . equal ( "SUCCESS" ) ;
837
883
expect ( arhDkim [ 2 ] ?. sdid ) . to . be . equal ( "last.example.com" ) ;
838
884
expect ( ( res . spf ?? [ ] ) [ 0 ] ?. result ) . to . be . equal ( "pass" ) ;
0 commit comments