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

Side by Side Diff: chrome/browser/chromeos/policy/system_log_uploader_unittest.cc

Issue 1610123003: Added anonymizer to SystemLogUploader. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 10 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 (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "chrome/browser/chromeos/policy/system_log_uploader.h" 5 #include "chrome/browser/chromeos/policy/system_log_uploader.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/test/test_simple_task_runner.h" 10 #include "base/test/test_simple_task_runner.h"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "chrome/browser/chromeos/settings/scoped_cros_settings_test_helper.h" 12 #include "chrome/browser/chromeos/settings/scoped_cros_settings_test_helper.h"
13 #include "components/feedback/anonymizer_tool.h"
13 #include "content/public/test/test_browser_thread_bundle.h" 14 #include "content/public/test/test_browser_thread_bundle.h"
14 #include "content/public/test/test_utils.h" 15 #include "content/public/test/test_utils.h"
15 #include "net/http/http_request_headers.h" 16 #include "net/http/http_request_headers.h"
16 #include "testing/gmock/include/gmock/gmock.h" 17 #include "testing/gmock/include/gmock/gmock.h"
17 18
18 namespace policy { 19 namespace policy {
19 20
20 namespace { 21 namespace {
21 22
22 // The list of tested system log file names. 23 // The list of tested system log file names.
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 RunPendingUploadTaskAndCheckNext( 282 RunPendingUploadTaskAndCheckNext(
282 uploader, base::TimeDelta::FromMilliseconds( 283 uploader, base::TimeDelta::FromMilliseconds(
283 SystemLogUploader::kDefaultUploadDelayMs)); 284 SystemLogUploader::kDefaultUploadDelayMs));
284 RunPendingUploadTaskAndCheckNext( 285 RunPendingUploadTaskAndCheckNext(
285 uploader, base::TimeDelta::FromMilliseconds( 286 uploader, base::TimeDelta::FromMilliseconds(
286 SystemLogUploader::kDefaultUploadDelayMs)); 287 SystemLogUploader::kDefaultUploadDelayMs));
287 } 288 }
288 289
289 // Test RemovePII function. 290 // Test RemovePII function.
290 TEST_F(SystemLogUploaderTest, TestPII) { 291 TEST_F(SystemLogUploaderTest, TestPII) {
292 feedback::AnonymizerTool anonymizer;
291 std::string data = 293 std::string data =
292 "aaaaaaaaSSID=123aaaaaaaaaaa\n" // SSID. 294 "aaaaaaaa [SSID=123aaaaaa]aaaaa\n" // SSID.
293 "aaaaaaaahttp://tets.comaaaaaaa\n" // URL. 295 "aaaaaaaahttp://tets.comaaaaaaa\n" // URL.
294 "aaaaaemail@example.comaaa\n" // Email address. 296 "aaaaaemail@example.comaaa\n" // Email address.
295 "example@@1234\n" // No PII, it is not valid email address. 297 "example@@1234\n" // No PII, it is not valid email address.
296 "255.255.355.255\n" // No PII, it is not valid IP address format. 298 "255.255.155.255\n" // IP address.
297 "aaaa123.123.45.4aaa\n" // IP address. 299 "aaaa123.123.45.4aaa\n" // IP address.
298 "11:11;11::11\n" // IP address. 300 "11:11;11::11\n" // IP address.
299 "11::11\n" // IP address. 301 "11::11\n" // IP address.
300 "11:11:abcdef:0:0:0:0:0"; // No PII, it is not valid IP address format. 302 "11:11:abcdef:0:0:0:0:0\n" // No PII.
303 "aa:aa:aa:aa:aa:aa"; // MAC address (BSSID).
301 304
302 std::string result = 305 std::string result =
306 "aaaaaaaa [SSID=1]aaaaa\n"
307 "aaaaaaaa<URL: 1>\n"
308 "<email: 1>\n"
303 "example@@1234\n" 309 "example@@1234\n"
304 "255.255.355.255\n" 310 "<IPv4: 1>55\n"
305 "11:11:abcdef:0:0:0:0:0\n"; 311 "aaaa<IPv4: 2>aaa\n"
306 312 "11:11;<IPv6: 1>\n"
307 EXPECT_EQ(result, SystemLogUploader::RemoveSensitiveData(data)); 313 "<IPv6: 1>\n"
314 "11:11:abcdef:0:0:0:0:0\n"
315 "aa:aa:aa:00:00:01";
316 EXPECT_EQ(result, SystemLogUploader::RemoveSensitiveData(&anonymizer, data));
308 } 317 }
309 318
310 } // namespace policy 319 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698