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

Side by Side Diff: net/cert/internal/test_helpers.cc

Issue 2918913002: Add path validation error expectations for PKITS tests. (Closed)
Patch Set: checkpoint Created 3 years, 6 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 unified diff | Download patch
OLDNEW
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
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,
mattm 2017/06/02 21:09:07 maybe name this expected_errors_str to match actua
eroman 2017/06/02 23:16:17 Done.
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 bool matches = expected_errors == actual_errors_str;
317
318 if (!matches) {
mattm 2017/06/02 21:09:07 optional: dunno if using the separate |matches| va
eroman 2017/06/02 23:16:17 Done.
319 ADD_FAILURE() << "Cert path errors don't match expectations ("
320 << errors_file_path << ")\n\n"
321 << "EXPECTED:\n\n"
322 << expected_errors << "\n"
323 << "ACTUAL:\n\n"
324 << actual_errors_str << "\n"
325 << "===> Use "
326 "net/data/verify_certificate_chain_unittest/"
327 "rebase-errors.py to rebaseline.\n";
328 }
329 }
330
331 void VerifyCertErrors(const std::string& expected_errors,
332 const CertErrors& actual_errors,
333 const std::string& errors_file_path) {
334 std::string actual_errors_str = actual_errors.ToDebugString();
335 bool matches = expected_errors == actual_errors_str;
336
337 if (!matches) {
338 ADD_FAILURE() << "Cert errors don't match expectations ("
339 << errors_file_path << ")\n\n"
340 << "EXPECTED:\n\n"
341 << expected_errors << "\n"
342 << "ACTUAL:\n\n"
343 << actual_errors_str << "\n"
344 << "===> Use "
345 "net/data/parse_certificate_unittest/"
346 "rebase-errors.py to rebaseline.\n";
347 }
348 }
349
311 } // namespace net 350 } // namespace net
OLDNEW
« no previous file with comments | « net/cert/internal/test_helpers.h ('k') | net/cert/internal/verify_certificate_chain_pkits_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698