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

Side by Side Diff: chrome/browser/ssl/captive_portal_blocking_page_browsertest.cc

Issue 2448943002: Refactor SecurityStateModel/Clients for simplicity and reusability. (Closed)
Patch Set: sync. Created 4 years, 1 month 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 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 "chrome/browser/ssl/captive_portal_blocking_page.h" 5 #include "chrome/browser/ssl/captive_portal_blocking_page.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/run_loop.h" 13 #include "base/run_loop.h"
14 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
15 #include "chrome/browser/interstitials/security_interstitial_page_test_utils.h" 15 #include "chrome/browser/interstitials/security_interstitial_page_test_utils.h"
16 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/ssl/cert_report_helper.h" 17 #include "chrome/browser/ssl/cert_report_helper.h"
18 #include "chrome/browser/ssl/certificate_reporting_test_utils.h" 18 #include "chrome/browser/ssl/certificate_reporting_test_utils.h"
19 #include "chrome/browser/ssl/chrome_security_state_model_client.h" 19 #include "chrome/browser/ssl/security_state_tab_helper.h"
20 #include "chrome/browser/ssl/ssl_cert_reporter.h" 20 #include "chrome/browser/ssl/ssl_cert_reporter.h"
21 #include "chrome/browser/ui/browser.h" 21 #include "chrome/browser/ui/browser.h"
22 #include "chrome/browser/ui/tabs/tab_strip_model.h" 22 #include "chrome/browser/ui/tabs/tab_strip_model.h"
23 #include "chrome/common/pref_names.h" 23 #include "chrome/common/pref_names.h"
24 #include "chrome/test/base/in_process_browser_test.h" 24 #include "chrome/test/base/in_process_browser_test.h"
25 #include "components/captive_portal/captive_portal_detector.h" 25 #include "components/captive_portal/captive_portal_detector.h"
26 #include "components/prefs/pref_service.h" 26 #include "components/prefs/pref_service.h"
27 #include "components/security_state/core/security_state.h"
27 #include "content/public/browser/interstitial_page.h" 28 #include "content/public/browser/interstitial_page.h"
28 #include "content/public/browser/web_contents.h" 29 #include "content/public/browser/web_contents.h"
29 #include "content/public/test/browser_test_utils.h" 30 #include "content/public/test/browser_test_utils.h"
30 #include "net/cert/x509_certificate.h" 31 #include "net/cert/x509_certificate.h"
31 #include "net/test/cert_test_util.h" 32 #include "net/test/cert_test_util.h"
32 #include "net/test/test_data_directory.h" 33 #include "net/test/test_data_directory.h"
33 #include "testing/gtest/include/gtest/gtest.h" 34 #include "testing/gtest/include/gtest/gtest.h"
34 #include "url/gurl.h" 35 #include "url/gurl.h"
35 36
36 using chrome_browser_interstitials::IsInterstitialDisplayingText; 37 using chrome_browser_interstitials::IsInterstitialDisplayingText;
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 wifi_ssid)); 162 wifi_ssid));
162 } 163 }
163 EXPECT_EQ(expect_login_url == EXPECT_LOGIN_URL_YES, 164 EXPECT_EQ(expect_login_url == EXPECT_LOGIN_URL_YES,
164 IsInterstitialDisplayingText(contents->GetInterstitialPage(), 165 IsInterstitialDisplayingText(contents->GetInterstitialPage(),
165 expected_login_hostname)); 166 expected_login_hostname));
166 EXPECT_EQ(expect_login_url == EXPECT_LOGIN_URL_NO, 167 EXPECT_EQ(expect_login_url == EXPECT_LOGIN_URL_NO,
167 IsInterstitialDisplayingText(contents->GetInterstitialPage(), 168 IsInterstitialDisplayingText(contents->GetInterstitialPage(),
168 kGenericLoginURLText)); 169 kGenericLoginURLText));
169 170
170 // Check that a red/dangerous lock icon is showing on the interstitial. 171 // Check that a red/dangerous lock icon is showing on the interstitial.
171 ChromeSecurityStateModelClient* security_model = 172 SecurityStateTabHelper* helper =
172 ChromeSecurityStateModelClient::FromWebContents(contents); 173 SecurityStateTabHelper::FromWebContents(contents);
173 ASSERT_TRUE(security_model); 174 ASSERT_TRUE(helper);
174 security_state::SecurityStateModel::SecurityInfo security_info; 175 security_state::SecurityInfo security_info;
175 security_model->GetSecurityInfo(&security_info); 176 helper->GetSecurityInfo(&security_info);
176 EXPECT_EQ(security_state::SecurityStateModel::DANGEROUS, 177 EXPECT_EQ(security_state::DANGEROUS, security_info.security_level);
177 security_info.security_level);
178 } 178 }
179 179
180 void CaptivePortalBlockingPageTest::TestInterstitial( 180 void CaptivePortalBlockingPageTest::TestInterstitial(
181 bool is_wifi_connection, 181 bool is_wifi_connection,
182 const std::string& wifi_ssid, 182 const std::string& wifi_ssid,
183 const GURL& login_url, 183 const GURL& login_url,
184 ExpectWiFi expect_wifi, 184 ExpectWiFi expect_wifi,
185 ExpectWiFiSSID expect_wifi_ssid, 185 ExpectWiFiSSID expect_wifi_ssid,
186 ExpectLoginURL expect_login_url) { 186 ExpectLoginURL expect_login_url) {
187 TestInterstitial(is_wifi_connection, wifi_ssid, login_url, expect_wifi, 187 TestInterstitial(is_wifi_connection, wifi_ssid, login_url, expect_wifi,
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 false, ""); 336 false, "");
337 return blocking_page; 337 return blocking_page;
338 } 338 }
339 }; 339 };
340 340
341 // Test that an IDN login domain is decoded properly. 341 // Test that an IDN login domain is decoded properly.
342 IN_PROC_BROWSER_TEST_F(CaptivePortalBlockingPageIDNTest, 342 IN_PROC_BROWSER_TEST_F(CaptivePortalBlockingPageIDNTest,
343 ShowLoginIDNIfPortalRedirectsDetectionURL) { 343 ShowLoginIDNIfPortalRedirectsDetectionURL) {
344 EXPECT_TRUE(VerifyIDNDecoded()); 344 EXPECT_TRUE(VerifyIDNDecoded());
345 } 345 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698