OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/cert/internal/test_helpers.h" | 5 #include "net/cert/internal/test_helpers.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/base_paths.h" | 8 #include "base/base_paths.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 // Read the full contents of the file. | 301 // Read the full contents of the file. |
302 std::string file_data; | 302 std::string file_data; |
303 if (!base::ReadFileToString(filepath, &file_data)) { | 303 if (!base::ReadFileToString(filepath, &file_data)) { |
304 ADD_FAILURE() << "Couldn't read file: " << filepath.value(); | 304 ADD_FAILURE() << "Couldn't read file: " << filepath.value(); |
305 return std::string(); | 305 return std::string(); |
306 } | 306 } |
307 | 307 |
308 return file_data; | 308 return file_data; |
309 } | 309 } |
310 | 310 |
| 311 void VerifyCertPathErrors(const std::string& expected_errors_str, |
| 312 const CertPathErrors& actual_errors, |
| 313 const ParsedCertificateList& chain, |
| 314 const std::string& errors_file_path) { |
| 315 std::string actual_errors_str = actual_errors.ToDebugString(chain); |
| 316 |
| 317 if (expected_errors_str != actual_errors_str) { |
| 318 ADD_FAILURE() << "Cert path errors don't match expectations (" |
| 319 << errors_file_path << ")\n\n" |
| 320 << "EXPECTED:\n\n" |
| 321 << expected_errors_str << "\n" |
| 322 << "ACTUAL:\n\n" |
| 323 << actual_errors_str << "\n" |
| 324 << "===> Use " |
| 325 "net/data/verify_certificate_chain_unittest/" |
| 326 "rebase-errors.py to rebaseline.\n"; |
| 327 } |
| 328 } |
| 329 |
| 330 void VerifyCertErrors(const std::string& expected_errors_str, |
| 331 const CertErrors& actual_errors, |
| 332 const std::string& errors_file_path) { |
| 333 std::string actual_errors_str = actual_errors.ToDebugString(); |
| 334 |
| 335 if (expected_errors_str != actual_errors_str) { |
| 336 ADD_FAILURE() << "Cert errors don't match expectations (" |
| 337 << errors_file_path << ")\n\n" |
| 338 << "EXPECTED:\n\n" |
| 339 << expected_errors_str << "\n" |
| 340 << "ACTUAL:\n\n" |
| 341 << actual_errors_str << "\n" |
| 342 << "===> Use " |
| 343 "net/data/parse_certificate_unittest/" |
| 344 "rebase-errors.py to rebaseline.\n"; |
| 345 } |
| 346 } |
| 347 |
311 } // namespace net | 348 } // namespace net |
OLD | NEW |