• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

randombit / botan / 5134090420

31 May 2023 03:12PM UTC coverage: 91.721% (-0.3%) from 91.995%
5134090420

push

github

randombit
Merge GH #3565 Disable noisy/pointless pylint warnings

76048 of 82912 relevant lines covered (91.72%)

11755290.1 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

89.29
/src/tests/test_x509_dn.cpp
1
/*
2
* (C) 2017 Jack Lloyd
3
*
4
* Botan is released under the Simplified BSD License (see license.txt)
5
*/
6

7
#include "tests.h"
8

9
#if defined(BOTAN_HAS_X509_CERTIFICATES)
10
   #include <botan/ber_dec.h>
11
   #include <botan/pkix_types.h>
12
#endif
13

14
namespace Botan_Tests {
15

16
#if defined(BOTAN_HAS_X509_CERTIFICATES)
17
class X509_DN_Comparisons_Tests final : public Text_Based_Test {
×
18
   public:
19
      X509_DN_Comparisons_Tests() : Text_Based_Test("x509_dn.vec", "DN1,DN2") {}
2✔
20

21
      Test::Result run_one_test(const std::string& type, const VarMap& vars) override {
10✔
22
         const std::vector<uint8_t> dn_bits1 = vars.get_req_bin("DN1");
10✔
23
         const std::vector<uint8_t> dn_bits2 = vars.get_req_bin("DN2");
10✔
24

25
         const bool dn_same = (type == "Equal");
10✔
26

27
         Test::Result result("X509_DN comparisons");
10✔
28
         try {
10✔
29
            Botan::X509_DN dn1;
10✔
30
            Botan::BER_Decoder bd1(dn_bits1);
10✔
31
            dn1.decode_from(bd1);
10✔
32

33
            Botan::X509_DN dn2;
10✔
34
            Botan::BER_Decoder bd2(dn_bits2);
10✔
35
            dn2.decode_from(bd2);
10✔
36

37
            const bool compared_same = (dn1 == dn2);
10✔
38
            result.test_eq("Comparison matches expected", dn_same, compared_same);
10✔
39

40
            const bool lt1 = (dn1 < dn2);
10✔
41
            const bool lt2 = (dn2 < dn1);
10✔
42

43
            if(dn_same) {
10✔
44
               result.test_eq("same means neither is less than", lt1, false);
6✔
45
               result.test_eq("same means neither is less than", lt2, false);
12✔
46
            } else {
47
               result.test_eq("different means one is less than", lt1 || lt2, true);
4✔
48
               result.test_eq("different means only one is less than", lt1 && lt2, false);
8✔
49
            }
50
         } catch(Botan::Exception& e) {
10✔
51
            result.test_failure(e.what());
×
52
         }
×
53

54
         return result;
10✔
55
      }
20✔
56
};
57

58
BOTAN_REGISTER_TEST("x509", "x509_dn_cmp", X509_DN_Comparisons_Tests);
59
#endif
60

61
}  // namespace Botan_Tests
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc