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

Unified Diff: net/cert/multi_log_ct_verifier_unittest.cc

Issue 1498983004: CT Verify test utilities change - Moved the following common functions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 | « no previous file | net/quic/crypto/proof_verifier_chromium_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/cert/multi_log_ct_verifier_unittest.cc
diff --git a/net/cert/multi_log_ct_verifier_unittest.cc b/net/cert/multi_log_ct_verifier_unittest.cc
index d5d609a8ec4d204b26585ba7603e604b8a0cfc03..e9505d73c057c1fa2e369f53d232e458a1bfa614 100644
--- a/net/cert/multi_log_ct_verifier_unittest.cc
+++ b/net/cert/multi_log_ct_verifier_unittest.cc
@@ -70,20 +70,6 @@ class MultiLogCTVerifierTest : public ::testing::Test {
ASSERT_TRUE(embedded_sct_chain_.get());
}
- bool CheckForSingleVerifiedSCTInResult(const ct::CTVerifyResult& result) {
- return (result.verified_scts.size() == 1U) &&
- result.invalid_scts.empty() &&
- result.unknown_logs_scts.empty() &&
- result.verified_scts[0]->log_description == kLogDescription;
- }
-
- bool CheckForSCTOrigin(
- const ct::CTVerifyResult& result,
- ct::SignedCertificateTimestamp::Origin origin) {
- return (result.verified_scts.size() > 0) &&
- (result.verified_scts[0]->origin == origin);
- }
-
bool CheckForEmbeddedSCTInNetLog(TestNetLog& net_log) {
TestNetLogEntry::List entries;
net_log.GetEntries(&entries);
@@ -128,18 +114,6 @@ class MultiLogCTVerifierTest : public ::testing::Test {
return true;
}
- std::string GetSCTListWithInvalidSCT() {
- std::string sct(ct::GetTestSignedCertificateTimestamp());
-
- // Change a byte inside the Log ID part of the SCT so it does
- // not match the log used in the tests
- sct[15] = 't';
-
- std::string sct_list;
- ct::EncodeSCTListForTesting(sct, &sct_list);
- return sct_list;
- }
-
bool VerifySinglePrecertificateChain(scoped_refptr<X509Certificate> chain,
const BoundNetLog& bound_net_log,
ct::CTVerifyResult* result) {
@@ -169,9 +143,9 @@ class MultiLogCTVerifierTest : public ::testing::Test {
BoundNetLog bound_net_log =
BoundNetLog::Make(&net_log, NetLog::SOURCE_CONNECT_JOB);
return (VerifySinglePrecertificateChain(chain, bound_net_log, &result) &&
- CheckForSingleVerifiedSCTInResult(result) &&
- CheckForSCTOrigin(result,
- ct::SignedCertificateTimestamp::SCT_EMBEDDED) &&
+ ct::CheckForSingleVerifiedSCTInResult(result, kLogDescription) &&
+ ct::CheckForSCTOrigin(
+ result, ct::SignedCertificateTimestamp::SCT_EMBEDDED) &&
CheckForEmbeddedSCTInNetLog(net_log));
}
@@ -241,25 +215,20 @@ TEST_F(MultiLogCTVerifierTest,
ASSERT_TRUE(CheckPrecertificateVerification(chain));
}
-TEST_F(MultiLogCTVerifierTest,
- VerifiesSCTOverX509Cert) {
- std::string sct(ct::GetTestSignedCertificateTimestamp());
-
- std::string sct_list;
- ASSERT_TRUE(ct::EncodeSCTListForTesting(sct, &sct_list));
+TEST_F(MultiLogCTVerifierTest, VerifiesSCTOverX509Cert) {
+ std::string sct_list = ct::GetSCTListForTesting();
ct::CTVerifyResult result;
EXPECT_EQ(OK,
verifier_->Verify(
chain_.get(), std::string(), sct_list, &result, BoundNetLog()));
- ASSERT_TRUE(CheckForSingleVerifiedSCTInResult(result));
- ASSERT_TRUE(CheckForSCTOrigin(
+ ASSERT_TRUE(ct::CheckForSingleVerifiedSCTInResult(result, kLogDescription));
+ ASSERT_TRUE(ct::CheckForSCTOrigin(
result, ct::SignedCertificateTimestamp::SCT_FROM_TLS_EXTENSION));
}
-TEST_F(MultiLogCTVerifierTest,
- IdentifiesSCTFromUnknownLog) {
- std::string sct_list = GetSCTListWithInvalidSCT();
+TEST_F(MultiLogCTVerifierTest, IdentifiesSCTFromUnknownLog) {
+ std::string sct_list = ct::GetSCTListWithInvalidSCT();
ct::CTVerifyResult result;
EXPECT_NE(OK,
@@ -278,7 +247,7 @@ TEST_F(MultiLogCTVerifierTest, CountsValidSCTsInStatusHistogram) {
}
TEST_F(MultiLogCTVerifierTest, CountsInvalidSCTsInStatusHistogram) {
- std::string sct_list = GetSCTListWithInvalidSCT();
+ std::string sct_list = ct::GetSCTListWithInvalidSCT();
ct::CTVerifyResult result;
int num_valid_scts = NumValidSCTsInStatusHistogram();
int num_invalid_scts = GetValueFromHistogram(
« no previous file with comments | « no previous file | net/quic/crypto/proof_verifier_chromium_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698