| 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 <string> | 5 #include <string> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "chrome/browser/component_updater/chrome_component_updater_configurator
.h" | 10 #include "chrome/browser/component_updater/chrome_component_updater_configurator
.h" |
| 11 #include "components/component_updater/component_updater_switches.h" | 11 #include "components/component_updater/component_updater_switches.h" |
| 12 #include "components/component_updater/component_updater_url_constants.h" |
| 13 #include "components/component_updater/configurator_impl.h" |
| 12 #include "components/update_client/configurator.h" | 14 #include "components/update_client/configurator.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "url/gurl.h" | 16 #include "url/gurl.h" |
| 15 | 17 |
| 16 namespace component_updater { | 18 namespace component_updater { |
| 17 | 19 |
| 18 TEST(ChromeComponentUpdaterConfiguratorTest, TestDisablePings) { | 20 TEST(ChromeComponentUpdaterConfiguratorTest, TestDisablePings) { |
| 19 base::CommandLine cmdline(*base::CommandLine::ForCurrentProcess()); | 21 base::CommandLine cmdline(*base::CommandLine::ForCurrentProcess()); |
| 20 cmdline.AppendSwitchASCII(switches::kComponentUpdater, "disable-pings"); | 22 cmdline.AppendSwitchASCII(switches::kComponentUpdater, "disable-pings"); |
| 21 | 23 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 | 62 |
| 61 EXPECT_FALSE(config->ExtraRequestParams().empty()); | 63 EXPECT_FALSE(config->ExtraRequestParams().empty()); |
| 62 } | 64 } |
| 63 | 65 |
| 64 TEST(ChromeComponentUpdaterConfiguratorTest, TestUpdaterDefaultUrl) { | 66 TEST(ChromeComponentUpdaterConfiguratorTest, TestUpdaterDefaultUrl) { |
| 65 base::CommandLine cmdline(*base::CommandLine::ForCurrentProcess()); | 67 base::CommandLine cmdline(*base::CommandLine::ForCurrentProcess()); |
| 66 const auto config(MakeChromeComponentUpdaterConfigurator(&cmdline, nullptr)); | 68 const auto config(MakeChromeComponentUpdaterConfigurator(&cmdline, nullptr)); |
| 67 const auto urls = config->UpdateUrl(); | 69 const auto urls = config->UpdateUrl(); |
| 68 | 70 |
| 69 // Expect the default url to be cryptographically secure. | 71 // Expect the default url to be cryptographically secure. |
| 70 EXPECT_GE(urls.size(), 1ul); | 72 EXPECT_GE(urls.size(), 1u); |
| 71 EXPECT_TRUE(urls.front().SchemeIsCryptographic()); | 73 EXPECT_TRUE(urls.front().SchemeIsCryptographic()); |
| 72 } | 74 } |
| 73 | 75 |
| 74 TEST(ChromeComponentUpdaterConfiguratorTest, TestUseCupSigning) { | 76 TEST(ChromeComponentUpdaterConfiguratorTest, TestUseCupSigning) { |
| 75 base::CommandLine cmdline(*base::CommandLine::ForCurrentProcess()); | 77 base::CommandLine cmdline(*base::CommandLine::ForCurrentProcess()); |
| 76 const auto config(MakeChromeComponentUpdaterConfigurator(&cmdline, nullptr)); | 78 const auto config(MakeChromeComponentUpdaterConfigurator(&cmdline, nullptr)); |
| 77 | 79 |
| 78 EXPECT_TRUE(config->UseCupSigning()); | 80 EXPECT_TRUE(config->UseCupSigning()); |
| 79 } | 81 } |
| 80 | 82 |
| 83 TEST(ChromeComponentUpdaterConfiguratorTest, TestUseEncryption) { |
| 84 base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); |
| 85 const auto config(MakeChromeComponentUpdaterConfigurator(cmdline, nullptr)); |
| 86 |
| 87 const auto urls = config->UpdateUrl(); |
| 88 ASSERT_EQ(2u, urls.size()); |
| 89 ASSERT_STREQ(kUpdaterDefaultUrl, urls[0].spec().c_str()); |
| 90 ASSERT_STREQ(kUpdaterFallbackUrl, urls[1].spec().c_str()); |
| 91 |
| 92 ASSERT_EQ(config->UpdateUrl(), config->PingUrl()); |
| 93 |
| 94 // Use the configurator implementation to test the filtering of |
| 95 // unencrypted URLs. |
| 96 { |
| 97 const ConfiguratorImpl config(cmdline, nullptr, true); |
| 98 const auto urls = config.UpdateUrl(); |
| 99 ASSERT_EQ(1u, urls.size()); |
| 100 ASSERT_STREQ(kUpdaterDefaultUrl, urls[0].spec().c_str()); |
| 101 ASSERT_EQ(config.UpdateUrl(), config.PingUrl()); |
| 102 } |
| 103 |
| 104 { |
| 105 const ConfiguratorImpl config(cmdline, nullptr, false); |
| 106 const auto urls = config.UpdateUrl(); |
| 107 ASSERT_EQ(2u, urls.size()); |
| 108 ASSERT_STREQ(kUpdaterDefaultUrl, urls[0].spec().c_str()); |
| 109 ASSERT_STREQ(kUpdaterFallbackUrl, urls[1].spec().c_str()); |
| 110 ASSERT_EQ(config.UpdateUrl(), config.PingUrl()); |
| 111 } |
| 112 } |
| 113 |
| 81 } // namespace component_updater | 114 } // namespace component_updater |
| OLD | NEW |