| OLD | NEW |
| 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/parsed_certificate.h" | 5 #include "net/cert/internal/parsed_certificate.h" |
| 6 | 6 |
| 7 #include "net/cert/internal/cert_errors.h" | 7 #include "net/cert/internal/cert_errors.h" |
| 8 #include "net/cert/internal/parse_certificate.h" | 8 #include "net/cert/internal/parse_certificate.h" |
| 9 #include "net/cert/internal/test_helpers.h" | 9 #include "net/cert/internal/test_helpers.h" |
| 10 #include "net/der/input.h" | 10 #include "net/der/input.h" |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 scoped_refptr<ParsedCertificate> cert = | 299 scoped_refptr<ParsedCertificate> cert = |
| 300 ParseCertificateFromFile("basic_constraints_pathlen_not_ca.pem"); | 300 ParseCertificateFromFile("basic_constraints_pathlen_not_ca.pem"); |
| 301 ASSERT_TRUE(cert); | 301 ASSERT_TRUE(cert); |
| 302 | 302 |
| 303 EXPECT_TRUE(cert->has_basic_constraints()); | 303 EXPECT_TRUE(cert->has_basic_constraints()); |
| 304 EXPECT_FALSE(cert->basic_constraints().is_ca); | 304 EXPECT_FALSE(cert->basic_constraints().is_ca); |
| 305 EXPECT_TRUE(cert->basic_constraints().has_path_len); | 305 EXPECT_TRUE(cert->basic_constraints().has_path_len); |
| 306 EXPECT_EQ(1u, cert->basic_constraints().path_len); | 306 EXPECT_EQ(1u, cert->basic_constraints().path_len); |
| 307 } | 307 } |
| 308 | 308 |
| 309 // Tests parsing a certificate that contains a policyConstraints |
| 310 // extension having requireExplicitPolicy:3. |
| 311 TEST(ParsedCertificateTest, PolicyConstraintsRequire) { |
| 312 scoped_refptr<ParsedCertificate> cert = |
| 313 ParseCertificateFromFile("policy_constraints_require.pem"); |
| 314 ASSERT_TRUE(cert); |
| 315 |
| 316 EXPECT_TRUE(cert->has_policy_constraints()); |
| 317 EXPECT_TRUE(cert->policy_constraints().has_require_explicit_policy); |
| 318 EXPECT_EQ(3, cert->policy_constraints().require_explicit_policy); |
| 319 EXPECT_FALSE(cert->policy_constraints().has_inhibit_policy_mapping); |
| 320 EXPECT_EQ(0, cert->policy_constraints().inhibit_policy_mapping); |
| 321 } |
| 322 |
| 323 // Tests parsing a certificate that contains a policyConstraints |
| 324 // extension having inhibitPolicyMapping:1. |
| 325 TEST(ParsedCertificateTest, PolicyConstraintsInhibit) { |
| 326 scoped_refptr<ParsedCertificate> cert = |
| 327 ParseCertificateFromFile("policy_constraints_inhibit.pem"); |
| 328 ASSERT_TRUE(cert); |
| 329 |
| 330 EXPECT_TRUE(cert->has_policy_constraints()); |
| 331 EXPECT_FALSE(cert->policy_constraints().has_require_explicit_policy); |
| 332 EXPECT_EQ(0, cert->policy_constraints().require_explicit_policy); |
| 333 EXPECT_TRUE(cert->policy_constraints().has_inhibit_policy_mapping); |
| 334 EXPECT_EQ(1, cert->policy_constraints().inhibit_policy_mapping); |
| 335 } |
| 336 |
| 337 // Tests parsing a certificate that contains a policyConstraints |
| 338 // extension having requireExplicitPolicy:5,inhibitPolicyMapping:2. |
| 339 TEST(ParsedCertificateTest, PolicyConstraintsInhibitRequire) { |
| 340 scoped_refptr<ParsedCertificate> cert = |
| 341 ParseCertificateFromFile("policy_constraints_inhibit_require.pem"); |
| 342 ASSERT_TRUE(cert); |
| 343 |
| 344 EXPECT_TRUE(cert->has_policy_constraints()); |
| 345 EXPECT_TRUE(cert->policy_constraints().has_require_explicit_policy); |
| 346 EXPECT_EQ(5, cert->policy_constraints().require_explicit_policy); |
| 347 EXPECT_TRUE(cert->policy_constraints().has_inhibit_policy_mapping); |
| 348 EXPECT_EQ(2, cert->policy_constraints().inhibit_policy_mapping); |
| 349 } |
| 350 |
| 351 // Tests parsing a certificate that has a policyConstraints |
| 352 // extension with an empty sequence. |
| 353 TEST(ParsedCertificateTest, PolicyConstraintsEmpty) { |
| 354 scoped_refptr<ParsedCertificate> cert = |
| 355 ParseCertificateFromFile("policy_constraints_empty.pem"); |
| 356 ASSERT_FALSE(cert); |
| 357 } |
| 358 |
| 309 } // namespace | 359 } // namespace |
| 310 | 360 |
| 311 } // namespace net | 361 } // namespace net |
| OLD | NEW |