Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(290)

Side by Side Diff: net/cert/internal/nist_pkits_unittest.cc

Issue 2907353002: Update PKITs test data to include "user_constrained_policy_set". (Closed)
Patch Set: re-run generator script Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/cert/internal/nist_pkits_unittest.h" 5 #include "net/cert/internal/nist_pkits_unittest.h"
6 6
7 #include "base/strings/string_split.h" 7 #include "base/strings/string_split.h"
8 #include "net/cert/internal/certificate_policies.h" 8 #include "net/cert/internal/certificate_policies.h"
9 9
10 namespace net { 10 namespace net {
11 11
12 namespace { 12 namespace {
13 13
14 // 2.16.840.1.101.3.2.1.48.1 14 // 2.16.840.1.101.3.2.1.48.1
15 const uint8_t kTestPolicy1[] = {0x60, 0x86, 0x48, 0x01, 0x65, 15 const uint8_t kTestPolicy1[] = {0x60, 0x86, 0x48, 0x01, 0x65,
16 0x03, 0x02, 0x01, 0x30, 0x01}; 16 0x03, 0x02, 0x01, 0x30, 0x01};
17 17
18 // 2.16.840.1.101.3.2.1.48.2 18 // 2.16.840.1.101.3.2.1.48.2
19 const uint8_t kTestPolicy2[] = {0x60, 0x86, 0x48, 0x01, 0x65, 19 const uint8_t kTestPolicy2[] = {0x60, 0x86, 0x48, 0x01, 0x65,
20 0x03, 0x02, 0x01, 0x30, 0x02}; 20 0x03, 0x02, 0x01, 0x30, 0x02};
21 21
22 // 2.16.840.1.101.3.2.1.48.3 22 // 2.16.840.1.101.3.2.1.48.3
23 const uint8_t kTestPolicy3[] = {0x60, 0x86, 0x48, 0x01, 0x65, 23 const uint8_t kTestPolicy3[] = {0x60, 0x86, 0x48, 0x01, 0x65,
24 0x03, 0x02, 0x01, 0x30, 0x03}; 24 0x03, 0x02, 0x01, 0x30, 0x03};
25 25
26 // 2.16.840.1.101.3.2.1.48.6 26 // 2.16.840.1.101.3.2.1.48.6
27 const uint8_t kTestPolicy6[] = {0x60, 0x86, 0x48, 0x01, 0x65, 27 const uint8_t kTestPolicy6[] = {0x60, 0x86, 0x48, 0x01, 0x65,
28 0x03, 0x02, 0x01, 0x30, 0x06}; 28 0x03, 0x02, 0x01, 0x30, 0x06};
29 29
30 } // namespace 30 void SetPolicySetFromString(const char* const policy_names,
31 31 std::set<der::Input>* out) {
32 PkitsTestSettings::PkitsTestSettings() { 32 out->clear();
33 SetInitialPolicySet("anyPolicy");
34 }
35
36 PkitsTestSettings::~PkitsTestSettings() = default;
37
38 void PkitsTestSettings::SetInitialPolicySet(const char* const policy_names) {
39 initial_policy_set.clear();
40 std::vector<std::string> names = base::SplitString( 33 std::vector<std::string> names = base::SplitString(
41 policy_names, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); 34 policy_names, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
42 for (const std::string& policy_name : names) { 35 for (const std::string& policy_name : names) {
43 if (policy_name == "anyPolicy") { 36 if (policy_name == "anyPolicy") {
44 initial_policy_set.insert(AnyPolicy()); 37 out->insert(AnyPolicy());
45 } else if (policy_name == "NIST-test-policy-1") { 38 } else if (policy_name == "NIST-test-policy-1") {
46 initial_policy_set.insert(der::Input(kTestPolicy1)); 39 out->insert(der::Input(kTestPolicy1));
47 } else if (policy_name == "NIST-test-policy-2") { 40 } else if (policy_name == "NIST-test-policy-2") {
48 initial_policy_set.insert(der::Input(kTestPolicy2)); 41 out->insert(der::Input(kTestPolicy2));
49 } else if (policy_name == "NIST-test-policy-3") { 42 } else if (policy_name == "NIST-test-policy-3") {
50 initial_policy_set.insert(der::Input(kTestPolicy3)); 43 out->insert(der::Input(kTestPolicy3));
51 } else if (policy_name == "NIST-test-policy-6") { 44 } else if (policy_name == "NIST-test-policy-6") {
52 initial_policy_set.insert(der::Input(kTestPolicy6)); 45 out->insert(der::Input(kTestPolicy6));
53 } else { 46 } else {
54 ADD_FAILURE() << "Unknown policy name: " << policy_name; 47 ADD_FAILURE() << "Unknown policy name: " << policy_name;
55 } 48 }
56 } 49 }
57 } 50 }
58 51
52 } // namespace
53
54 PkitsTestInfo::PkitsTestInfo() {
55 SetInitialPolicySet("anyPolicy");
56 SetUserConstrainedPolicySet("NIST-test-policy-1");
57 }
58
59 void PkitsTestInfo::SetInitialExplicitPolicy(bool b) {
60 initial_explicit_policy = b;
61 }
62
63 void PkitsTestInfo::SetInitialPolicyMappingInhibit(bool b) {
64 initial_policy_mapping_inhibit = b;
65 }
66
67 void PkitsTestInfo::SetInitialInhibitAnyPolicy(bool b) {
68 initial_inhibit_any_policy = b;
69 }
70
71 PkitsTestInfo::~PkitsTestInfo() = default;
72
73 void PkitsTestInfo::SetInitialPolicySet(const char* const policy_names) {
74 SetPolicySetFromString(policy_names, &initial_policy_set);
75 }
76
77 void PkitsTestInfo::SetUserConstrainedPolicySet(
78 const char* const policy_names) {
79 SetPolicySetFromString(policy_names, &user_constrained_policy_set);
80 }
81
59 } // namespace net 82 } // namespace net
OLDNEW
« no previous file with comments | « net/cert/internal/nist_pkits_unittest.h ('k') | net/cert/internal/path_builder_pkits_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698