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"
14 void CheckCertVerifyFlags(SSLConfig
& ssl_config
,
15 bool rev_checking_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
);
28 EXPECT_FALSE(flags
& CertVerifier::VERIFY_REV_CHECKING_ENABLED
);
30 EXPECT_TRUE(flags
& CertVerifier::VERIFY_EV_CERT
);
32 EXPECT_FALSE(flags
& CertVerifier::VERIFY_EV_CERT
);
34 EXPECT_TRUE(flags
& CertVerifier::VERIFY_CERT_IO_ENABLED
);
36 EXPECT_FALSE(flags
& CertVerifier::VERIFY_CERT_IO_ENABLED
);
37 if (rev_checking_required_local_anchors
) {
39 CertVerifier::VERIFY_REV_CHECKING_REQUIRED_LOCAL_ANCHORS
);
42 CertVerifier::VERIFY_REV_CHECKING_REQUIRED_LOCAL_ANCHORS
);
48 TEST(SSLConfigTest
, GetCertVerifyFlags
) {
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);