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)); |
} |
}; |