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

Side by Side Diff: chrome/browser/policy/policy_browsertest.cc

Issue 2911263002: Rename network time policy to BrowserNetworkTimeQueriesEnabled (Closed)
Patch Set: Created 3 years, 6 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 4529 matching lines...) Expand 10 before | Expand all | Expand 10 after
4540 4540
4541 uint32_t num_requests() { return num_requests_; } 4541 uint32_t num_requests() { return num_requests_; }
4542 4542
4543 private: 4543 private:
4544 uint32_t num_requests_ = 0; 4544 uint32_t num_requests_ = 0;
4545 }; 4545 };
4546 4546
4547 IN_PROC_BROWSER_TEST_F(NetworkTimePolicyTest, NetworkTimeQueriesDisabled) { 4547 IN_PROC_BROWSER_TEST_F(NetworkTimePolicyTest, NetworkTimeQueriesDisabled) {
4548 // Set a policy to disable network time queries. 4548 // Set a policy to disable network time queries.
4549 PolicyMap policies; 4549 PolicyMap policies;
4550 policies.Set(key::kNetworkTimeQueriesEnabled, POLICY_LEVEL_MANDATORY, 4550 policies.Set(key::kBrowserNetworkTimeQueriesEnabled, POLICY_LEVEL_MANDATORY,
4551 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, 4551 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
4552 base::MakeUnique<base::Value>(false), nullptr); 4552 base::MakeUnique<base::Value>(false), nullptr);
4553 UpdateProviderPolicy(policies); 4553 UpdateProviderPolicy(policies);
4554 4554
4555 embedded_test_server()->RegisterRequestHandler(base::Bind( 4555 embedded_test_server()->RegisterRequestHandler(base::Bind(
4556 &NetworkTimePolicyTest::CountingRequestHandler, base::Unretained(this))); 4556 &NetworkTimePolicyTest::CountingRequestHandler, base::Unretained(this)));
4557 ASSERT_TRUE(embedded_test_server()->Start()); 4557 ASSERT_TRUE(embedded_test_server()->Start());
4558 g_browser_process->network_time_tracker()->SetTimeServerURLForTesting( 4558 g_browser_process->network_time_tracker()->SetTimeServerURLForTesting(
4559 embedded_test_server()->GetURL("/")); 4559 embedded_test_server()->GetURL("/"));
4560 4560
4561 net::EmbeddedTestServer https_server_expired_( 4561 net::EmbeddedTestServer https_server_expired_(
4562 net::EmbeddedTestServer::TYPE_HTTPS); 4562 net::EmbeddedTestServer::TYPE_HTTPS);
4563 https_server_expired_.SetSSLConfig(net::EmbeddedTestServer::CERT_EXPIRED); 4563 https_server_expired_.SetSSLConfig(net::EmbeddedTestServer::CERT_EXPIRED);
4564 ASSERT_TRUE(https_server_expired_.Start()); 4564 ASSERT_TRUE(https_server_expired_.Start());
4565 4565
4566 // Navigate to a page with a certificate date error and then check that a 4566 // Navigate to a page with a certificate date error and then check that a
4567 // network time query was not sent. 4567 // network time query was not sent.
4568 ui_test_utils::NavigateToURL(browser(), https_server_expired_.GetURL("/")); 4568 ui_test_utils::NavigateToURL(browser(), https_server_expired_.GetURL("/"));
4569 content::WebContents* tab = 4569 content::WebContents* tab =
4570 browser()->tab_strip_model()->GetActiveWebContents(); 4570 browser()->tab_strip_model()->GetActiveWebContents();
4571 content::InterstitialPage* interstitial_page = tab->GetInterstitialPage(); 4571 content::InterstitialPage* interstitial_page = tab->GetInterstitialPage();
4572 ASSERT_TRUE(interstitial_page); 4572 ASSERT_TRUE(interstitial_page);
4573 EXPECT_EQ(0u, num_requests()); 4573 EXPECT_EQ(0u, num_requests());
4574 4574
4575 // Now enable the policy and check that a network time query is sent. 4575 // Now enable the policy and check that a network time query is sent.
4576 policies.Set(key::kNetworkTimeQueriesEnabled, POLICY_LEVEL_MANDATORY, 4576 policies.Set(key::kBrowserNetworkTimeQueriesEnabled, POLICY_LEVEL_MANDATORY,
4577 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD, 4577 POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
4578 base::MakeUnique<base::Value>(true), nullptr); 4578 base::MakeUnique<base::Value>(true), nullptr);
4579 UpdateProviderPolicy(policies); 4579 UpdateProviderPolicy(policies);
4580 ui_test_utils::NavigateToURL(browser(), https_server_expired_.GetURL("/")); 4580 ui_test_utils::NavigateToURL(browser(), https_server_expired_.GetURL("/"));
4581 interstitial_page = tab->GetInterstitialPage(); 4581 interstitial_page = tab->GetInterstitialPage();
4582 ASSERT_TRUE(interstitial_page); 4582 ASSERT_TRUE(interstitial_page);
4583 EXPECT_EQ(1u, num_requests()); 4583 EXPECT_EQ(1u, num_requests());
4584 } 4584 }
4585 4585
4586 } // namespace policy 4586 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698