| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "base/files/file_path.h" | 5 #include "base/files/file_path.h" |
| 6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
| 7 #include "components/update_client/utils.h" | 7 #include "components/update_client/utils.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "url/gurl.h" | 9 #include "url/gurl.h" |
| 10 | 10 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 EXPECT_FALSE(VerifyFileHash256( | 50 EXPECT_FALSE(VerifyFileHash256( |
| 51 MakeTestFilePath("jebgalgnebhfojomionfpkfelancnnkf.crx"), | 51 MakeTestFilePath("jebgalgnebhfojomionfpkfelancnnkf.crx"), |
| 52 std::string("abcd"))); | 52 std::string("abcd"))); |
| 53 | 53 |
| 54 EXPECT_FALSE(VerifyFileHash256( | 54 EXPECT_FALSE(VerifyFileHash256( |
| 55 MakeTestFilePath("jebgalgnebhfojomionfpkfelancnnkf.crx"), | 55 MakeTestFilePath("jebgalgnebhfojomionfpkfelancnnkf.crx"), |
| 56 std::string( | 56 std::string( |
| 57 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"))); | 57 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"))); |
| 58 } | 58 } |
| 59 | 59 |
| 60 // Tests that the brand matches ^([a-zA-Z]{4})?$ |
| 61 TEST(UpdateClientUtils, IsValidBrand) { |
| 62 EXPECT_TRUE(IsValidBrand(std::string(""))); |
| 63 EXPECT_TRUE(IsValidBrand(std::string("T"))); |
| 64 EXPECT_TRUE(IsValidBrand(std::string("TE"))); |
| 65 EXPECT_TRUE(IsValidBrand(std::string("TES"))); |
| 66 EXPECT_TRUE(IsValidBrand(std::string("TEST"))); |
| 67 EXPECT_TRUE(IsValidBrand(std::string(""))); |
| 68 EXPECT_TRUE(IsValidBrand(std::string("t"))); |
| 69 EXPECT_TRUE(IsValidBrand(std::string("te"))); |
| 70 EXPECT_TRUE(IsValidBrand(std::string("tes"))); |
| 71 EXPECT_TRUE(IsValidBrand(std::string("test"))); |
| 72 EXPECT_TRUE(IsValidBrand(std::string("TEst"))); |
| 73 |
| 74 EXPECT_FALSE(IsValidBrand(std::string("TESTS"))); // Too long. |
| 75 EXPECT_FALSE(IsValidBrand(std::string("TES1"))); // Has digit. |
| 76 EXPECT_FALSE(IsValidBrand(std::string(" TES"))); // Begins with white space. |
| 77 EXPECT_FALSE(IsValidBrand(std::string("TES "))); // Ends with white space. |
| 78 EXPECT_FALSE(IsValidBrand(std::string("T ES"))); // Contains white space. |
| 79 EXPECT_FALSE(IsValidBrand(std::string("<TE"))); // Has <. |
| 80 EXPECT_FALSE(IsValidBrand(std::string("TE>"))); // Has >. |
| 81 EXPECT_FALSE(IsValidBrand(std::string("\xaa"))); // Has non-ASCII char. |
| 82 } |
| 83 |
| 60 } // namespace update_client | 84 } // namespace update_client |
| OLD | NEW |