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

Unified Diff: net/cert/internal/parse_ocsp_unittest.cc

Issue 2138413002: Revert of Add CheckOCSPDateValid() to net/cert/internal (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « net/cert/internal/parse_ocsp.cc ('k') | net/der/encode_values.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/cert/internal/parse_ocsp_unittest.cc
diff --git a/net/cert/internal/parse_ocsp_unittest.cc b/net/cert/internal/parse_ocsp_unittest.cc
index bc4e1e1ebe14930727397707a95423a472081e96..c0fc061b5e43243f39d156444df42a61f38915e5 100644
--- a/net/cert/internal/parse_ocsp_unittest.cc
+++ b/net/cert/internal/parse_ocsp_unittest.cc
@@ -8,15 +8,12 @@
#include "base/logging.h"
#include "net/cert/internal/test_helpers.h"
#include "net/cert/x509_certificate.h"
-#include "net/der/encode_values.h"
#include "net/test/test_data_directory.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace net {
namespace {
-
-const base::TimeDelta kOCSPAgeOneWeek = base::TimeDelta::FromDays(7);
std::string GetFilePath(const std::string& file_name) {
return std::string("net/data/parse_ocsp_unittest/") + file_name;
@@ -185,131 +182,4 @@
ASSERT_EQ(PARSE_OCSP_SINGLE_RESPONSE, ParseOCSP("missing_response.pem"));
}
-TEST(OCSPDateTest, Valid) {
- OCSPSingleResponse response;
-
- base::Time now = base::Time::Now();
- base::Time this_update = now - base::TimeDelta::FromHours(1);
- ASSERT_TRUE(
- der::EncodeTimeAsGeneralizedTime(this_update, &response.this_update));
- response.has_next_update = false;
- EXPECT_TRUE(CheckOCSPDateValid(response, now, kOCSPAgeOneWeek));
-
- base::Time next_update = this_update + base::TimeDelta::FromDays(7);
- ASSERT_TRUE(
- der::EncodeTimeAsGeneralizedTime(next_update, &response.next_update));
- response.has_next_update = true;
- EXPECT_TRUE(CheckOCSPDateValid(response, now, kOCSPAgeOneWeek));
-}
-
-TEST(OCSPDateTest, ThisUpdateInTheFuture) {
- OCSPSingleResponse response;
-
- base::Time now = base::Time::Now();
- base::Time this_update = now + base::TimeDelta::FromHours(1);
- ASSERT_TRUE(
- der::EncodeTimeAsGeneralizedTime(this_update, &response.this_update));
- response.has_next_update = false;
- EXPECT_FALSE(CheckOCSPDateValid(response, now, kOCSPAgeOneWeek));
-
- base::Time next_update = this_update + base::TimeDelta::FromDays(7);
- ASSERT_TRUE(
- der::EncodeTimeAsGeneralizedTime(next_update, &response.next_update));
- response.has_next_update = true;
- EXPECT_FALSE(CheckOCSPDateValid(response, now, kOCSPAgeOneWeek));
-}
-
-TEST(OCSPDateTest, NextUpdatePassed) {
- OCSPSingleResponse response;
-
- base::Time now = base::Time::Now();
- base::Time this_update = now - base::TimeDelta::FromDays(6);
- ASSERT_TRUE(
- der::EncodeTimeAsGeneralizedTime(this_update, &response.this_update));
- response.has_next_update = false;
- EXPECT_TRUE(CheckOCSPDateValid(response, now, kOCSPAgeOneWeek));
-
- base::Time next_update = now - base::TimeDelta::FromHours(1);
- ASSERT_TRUE(
- der::EncodeTimeAsGeneralizedTime(next_update, &response.next_update));
- response.has_next_update = true;
- EXPECT_FALSE(CheckOCSPDateValid(response, now, kOCSPAgeOneWeek));
-}
-
-TEST(OCSPDateTest, NextUpdateBeforeThisUpdate) {
- OCSPSingleResponse response;
-
- base::Time now = base::Time::Now();
- base::Time this_update = now - base::TimeDelta::FromDays(1);
- ASSERT_TRUE(
- der::EncodeTimeAsGeneralizedTime(this_update, &response.this_update));
- response.has_next_update = false;
- EXPECT_TRUE(CheckOCSPDateValid(response, now, kOCSPAgeOneWeek));
-
- base::Time next_update = this_update - base::TimeDelta::FromDays(1);
- ASSERT_TRUE(
- der::EncodeTimeAsGeneralizedTime(next_update, &response.next_update));
- response.has_next_update = true;
- EXPECT_FALSE(CheckOCSPDateValid(response, now, kOCSPAgeOneWeek));
-}
-
-TEST(OCSPDateTest, ThisUpdateOlderThanMaxAge) {
- OCSPSingleResponse response;
-
- base::Time now = base::Time::Now();
- base::Time this_update = now - kOCSPAgeOneWeek;
- ASSERT_TRUE(
- der::EncodeTimeAsGeneralizedTime(this_update, &response.this_update));
- response.has_next_update = false;
- EXPECT_TRUE(CheckOCSPDateValid(response, now, kOCSPAgeOneWeek));
-
- base::Time next_update = now + base::TimeDelta::FromHours(1);
- ASSERT_TRUE(
- der::EncodeTimeAsGeneralizedTime(next_update, &response.next_update));
- response.has_next_update = true;
- EXPECT_TRUE(CheckOCSPDateValid(response, now, kOCSPAgeOneWeek));
-
- ASSERT_TRUE(der::EncodeTimeAsGeneralizedTime(
- this_update - base::TimeDelta::FromSeconds(1), &response.this_update));
- response.has_next_update = false;
- EXPECT_FALSE(CheckOCSPDateValid(response, now, kOCSPAgeOneWeek));
- response.has_next_update = true;
- EXPECT_FALSE(CheckOCSPDateValid(response, now, kOCSPAgeOneWeek));
-}
-
-TEST(OCSPDateTest, VerifyTimeFromBeforeWindowsEpoch) {
- OCSPSingleResponse response;
- base::Time windows_epoch;
- base::Time verify_time = windows_epoch - base::TimeDelta::FromDays(1);
-
- base::Time now = base::Time::Now();
- base::Time this_update = now - base::TimeDelta::FromHours(1);
- ASSERT_TRUE(
- der::EncodeTimeAsGeneralizedTime(this_update, &response.this_update));
- response.has_next_update = false;
- EXPECT_FALSE(CheckOCSPDateValid(response, verify_time, kOCSPAgeOneWeek));
-
- base::Time next_update = this_update + kOCSPAgeOneWeek;
- ASSERT_TRUE(
- der::EncodeTimeAsGeneralizedTime(next_update, &response.next_update));
- response.has_next_update = true;
- EXPECT_FALSE(CheckOCSPDateValid(response, verify_time, kOCSPAgeOneWeek));
-}
-
-TEST(OCSPDateTest, VerifyTimeMinusAgeFromBeforeWindowsEpoch) {
- OCSPSingleResponse response;
- base::Time windows_epoch;
- base::Time verify_time = windows_epoch + base::TimeDelta::FromDays(1);
-
- base::Time this_update = windows_epoch;
- ASSERT_TRUE(
- der::EncodeTimeAsGeneralizedTime(this_update, &response.this_update));
- response.has_next_update = false;
-#ifdef OS_WIN
- EXPECT_FALSE(CheckOCSPDateValid(response, verify_time, kOCSPAgeOneWeek));
-#else
- EXPECT_TRUE(CheckOCSPDateValid(response, verify_time, kOCSPAgeOneWeek));
-#endif
-}
-
} // namespace net
« no previous file with comments | « net/cert/internal/parse_ocsp.cc ('k') | net/der/encode_values.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698