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

Side by Side Diff: chrome/browser/ssl/ssl_error_classification_unittest.cc

Issue 376663002: Calculate severity score for date_invalid error (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed typo Created 6 years, 5 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
(Empty)
1 // Copyright (c) 2012 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.
4
5 #include "chrome/browser/ssl/ssl_error_classification.h"
6
7 #include "base/files/file_path.h"
8 #include "base/time/time.h"
9 #include "net/base/test_data_directory.h"
10 #include "net/cert/x509_certificate.h"
11 #include "net/test/cert_test_util.h"
12 #include "net/test/test_certificate_data.h"
13 #include "testing/gtest/include/gtest/gtest.h"
14
15 using base::Time;
16
17 TEST(SSLErrorClassification, TestDateInvalidScore) {
18 base::FilePath certs_dir = net::GetTestCertsDirectory();
19 scoped_refptr<net::X509Certificate> expired_cert =
20 net::ImportCertFromFile(certs_dir, "expired_cert.pem");
21 base::Time time;
22
23 {
24 EXPECT_TRUE(base::Time::FromString("Wed, 03 Jan 2007 12:00:00 GMT", &time));
25 SSLErrorClassification ssl_error(time, expired_cert);
26 EXPECT_FLOAT_EQ(0.06f, ssl_error.ServerCharacteristics());
27 }
28
29 {
30 EXPECT_TRUE(base::Time::FromString("Sat, 06 Jan 2007 12:00:00 GMT", &time));
31 SSLErrorClassification ssl_error(time, expired_cert);
32 EXPECT_FLOAT_EQ(0.09f, ssl_error.ServerCharacteristics());
33 }
34
35 {
36 EXPECT_TRUE(base::Time::FromString("Mon, 08 Jan 2007 12:00:00 GMT", &time));
37 SSLErrorClassification ssl_error(time, expired_cert);
38 EXPECT_FLOAT_EQ(0.12f, ssl_error.ServerCharacteristics());
39 }
40
41 scoped_refptr<net::X509Certificate> ok_cert =
42 net::ImportCertFromFile(certs_dir, "ok_cert.pem");
43 {
44 EXPECT_TRUE(base::Time::FromString("Fri, 07 Jan 2005 12:00:00 GMT", &time));
45 SSLErrorClassification ssl_error(time, ok_cert);
46 EXPECT_FLOAT_EQ(0.2f, ssl_error.ServerCharacteristics());
47 }
48
49 {
50 time = base::Time::NowFromSystemTime();
51 SSLErrorClassification ssl_error(time, ok_cert);
52 EXPECT_FLOAT_EQ(0.0f, ssl_error.ServerCharacteristics());
53 }
54
55 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698