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 "components/feedback/anonymizer_tool.h" | 5 #include "components/feedback/anonymizer_tool.h" |
6 | 6 |
7 #include <gtest/gtest.h> | 7 #include <gtest/gtest.h> |
8 | 8 |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 | 10 |
(...skipping 29 matching lines...) Expand all Loading... |
40 | 40 |
41 TEST_F(AnonymizerToolTest, Anonymize) { | 41 TEST_F(AnonymizerToolTest, Anonymize) { |
42 EXPECT_EQ("", anonymizer_.Anonymize("")); | 42 EXPECT_EQ("", anonymizer_.Anonymize("")); |
43 EXPECT_EQ("foo\nbar\n", anonymizer_.Anonymize("foo\nbar\n")); | 43 EXPECT_EQ("foo\nbar\n", anonymizer_.Anonymize("foo\nbar\n")); |
44 | 44 |
45 // Make sure MAC address anonymization is invoked. | 45 // Make sure MAC address anonymization is invoked. |
46 EXPECT_EQ("02:46:8a:00:00:01", anonymizer_.Anonymize("02:46:8a:ce:13:57")); | 46 EXPECT_EQ("02:46:8a:00:00:01", anonymizer_.Anonymize("02:46:8a:ce:13:57")); |
47 | 47 |
48 // Make sure custom pattern anonymization is invoked. | 48 // Make sure custom pattern anonymization is invoked. |
49 EXPECT_EQ("Cell ID: '1'", AnonymizeCustomPatterns("Cell ID: 'A1B2'")); | 49 EXPECT_EQ("Cell ID: '1'", AnonymizeCustomPatterns("Cell ID: 'A1B2'")); |
| 50 |
| 51 // Make sure UUIDs are anonymized. |
| 52 EXPECT_EQ( |
| 53 "REQUEST localhost - - \"POST /printers/<UUID: 1> HTTP/1.1\" 200 291 " |
| 54 "Create-Job successful-ok", |
| 55 anonymizer_.Anonymize( |
| 56 "REQUEST localhost - - \"POST /printers/" |
| 57 "cb738a9f-6433-4d95-a81e-94e4ae0ed30b HTTP/1.1\" 200 291 Create-Job " |
| 58 "successful-ok")); |
| 59 EXPECT_EQ( |
| 60 "REQUEST localhost - - \"POST /printers/<UUID: 2> HTTP/1.1\" 200 286 " |
| 61 "Create-Job successful-ok", |
| 62 anonymizer_.Anonymize( |
| 63 "REQUEST localhost - - \"POST /printers/" |
| 64 "d17188da-9cd3-44f4-b148-3e1d748a3b0f HTTP/1.1\" 200 286 Create-Job " |
| 65 "successful-ok")); |
50 } | 66 } |
51 | 67 |
52 TEST_F(AnonymizerToolTest, AnonymizeMACAddresses) { | 68 TEST_F(AnonymizerToolTest, AnonymizeMACAddresses) { |
53 EXPECT_EQ("", AnonymizeMACAddresses("")); | 69 EXPECT_EQ("", AnonymizeMACAddresses("")); |
54 EXPECT_EQ("foo\nbar\n", AnonymizeMACAddresses("foo\nbar\n")); | 70 EXPECT_EQ("foo\nbar\n", AnonymizeMACAddresses("foo\nbar\n")); |
55 EXPECT_EQ("11:22:33:44:55", AnonymizeMACAddresses("11:22:33:44:55")); | 71 EXPECT_EQ("11:22:33:44:55", AnonymizeMACAddresses("11:22:33:44:55")); |
56 EXPECT_EQ("aa:bb:cc:00:00:01", AnonymizeMACAddresses("aa:bb:cc:dd:ee:ff")); | 72 EXPECT_EQ("aa:bb:cc:00:00:01", AnonymizeMACAddresses("aa:bb:cc:dd:ee:ff")); |
57 EXPECT_EQ( | 73 EXPECT_EQ( |
58 "BSSID: aa:bb:cc:00:00:01 in the middle\n" | 74 "BSSID: aa:bb:cc:00:00:01 in the middle\n" |
59 "bb:cc:dd:00:00:02 start of line\n" | 75 "bb:cc:dd:00:00:02 start of line\n" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 TEST_F(AnonymizerToolTest, AnonymizeCustomPatternWithoutContext) { | 195 TEST_F(AnonymizerToolTest, AnonymizeCustomPatternWithoutContext) { |
180 CustomPatternWithoutContext kPattern = {"pattern", "(o+)"}; | 196 CustomPatternWithoutContext kPattern = {"pattern", "(o+)"}; |
181 std::map<std::string, std::string> space; | 197 std::map<std::string, std::string> space; |
182 EXPECT_EQ("", AnonymizeCustomPatternWithoutContext("", kPattern, &space)); | 198 EXPECT_EQ("", AnonymizeCustomPatternWithoutContext("", kPattern, &space)); |
183 EXPECT_EQ("f<pattern: 1>\nf<pattern: 2>z\nf<pattern: 1>l\n", | 199 EXPECT_EQ("f<pattern: 1>\nf<pattern: 2>z\nf<pattern: 1>l\n", |
184 AnonymizeCustomPatternWithoutContext("fo\nfooz\nfol\n", kPattern, | 200 AnonymizeCustomPatternWithoutContext("fo\nfooz\nfol\n", kPattern, |
185 &space)); | 201 &space)); |
186 } | 202 } |
187 | 203 |
188 } // namespace feedback | 204 } // namespace feedback |
OLD | NEW |