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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ssl/ssl_error_classification_unittest.cc
diff --git a/chrome/browser/ssl/ssl_error_classification_unittest.cc b/chrome/browser/ssl/ssl_error_classification_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f10518e1708c2cb69b866429bc2726ffac1c6634
--- /dev/null
+++ b/chrome/browser/ssl/ssl_error_classification_unittest.cc
@@ -0,0 +1,55 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ssl/ssl_error_classification.h"
+
+#include "base/files/file_path.h"
+#include "base/time/time.h"
+#include "net/base/test_data_directory.h"
+#include "net/cert/x509_certificate.h"
+#include "net/test/cert_test_util.h"
+#include "net/test/test_certificate_data.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+using base::Time;
+
+TEST(SSLErrorClassification, TestDateInvalidScore) {
+ base::FilePath certs_dir = net::GetTestCertsDirectory();
+ scoped_refptr<net::X509Certificate> expired_cert =
+ net::ImportCertFromFile(certs_dir, "expired_cert.pem");
+ base::Time time;
+
+ {
+ EXPECT_TRUE(base::Time::FromString("Wed, 03 Jan 2007 12:00:00 GMT", &time));
+ SSLErrorClassification ssl_error(time, expired_cert);
+ EXPECT_FLOAT_EQ(0.06f, ssl_error.ServerCharacteristics());
+ }
+
+ {
+ EXPECT_TRUE(base::Time::FromString("Sat, 06 Jan 2007 12:00:00 GMT", &time));
+ SSLErrorClassification ssl_error(time, expired_cert);
+ EXPECT_FLOAT_EQ(0.09f, ssl_error.ServerCharacteristics());
+ }
+
+ {
+ EXPECT_TRUE(base::Time::FromString("Mon, 08 Jan 2007 12:00:00 GMT", &time));
+ SSLErrorClassification ssl_error(time, expired_cert);
+ EXPECT_FLOAT_EQ(0.12f, ssl_error.ServerCharacteristics());
+ }
+
+ scoped_refptr<net::X509Certificate> ok_cert =
+ net::ImportCertFromFile(certs_dir, "ok_cert.pem");
+ {
+ EXPECT_TRUE(base::Time::FromString("Fri, 07 Jan 2005 12:00:00 GMT", &time));
+ SSLErrorClassification ssl_error(time, ok_cert);
+ EXPECT_FLOAT_EQ(0.2f, ssl_error.ServerCharacteristics());
+ }
+
+ {
+ time = base::Time::NowFromSystemTime();
+ SSLErrorClassification ssl_error(time, ok_cert);
+ EXPECT_FLOAT_EQ(0.0f, ssl_error.ServerCharacteristics());
+ }
+
+}

Powered by Google App Engine
This is Rietveld 408576698