Beispiel #1
0
    def test_broken_records(self):
        record = ['v=BIMI1; l;= s=;']
        bimi = Bimi(record, self.dmarc)
        self.assertEqual([BimiErrors.LOGO_NOT_DEFINED, BimiErrors.SELECTOR_NOT_DEFINED], bimi.errors)

        record = ['v=BIMI1; l;= s;']
        bimi = Bimi(record, self.dmarc)
        self.assertEqual([BimiErrors.LOGO_NOT_DEFINED, BimiErrors.SELECTOR_NOT_DEFINED], bimi.errors)

        record = ['v=BIMI1; l;= s;;']
        bimi = Bimi(record, self.dmarc)
        self.assertEqual([BimiErrors.LOGO_NOT_DEFINED, BimiErrors.SELECTOR_NOT_DEFINED], bimi.errors)

        record = ['v=BIMI1; l']
        bimi = Bimi(record, self.dmarc)
        self.assertEqual([BimiErrors.LOGO_NOT_DEFINED, BimiErrors.SELECTOR_NOT_DEFINED], bimi.errors)

        record = ['v=BIMI1; s']
        bimi = Bimi(record, self.dmarc)
        self.assertEqual([BimiErrors.LOGO_NOT_DEFINED, BimiErrors.SELECTOR_NOT_DEFINED], bimi.errors)

        record = ['v=BIMI1; ; ; ; ;']
        bimi = Bimi(record, self.dmarc)
        self.assertEqual([BimiErrors.LOGO_NOT_DEFINED, BimiErrors.SELECTOR_NOT_DEFINED], bimi.errors)

        record = ['v=BIMI1;']
        bimi = Bimi(record, self.dmarc)
        self.assertEqual([BimiErrors.LOGO_NOT_DEFINED, BimiErrors.SELECTOR_NOT_DEFINED], bimi.errors)

        record = ['v=DMARC1;']
        bimi = Bimi(record, self.dmarc)
        self.assertEqual([BimiErrors.INVALID_START], bimi.errors)
Beispiel #2
0
def grade(bimis: list, dmarcs: list, domain: str) -> [int, ()]:
    if not bimis:
        return 0, [BimiErrors.N0_BIMI_RECORDS]

    the_bimis = []
    for bimi in bimis:
        if bimi.startswith('v=BIMI1'):
            the_bimis.append(bimi)

    bimi = Bimi(the_bimis, dmarcs)

    if len(bimi.errors) == 0 or bimi.errors == [
            BimiErrors.SELECTOR_NOT_DEFINED
    ]:
        return 100, bimi.errors
    else:
        return 0, bimi.errors
Beispiel #3
0
 def test_with_quarantine_bad_percent(self):
     record = ['v=BIMI1; l=https://dnstats.io/logo.svg; s=transaction']
     dmarc = ['v=DMARC1; p=quarantine; pct=10']
     bimi = Bimi(record, dmarc)
     self.assertEqual([BimiErrors.DMARC_STRICT_ENOUGH_PERCENT], bimi.errors)
Beispiel #4
0
 def test_with_quarantine(self):
     record = ['v=BIMI1; l=https://dnstats.io/logo.svg; s=transaction']
     dmarc = ['v=DMARC1; p=quarantine']
     bimi = Bimi(record, dmarc)
     self.assertEqual([], bimi.errors)
Beispiel #5
0
 def test_with_none_dmarc(self):
     record = ['v=BIMI1; l=https://dnstats.io/logo.svg; s=transaction']
     dmarc = ['v=DMARC1; p=none']
     bimi = Bimi(record, dmarc)
     self.assertEqual([BimiErrors.DMARC_STRICT_ENOUGH_POLICY], bimi.errors)
Beispiel #6
0
 def test_with_bad_logo_format(self):
     record = ['v=BIMI1; l=https://dnstats.io/logo.jpg; s=transaction']
     bimi = Bimi(record, self.dmarc)
     self.assertEqual([BimiErrors.LOGO_INVALID_FORMAT], bimi.errors)
Beispiel #7
0
 def test_with_http_logo(self):
     record = ['v=BIMI1; l=http://dnstats.io/logo.svg; s=transaction']
     bimi = Bimi(record, self.dmarc)
     self.assertEqual([BimiErrors.LOGO_NOT_HTTPS], bimi.errors)
Beispiel #8
0
 def test_opt_out(self):
    record = ['v=BIMI1; l=; s=;']
    bimi = Bimi(record, self.dmarc)
    self.assertEqual([BimiErrors.BIMI_OPTED_OUT], bimi.errors)
Beispiel #9
0
 def test_with_bad_logo_location(self):
     record = ['v=BIMI1; l=dnstats.io/logo.svg; s=transaction']
     bimi = Bimi(record, self.dmarc)
     self.assertEqual([BimiErrors.LOGO_INVALID_LOCATION], bimi.errors)
Beispiel #10
0
 def test_with_selector_no_logo(self):
     record = ['v=BIMI1; l=; s=transaction']
     bimi = Bimi(record, self.dmarc)
     self.assertEqual([BimiErrors.LOGO_LOCATION_BLANK], bimi.errors)
Beispiel #11
0
 def test_with_selector(self):
     record = ['v=BIMI1; l=https://dnstats.io/logo.svg; s=transaction;']
     bimi = Bimi(record, self.dmarc)
     self.assertEqual([], bimi.errors)
Beispiel #12
0
 def test_default(self):
     record = ['v=BIMI1; l=https://dnstats.io/logo.svg']
     bimi = Bimi(record, self.dmarc)
     self.assertEqual([BimiErrors.SELECTOR_NOT_DEFINED], bimi.errors)
Beispiel #13
0
 def test_duplicate_tags(self):
     record = ['v=BIMI1; v=BIMI1;']
     bimi = Bimi(record, self.dmarc)
     self.assertEqual([BimiErrors.DUPLICATE_TAG_FOUND, BimiErrors.LOGO_NOT_DEFINED, BimiErrors.SELECTOR_NOT_DEFINED], bimi.errors)
Beispiel #14
0
 def test_with_two_records(self):
     record = ['"v=BIMI1; l=https://dnstats.io/logo.svg; s=transaction"', '"v=BIMI1; l=https://dnstats.io/logo.svg; s=transaction"']
     bimi = Bimi(record, self.dmarc)
     self.assertEqual([BimiErrors.TOO_MANY_BIMI_RECORDS], bimi.errors)