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

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

Issue 1290553002: [refactor] Extract some test helpers for certificate verification unittests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cert_mapper
Patch Set: Remove extaneous comment Created 5 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
« no previous file with comments | « net/cert/internal/test_helpers.cc ('k') | net/cert/internal/verify_signed_data_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/cert/internal/verify_name_match_unittest.cc
diff --git a/net/cert/internal/verify_name_match_unittest.cc b/net/cert/internal/verify_name_match_unittest.cc
index 273e2e899165989c90307f387d6cf543827744ee..7321f1612715b37b2ff7ff92fa78c90b9c1eab10 100644
--- a/net/cert/internal/verify_name_match_unittest.cc
+++ b/net/cert/internal/verify_name_match_unittest.cc
@@ -4,13 +4,9 @@
#include "net/cert/internal/verify_name_match.h"
-#include "base/base_paths.h"
-#include "base/files/file_path.h"
-#include "base/files/file_util.h"
-#include "base/path_service.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
-#include "net/cert/pem_tokenizer.h"
+#include "net/cert/internal/test_helpers.h"
#include "net/der/input.h"
#include "net/der/parser.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -19,8 +15,7 @@ namespace net {
namespace {
der::Input SequenceValueFromString(const std::string& s) {
mattm 2015/08/12 21:30:26 Do you want to update this to also take a pointer
eroman 2015/08/12 21:51:30 Good point! I will make that change in this CL.
eroman 2015/08/12 22:51:00 Done.
- der::Parser parser(
- der::Input(reinterpret_cast<const uint8_t*>(s.data()), s.size()));
+ der::Parser parser(InputFromString(&s));
der::Input data;
if (!parser.ReadTag(der::kSequence, &data)) {
ADD_FAILURE();
@@ -43,29 +38,14 @@ der::Input SequenceValueFromString(const std::string& s) {
const std::string& value_type,
const std::string& suffix,
std::string* result) {
- base::FilePath src_root;
- PathService::Get(base::DIR_SOURCE_ROOT, &src_root);
- std::string filename = prefix + "-" + value_type + "-" + suffix + ".pem";
- base::FilePath filepath =
- src_root.Append(FILE_PATH_LITERAL(
- "net/data/verify_name_match_unittest/names"))
- .AppendASCII(filename);
- std::string file_data;
- if (!base::ReadFileToString(filepath, &file_data)) {
- return ::testing::AssertionFailure()
- << "ReadFileToString returned false on " << filename;
- }
+ std::string path = "net/data/verify_name_match_unittest/names/" + prefix +
+ "-" + value_type + "-" + suffix + ".pem";
- std::vector<std::string> pem_headers;
- pem_headers.push_back("NAME");
- PEMTokenizer pem_tokenizer(file_data, pem_headers);
- if (!pem_tokenizer.GetNext()) {
- return ::testing::AssertionFailure() << "PEM.GetNext returned false on "
- << filename;
- }
+ const PemBlockMapping mappings[] = {
+ {"NAME", result},
+ };
- result->assign(pem_tokenizer.data());
- return ::testing::AssertionSuccess();
+ return ReadTestDataFromPemFile(path, mappings);
}
bool TypesAreComparable(const std::string& type_1, const std::string& type_2) {
« no previous file with comments | « net/cert/internal/test_helpers.cc ('k') | net/cert/internal/verify_signed_data_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698