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

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

Issue 2282183004: Add error information to VerifyCertificateChain(). (Closed)
Patch Set: fix typo in README Created 4 years, 4 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: net/cert/internal/verify_certificate_chain_unittest.cc
diff --git a/net/cert/internal/verify_certificate_chain_unittest.cc b/net/cert/internal/verify_certificate_chain_unittest.cc
index 225dcabcade525cea223e9c38dbc955534600566..06346b2f10445475d82cfac8de73f689b9af2a68 100644
--- a/net/cert/internal/verify_certificate_chain_unittest.cc
+++ b/net/cert/internal/verify_certificate_chain_unittest.cc
@@ -12,20 +12,38 @@ namespace net {
namespace {
+// Builds a string representation of all the errors/warnings, that matches the
+// format used in the test files. The format is described in
+// net/data/verify_certificate_chain_unittest/README.
+//
+// TODO(crbug.com/634443): Use a richer string format that includes the error
+// parameters and context.
+std::string MakeErrorsString(const CertErrors& errors) {
+ std::string str;
+ for (const auto& error : errors.errors()) {
+ if (!str.empty())
+ str += "\n";
+ str += error.type;
+ }
+ return str;
+}
+
class VerifyCertificateChainDelegate {
public:
static void Verify(const ParsedCertificateList& chain,
const scoped_refptr<TrustAnchor>& trust_anchor,
const der::GeneralizedTime& time,
- bool expected_result) {
+ bool expected_result,
+ const std::string& expected_errors) {
ASSERT_TRUE(trust_anchor);
SimpleSignaturePolicy signature_policy(1024);
+ CertErrors errors;
bool result = VerifyCertificateChain(chain, trust_anchor.get(),
- &signature_policy, time);
-
- ASSERT_EQ(expected_result, result);
+ &signature_policy, time, &errors);
+ EXPECT_EQ(expected_result, result);
+ EXPECT_EQ(expected_errors, MakeErrorsString(errors));
}
};
« no previous file with comments | « net/cert/internal/verify_certificate_chain_typed_unittest.h ('k') | net/data/verify_certificate_chain_unittest/README » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698