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

randombit / botan / 19012754211

02 Nov 2025 01:10PM UTC coverage: 90.677% (+0.006%) from 90.671%
19012754211

push

github

web-flow
Merge pull request #5137 from randombit/jack/clang-tidy-includes

Remove various unused includes flagged by clang-tidy misc-include-cleaner

100457 of 110786 relevant lines covered (90.68%)

12189873.8 hits per line

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

93.1
/src/tests/test_name_constraint.cpp
1
/*
2
* (C) 2015,2016 Kai Michaelis
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/x509path.h>
11
   #include <botan/internal/calendar.h>
12
#endif
13

14
namespace Botan_Tests {
15

16
namespace {
17

18
#if defined(BOTAN_HAS_X509_CERTIFICATES) && defined(BOTAN_HAS_RSA) && defined(BOTAN_HAS_EMSA_PKCS1) && \
19
   defined(BOTAN_TARGET_OS_HAS_FILESYSTEM)
20

21
class Name_Constraint_Tests final : public Test {
×
22
   public:
23
      std::vector<Test::Result> run() override {
1✔
24
         const std::vector<std::tuple<std::string, std::string, std::string, std::string>> test_cases = {
1✔
25
            std::make_tuple("Root_Email_Name_Constraint.crt",
1✔
26
                            "Invalid_Email_Name_Constraint.crt",
27
                            "",
28
                            "Certificate does not pass name constraint"),
29
            std::make_tuple("Root_DN_Name_Constraint.crt",
1✔
30
                            "Invalid_DN_Name_Constraint.crt",
31
                            "",
32
                            "Certificate does not pass name constraint"),
33
            std::make_tuple("Root_DN_Name_Constraint.crt", "Valid_DN_Name_Constraint.crt", "", "Verified"),
1✔
34
            std::make_tuple(
1✔
35
               "Root_DNS_Name_Constraint.crt", "Valid_DNS_Name_Constraint.crt", "aexample.com", "Verified"),
36
            std::make_tuple("Root_IP_Name_Constraint.crt", "Valid_IP_Name_Constraint.crt", "", "Verified"),
1✔
37
            std::make_tuple("Root_IP_Name_Constraint.crt",
1✔
38
                            "Invalid_IP_Name_Constraint.crt",
39
                            "",
40
                            "Certificate does not pass name constraint"),
41
         };
8✔
42
         std::vector<Test::Result> results;
1✔
43
         const Botan::Path_Validation_Restrictions restrictions(false, 80);
2✔
44

45
         std::chrono::system_clock::time_point validation_time =
1✔
46
            Botan::calendar_point(2016, 10, 21, 4, 20, 0).to_std_timepoint();
1✔
47

48
         for(const auto& t : test_cases) {
7✔
49
            Botan::X509_Certificate root(Test::data_file("x509/name_constraint/" + std::get<0>(t)));
12✔
50
            Botan::X509_Certificate sub(Test::data_file("x509/name_constraint/" + std::get<1>(t)));
12✔
51
            Botan::Certificate_Store_In_Memory trusted;
6✔
52
            Test::Result result("X509v3 Name Constraints: " + std::get<1>(t));
6✔
53

54
            trusted.add_certificate(root);
6✔
55
            Botan::Path_Validation_Result path_result = Botan::x509_path_validate(
6✔
56
               sub, restrictions, trusted, std::get<2>(t), Botan::Usage_Type::TLS_SERVER_AUTH, validation_time);
6✔
57

58
            if(path_result.successful_validation() && path_result.trust_root() != root) {
6✔
59
               path_result = Botan::Path_Validation_Result(Botan::Certificate_Status_Code::CANNOT_ESTABLISH_TRUST);
×
60
            }
61

62
            result.test_eq("validation result", path_result.result_string(), std::get<3>(t));
12✔
63
            results.emplace_back(result);
6✔
64
         }
6✔
65

66
         return results;
1✔
67
      }
2✔
68
};
69

70
BOTAN_REGISTER_TEST("x509", "x509_path_name_constraint", Name_Constraint_Tests);
71

72
#endif
73

74
}  // namespace
75

76
}  // 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

© 2026 Coveralls, Inc