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

Unified Diff: net/cert/internal/parsed_certificate_unittest.cc

Issue 2872113002: Add parsing code for RFC 5280 PolicyConstraints. (Closed)
Patch Set: update ios bundle_data Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: net/cert/internal/parsed_certificate_unittest.cc
diff --git a/net/cert/internal/parsed_certificate_unittest.cc b/net/cert/internal/parsed_certificate_unittest.cc
index 9b3b2e4b1d3e031d375e6a647ba6b54df0b73ba7..db1b0ad845bdce2d76825ca3ef8e2c4913cc673a 100644
--- a/net/cert/internal/parsed_certificate_unittest.cc
+++ b/net/cert/internal/parsed_certificate_unittest.cc
@@ -306,6 +306,56 @@ TEST(ParsedCertificateTest, BasicConstraintsPathLenButNotCa) {
EXPECT_EQ(1u, cert->basic_constraints().path_len);
}
+// Tests parsing a certificate that contains a policyConstraints
+// extension having requireExplicitPolicy:3.
+TEST(ParsedCertificateTest, PolicyConstraintsRequire) {
+ scoped_refptr<ParsedCertificate> cert =
+ ParseCertificateFromFile("policy_constraints_require.pem");
+ ASSERT_TRUE(cert);
+
+ EXPECT_TRUE(cert->has_policy_constraints());
+ EXPECT_TRUE(cert->policy_constraints().has_require_explicit_policy);
+ EXPECT_EQ(3, cert->policy_constraints().require_explicit_policy);
+ EXPECT_FALSE(cert->policy_constraints().has_inhibit_policy_mapping);
+ EXPECT_EQ(0, cert->policy_constraints().inhibit_policy_mapping);
+}
+
+// Tests parsing a certificate that contains a policyConstraints
+// extension having inhibitPolicyMapping:1.
+TEST(ParsedCertificateTest, PolicyConstraintsInhibit) {
+ scoped_refptr<ParsedCertificate> cert =
+ ParseCertificateFromFile("policy_constraints_inhibit.pem");
+ ASSERT_TRUE(cert);
+
+ EXPECT_TRUE(cert->has_policy_constraints());
+ EXPECT_FALSE(cert->policy_constraints().has_require_explicit_policy);
+ EXPECT_EQ(0, cert->policy_constraints().require_explicit_policy);
+ EXPECT_TRUE(cert->policy_constraints().has_inhibit_policy_mapping);
+ EXPECT_EQ(1, cert->policy_constraints().inhibit_policy_mapping);
+}
+
+// Tests parsing a certificate that contains a policyConstraints
+// extension having requireExplicitPolicy:5,inhibitPolicyMapping:2.
+TEST(ParsedCertificateTest, PolicyConstraintsInhibitRequire) {
+ scoped_refptr<ParsedCertificate> cert =
+ ParseCertificateFromFile("policy_constraints_inhibit_require.pem");
+ ASSERT_TRUE(cert);
+
+ EXPECT_TRUE(cert->has_policy_constraints());
+ EXPECT_TRUE(cert->policy_constraints().has_require_explicit_policy);
+ EXPECT_EQ(5, cert->policy_constraints().require_explicit_policy);
+ EXPECT_TRUE(cert->policy_constraints().has_inhibit_policy_mapping);
+ EXPECT_EQ(2, cert->policy_constraints().inhibit_policy_mapping);
+}
+
+// Tests parsing a certificate that has a policyConstraints
+// extension with an empty sequence.
+TEST(ParsedCertificateTest, PolicyConstraintsEmpty) {
+ scoped_refptr<ParsedCertificate> cert =
+ ParseCertificateFromFile("policy_constraints_empty.pem");
+ ASSERT_FALSE(cert);
+}
+
} // namespace
} // namespace net
« no previous file with comments | « net/cert/internal/parsed_certificate.cc ('k') | net/data/parse_certificate_unittest/policy_constraints_empty.pem » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698