Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / net / ssl / ssl_config_unittest.cc
blobcadce31ce6421a4168f9684413ab49e904095d00
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "net/ssl/ssl_config.h"
7 #include "net/cert/cert_verifier.h"
8 #include "testing/gtest/include/gtest/gtest.h"
10 namespace net {
12 namespace {
14 void CheckCertVerifyFlags(SSLConfig& ssl_config,
15 bool rev_checking_enabled,
16 bool verify_ev_cert,
17 bool cert_io_enabled,
18 bool rev_checking_required_local_anchors) {
19 ssl_config.rev_checking_enabled = rev_checking_enabled;
20 ssl_config.verify_ev_cert = verify_ev_cert;
21 ssl_config.cert_io_enabled = cert_io_enabled;
22 ssl_config.rev_checking_required_local_anchors =
23 rev_checking_required_local_anchors;
24 int flags = ssl_config.GetCertVerifyFlags();
25 if (rev_checking_enabled)
26 EXPECT_TRUE(flags & CertVerifier::VERIFY_REV_CHECKING_ENABLED);
27 else
28 EXPECT_FALSE(flags & CertVerifier::VERIFY_REV_CHECKING_ENABLED);
29 if (verify_ev_cert)
30 EXPECT_TRUE(flags & CertVerifier::VERIFY_EV_CERT);
31 else
32 EXPECT_FALSE(flags & CertVerifier::VERIFY_EV_CERT);
33 if (cert_io_enabled)
34 EXPECT_TRUE(flags & CertVerifier::VERIFY_CERT_IO_ENABLED);
35 else
36 EXPECT_FALSE(flags & CertVerifier::VERIFY_CERT_IO_ENABLED);
37 if (rev_checking_required_local_anchors) {
38 EXPECT_TRUE(flags &
39 CertVerifier::VERIFY_REV_CHECKING_REQUIRED_LOCAL_ANCHORS);
40 } else {
41 EXPECT_FALSE(flags &
42 CertVerifier::VERIFY_REV_CHECKING_REQUIRED_LOCAL_ANCHORS);
46 } // namespace
48 TEST(SSLConfigTest, GetCertVerifyFlags) {
49 SSLConfig ssl_config;
50 CheckCertVerifyFlags(ssl_config,
51 /*rev_checking_enabled=*/true,
52 /*verify_ev_cert=*/true,
53 /*cert_io_enabled=*/true,
54 /*rev_checking_required_local_anchors=*/true);
56 CheckCertVerifyFlags(ssl_config,
57 /*rev_checking_enabled=*/false,
58 /*verify_ev_cert=*/false,
59 /*cert_io_enabled=*/false,
60 /*rev_checking_required_local_anchors=*/false);
62 CheckCertVerifyFlags(ssl_config,
63 /*rev_checking_enabled=*/true,
64 /*verify_ev_cert=*/false,
65 /*cert_io_enabled=*/false,
66 /*rev_checking_required_local_anchors=*/false);
68 CheckCertVerifyFlags(ssl_config,
69 /*rev_checking_enabled=*/false,
70 /*verify_ev_cert=*/true,
71 /*cert_io_enabled=*/false,
72 /*rev_checking_required_local_anchors=*/false);
74 CheckCertVerifyFlags(ssl_config,
75 /*rev_checking_enabled=*/false,
76 /*verify_ev_cert=*/false,
77 /*cert_io_enabled=*/true,
78 /*rev_checking_required_local_anchors=*/false);
80 CheckCertVerifyFlags(ssl_config,
81 /*rev_checking_enabled=*/false,
82 /*verify_ev_cert=*/false,
83 /*cert_io_enabled=*/false,
84 /*rev_checking_required_local_anchors=*/true);
87 } // namespace net