OLD | NEW |
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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
7 #include "base/synchronization/waitable_event.h" | 7 #include "base/synchronization/waitable_event.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/ssl/ssl_client_auth_requestor_mock.h" | 9 #include "chrome/browser/ssl/ssl_client_auth_requestor_mock.h" |
10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 SSLClientCertificateSelectorTest() | 39 SSLClientCertificateSelectorTest() |
40 : io_loop_finished_event_(false, false), | 40 : io_loop_finished_event_(false, false), |
41 url_request_(NULL), | 41 url_request_(NULL), |
42 selector_(NULL) { | 42 selector_(NULL) { |
43 } | 43 } |
44 | 44 |
45 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 45 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
46 base::FilePath certs_dir = net::GetTestCertsDirectory(); | 46 base::FilePath certs_dir = net::GetTestCertsDirectory(); |
47 | 47 |
48 mit_davidben_cert_ = net::ImportCertFromFile(certs_dir, "mit.davidben.der"); | 48 mit_davidben_cert_ = net::ImportCertFromFile(certs_dir, "mit.davidben.der"); |
49 ASSERT_NE(static_cast<net::X509Certificate*>(NULL), mit_davidben_cert_); | 49 ASSERT_NE(static_cast<net::X509Certificate*>(NULL), |
| 50 mit_davidben_cert_.get()); |
50 | 51 |
51 foaf_me_chromium_test_cert_ = net::ImportCertFromFile( | 52 foaf_me_chromium_test_cert_ = net::ImportCertFromFile( |
52 certs_dir, "foaf.me.chromium-test-cert.der"); | 53 certs_dir, "foaf.me.chromium-test-cert.der"); |
53 ASSERT_NE(static_cast<net::X509Certificate*>(NULL), | 54 ASSERT_NE(static_cast<net::X509Certificate*>(NULL), |
54 foaf_me_chromium_test_cert_); | 55 foaf_me_chromium_test_cert_.get()); |
55 | 56 |
56 cert_request_info_ = new net::SSLCertRequestInfo; | 57 cert_request_info_ = new net::SSLCertRequestInfo; |
57 cert_request_info_->host_and_port = net::HostPortPair("foo", 123); | 58 cert_request_info_->host_and_port = net::HostPortPair("foo", 123); |
58 cert_request_info_->client_certs.push_back(mit_davidben_cert_); | 59 cert_request_info_->client_certs.push_back(mit_davidben_cert_); |
59 cert_request_info_->client_certs.push_back(foaf_me_chromium_test_cert_); | 60 cert_request_info_->client_certs.push_back(foaf_me_chromium_test_cert_); |
60 } | 61 } |
61 | 62 |
62 virtual void SetUpOnMainThread() OVERRIDE { | 63 virtual void SetUpOnMainThread() OVERRIDE { |
63 url_request_context_getter_ = browser()->profile()->GetRequestContext(); | 64 url_request_context_getter_ = browser()->profile()->GetRequestContext(); |
64 | 65 |
(...skipping 10 matching lines...) Expand all Loading... |
75 auth_requestor_->http_network_session_, | 76 auth_requestor_->http_network_session_, |
76 auth_requestor_->cert_request_info_, | 77 auth_requestor_->cert_request_info_, |
77 base::Bind(&SSLClientAuthRequestorMock::CertificateSelected, | 78 base::Bind(&SSLClientAuthRequestorMock::CertificateSelected, |
78 auth_requestor_)); | 79 auth_requestor_)); |
79 selector_->Init(); | 80 selector_->Init(); |
80 | 81 |
81 EXPECT_EQ(mit_davidben_cert_.get(), selector_->GetSelectedCert()); | 82 EXPECT_EQ(mit_davidben_cert_.get(), selector_->GetSelectedCert()); |
82 } | 83 } |
83 | 84 |
84 virtual void SetUpOnIOThread() { | 85 virtual void SetUpOnIOThread() { |
85 url_request_ = MakeURLRequest(url_request_context_getter_).release(); | 86 url_request_ = MakeURLRequest(url_request_context_getter_.get()).release(); |
86 | 87 |
87 auth_requestor_ = new StrictMock<SSLClientAuthRequestorMock>( | 88 auth_requestor_ = new StrictMock<SSLClientAuthRequestorMock>( |
88 url_request_, | 89 url_request_, |
89 cert_request_info_); | 90 cert_request_info_); |
90 | 91 |
91 io_loop_finished_event_.Signal(); | 92 io_loop_finished_event_.Signal(); |
92 } | 93 } |
93 | 94 |
94 // Have to release our reference to the auth handler during the test to allow | 95 // Have to release our reference to the auth handler during the test to allow |
95 // it to be destroyed while the Browser and its IO thread still exist. | 96 // it to be destroyed while the Browser and its IO thread still exist. |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 base::Bind(&SSLClientAuthRequestorMock::CertificateSelected, | 173 base::Bind(&SSLClientAuthRequestorMock::CertificateSelected, |
173 auth_requestor_2_)); | 174 auth_requestor_2_)); |
174 selector_2_->Init(); | 175 selector_2_->Init(); |
175 | 176 |
176 EXPECT_EQ(2, browser()->tab_strip_model()->active_index()); | 177 EXPECT_EQ(2, browser()->tab_strip_model()->active_index()); |
177 EXPECT_EQ(mit_davidben_cert_.get(), selector_1_->GetSelectedCert()); | 178 EXPECT_EQ(mit_davidben_cert_.get(), selector_1_->GetSelectedCert()); |
178 EXPECT_EQ(mit_davidben_cert_.get(), selector_2_->GetSelectedCert()); | 179 EXPECT_EQ(mit_davidben_cert_.get(), selector_2_->GetSelectedCert()); |
179 } | 180 } |
180 | 181 |
181 virtual void SetUpOnIOThread() OVERRIDE { | 182 virtual void SetUpOnIOThread() OVERRIDE { |
182 url_request_1_ = MakeURLRequest(url_request_context_getter_).release(); | 183 url_request_1_ = |
183 url_request_2_ = MakeURLRequest(url_request_context_getter_).release(); | 184 MakeURLRequest(url_request_context_getter_.get()).release(); |
| 185 url_request_2_ = |
| 186 MakeURLRequest(url_request_context_getter_.get()).release(); |
184 | 187 |
185 auth_requestor_1_ = new StrictMock<SSLClientAuthRequestorMock>( | 188 auth_requestor_1_ = new StrictMock<SSLClientAuthRequestorMock>( |
186 url_request_1_, | 189 url_request_1_, |
187 cert_request_info_1_); | 190 cert_request_info_1_); |
188 auth_requestor_2_ = new StrictMock<SSLClientAuthRequestorMock>( | 191 auth_requestor_2_ = new StrictMock<SSLClientAuthRequestorMock>( |
189 url_request_2_, | 192 url_request_2_, |
190 cert_request_info_2_); | 193 cert_request_info_2_); |
191 | 194 |
192 SSLClientCertificateSelectorTest::SetUpOnIOThread(); | 195 SSLClientCertificateSelectorTest::SetUpOnIOThread(); |
193 } | 196 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 auth_requestor_1_->http_network_session_, | 242 auth_requestor_1_->http_network_session_, |
240 auth_requestor_1_->cert_request_info_, | 243 auth_requestor_1_->cert_request_info_, |
241 base::Bind(&SSLClientAuthRequestorMock::CertificateSelected, | 244 base::Bind(&SSLClientAuthRequestorMock::CertificateSelected, |
242 auth_requestor_1_)); | 245 auth_requestor_1_)); |
243 selector_1_->Init(); | 246 selector_1_->Init(); |
244 | 247 |
245 EXPECT_EQ(mit_davidben_cert_.get(), selector_1_->GetSelectedCert()); | 248 EXPECT_EQ(mit_davidben_cert_.get(), selector_1_->GetSelectedCert()); |
246 } | 249 } |
247 | 250 |
248 virtual void SetUpOnIOThread() OVERRIDE { | 251 virtual void SetUpOnIOThread() OVERRIDE { |
249 url_request_1_ = MakeURLRequest(url_request_context_getter_1_).release(); | 252 url_request_1_ = |
| 253 MakeURLRequest(url_request_context_getter_1_.get()).release(); |
250 | 254 |
251 auth_requestor_1_ = new StrictMock<SSLClientAuthRequestorMock>( | 255 auth_requestor_1_ = new StrictMock<SSLClientAuthRequestorMock>( |
252 url_request_1_, | 256 url_request_1_, |
253 cert_request_info_1_); | 257 cert_request_info_1_); |
254 | 258 |
255 SSLClientCertificateSelectorTest::SetUpOnIOThread(); | 259 SSLClientCertificateSelectorTest::SetUpOnIOThread(); |
256 } | 260 } |
257 | 261 |
258 virtual void TearDownOnMainThread() OVERRIDE { | 262 virtual void TearDownOnMainThread() OVERRIDE { |
259 auth_requestor_1_ = NULL; | 263 auth_requestor_1_ = NULL; |
(...skipping 16 matching lines...) Expand all Loading... |
276 | 280 |
277 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_AURA) | 281 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_AURA) |
278 // TODO(erg): linux_aura bringup: http://crbug.com/163931 | 282 // TODO(erg): linux_aura bringup: http://crbug.com/163931 |
279 #define MAYBE_SelectNone DISABLED_SelectNone | 283 #define MAYBE_SelectNone DISABLED_SelectNone |
280 #else | 284 #else |
281 #define MAYBE_SelectNone SelectNone | 285 #define MAYBE_SelectNone SelectNone |
282 #endif | 286 #endif |
283 | 287 |
284 | 288 |
285 IN_PROC_BROWSER_TEST_F(SSLClientCertificateSelectorTest, MAYBE_SelectNone) { | 289 IN_PROC_BROWSER_TEST_F(SSLClientCertificateSelectorTest, MAYBE_SelectNone) { |
286 EXPECT_CALL(*auth_requestor_, CertificateSelected(NULL)); | 290 EXPECT_CALL(*auth_requestor_.get(), CertificateSelected(NULL)); |
287 | 291 |
288 // Let the mock get checked on destruction. | 292 // Let the mock get checked on destruction. |
289 } | 293 } |
290 | 294 |
291 // http://crbug.com/121007 | 295 // http://crbug.com/121007 |
292 IN_PROC_BROWSER_TEST_F(SSLClientCertificateSelectorTest, DISABLED_Escape) { | 296 IN_PROC_BROWSER_TEST_F(SSLClientCertificateSelectorTest, DISABLED_Escape) { |
293 EXPECT_CALL(*auth_requestor_, CertificateSelected(NULL)); | 297 EXPECT_CALL(*auth_requestor_.get(), CertificateSelected(NULL)); |
294 | 298 |
295 EXPECT_TRUE(ui_test_utils::SendKeyPressSync( | 299 EXPECT_TRUE(ui_test_utils::SendKeyPressSync( |
296 browser(), ui::VKEY_ESCAPE, false, false, false, false)); | 300 browser(), ui::VKEY_ESCAPE, false, false, false, false)); |
297 | 301 |
298 Mock::VerifyAndClear(auth_requestor_.get()); | 302 Mock::VerifyAndClear(auth_requestor_.get()); |
299 } | 303 } |
300 | 304 |
301 // Flaky, http://crbug.com/103534 . | 305 // Flaky, http://crbug.com/103534 . |
302 IN_PROC_BROWSER_TEST_F(SSLClientCertificateSelectorTest, | 306 IN_PROC_BROWSER_TEST_F(SSLClientCertificateSelectorTest, |
303 DISABLED_SelectDefault) { | 307 DISABLED_SelectDefault) { |
304 EXPECT_CALL(*auth_requestor_, CertificateSelected(mit_davidben_cert_.get())); | 308 EXPECT_CALL(*auth_requestor_.get(), |
| 309 CertificateSelected(mit_davidben_cert_.get())); |
305 | 310 |
306 EXPECT_TRUE(ui_test_utils::SendKeyPressSync( | 311 EXPECT_TRUE(ui_test_utils::SendKeyPressSync( |
307 browser(), ui::VKEY_RETURN, false, false, false, false)); | 312 browser(), ui::VKEY_RETURN, false, false, false, false)); |
308 | 313 |
309 Mock::VerifyAndClear(auth_requestor_.get()); | 314 Mock::VerifyAndClear(auth_requestor_.get()); |
310 } | 315 } |
311 | 316 |
312 // http://crbug.com/121007 | 317 // http://crbug.com/121007 |
313 IN_PROC_BROWSER_TEST_F(SSLClientCertificateSelectorMultiTabTest, | 318 IN_PROC_BROWSER_TEST_F(SSLClientCertificateSelectorMultiTabTest, |
314 DISABLED_Escape) { | 319 DISABLED_Escape) { |
315 // auth_requestor_1_ should get selected automatically by the | 320 // auth_requestor_1_ should get selected automatically by the |
316 // SSLClientAuthObserver when selector_2_ is accepted, since both 1 & 2 have | 321 // SSLClientAuthObserver when selector_2_ is accepted, since both 1 & 2 have |
317 // the same host:port. | 322 // the same host:port. |
318 EXPECT_CALL(*auth_requestor_1_, CertificateSelected(NULL)); | 323 EXPECT_CALL(*auth_requestor_1_.get(), CertificateSelected(NULL)); |
319 EXPECT_CALL(*auth_requestor_2_, CertificateSelected(NULL)); | 324 EXPECT_CALL(*auth_requestor_2_.get(), CertificateSelected(NULL)); |
320 | 325 |
321 EXPECT_TRUE(ui_test_utils::SendKeyPressSync( | 326 EXPECT_TRUE(ui_test_utils::SendKeyPressSync( |
322 browser(), ui::VKEY_ESCAPE, false, false, false, false)); | 327 browser(), ui::VKEY_ESCAPE, false, false, false, false)); |
323 | 328 |
324 Mock::VerifyAndClear(auth_requestor_.get()); | 329 Mock::VerifyAndClear(auth_requestor_.get()); |
325 Mock::VerifyAndClear(auth_requestor_1_.get()); | 330 Mock::VerifyAndClear(auth_requestor_1_.get()); |
326 Mock::VerifyAndClear(auth_requestor_2_.get()); | 331 Mock::VerifyAndClear(auth_requestor_2_.get()); |
327 | 332 |
328 // Now let the default selection for auth_requestor_ mock get checked on | 333 // Now let the default selection for auth_requestor_ mock get checked on |
329 // destruction. | 334 // destruction. |
330 EXPECT_CALL(*auth_requestor_, CertificateSelected(NULL)); | 335 EXPECT_CALL(*auth_requestor_.get(), CertificateSelected(NULL)); |
331 } | 336 } |
332 | 337 |
333 // http://crbug.com/121007 | 338 // http://crbug.com/121007 |
334 IN_PROC_BROWSER_TEST_F(SSLClientCertificateSelectorMultiTabTest, | 339 IN_PROC_BROWSER_TEST_F(SSLClientCertificateSelectorMultiTabTest, |
335 DISABLED_SelectSecond) { | 340 DISABLED_SelectSecond) { |
336 // auth_requestor_1_ should get selected automatically by the | 341 // auth_requestor_1_ should get selected automatically by the |
337 // SSLClientAuthObserver when selector_2_ is accepted, since both 1 & 2 have | 342 // SSLClientAuthObserver when selector_2_ is accepted, since both 1 & 2 have |
338 // the same host:port. | 343 // the same host:port. |
339 EXPECT_CALL(*auth_requestor_1_, | 344 EXPECT_CALL(*auth_requestor_1_.get(), |
340 CertificateSelected(foaf_me_chromium_test_cert_.get())); | 345 CertificateSelected(foaf_me_chromium_test_cert_.get())); |
341 EXPECT_CALL(*auth_requestor_2_, | 346 EXPECT_CALL(*auth_requestor_2_.get(), |
342 CertificateSelected(foaf_me_chromium_test_cert_.get())); | 347 CertificateSelected(foaf_me_chromium_test_cert_.get())); |
343 | 348 |
344 EXPECT_TRUE(ui_test_utils::SendKeyPressSync( | 349 EXPECT_TRUE(ui_test_utils::SendKeyPressSync( |
345 browser(), ui::VKEY_DOWN, false, false, false, false)); | 350 browser(), ui::VKEY_DOWN, false, false, false, false)); |
346 | 351 |
347 EXPECT_EQ(mit_davidben_cert_.get(), selector_->GetSelectedCert()); | 352 EXPECT_EQ(mit_davidben_cert_.get(), selector_->GetSelectedCert()); |
348 EXPECT_EQ(mit_davidben_cert_.get(), selector_1_->GetSelectedCert()); | 353 EXPECT_EQ(mit_davidben_cert_.get(), selector_1_->GetSelectedCert()); |
349 EXPECT_EQ(foaf_me_chromium_test_cert_.get(), selector_2_->GetSelectedCert()); | 354 EXPECT_EQ(foaf_me_chromium_test_cert_.get(), selector_2_->GetSelectedCert()); |
350 | 355 |
351 EXPECT_TRUE(ui_test_utils::SendKeyPressSync( | 356 EXPECT_TRUE(ui_test_utils::SendKeyPressSync( |
352 browser(), ui::VKEY_RETURN, false, false, false, false)); | 357 browser(), ui::VKEY_RETURN, false, false, false, false)); |
353 | 358 |
354 Mock::VerifyAndClear(auth_requestor_.get()); | 359 Mock::VerifyAndClear(auth_requestor_.get()); |
355 Mock::VerifyAndClear(auth_requestor_1_.get()); | 360 Mock::VerifyAndClear(auth_requestor_1_.get()); |
356 Mock::VerifyAndClear(auth_requestor_2_.get()); | 361 Mock::VerifyAndClear(auth_requestor_2_.get()); |
357 | 362 |
358 // Now let the default selection for auth_requestor_ mock get checked on | 363 // Now let the default selection for auth_requestor_ mock get checked on |
359 // destruction. | 364 // destruction. |
360 EXPECT_CALL(*auth_requestor_, CertificateSelected(NULL)); | 365 EXPECT_CALL(*auth_requestor_.get(), CertificateSelected(NULL)); |
361 } | 366 } |
362 | 367 |
363 // http://crbug.com/103529 | 368 // http://crbug.com/103529 |
364 IN_PROC_BROWSER_TEST_F(SSLClientCertificateSelectorMultiProfileTest, | 369 IN_PROC_BROWSER_TEST_F(SSLClientCertificateSelectorMultiProfileTest, |
365 DISABLED_Escape) { | 370 DISABLED_Escape) { |
366 EXPECT_CALL(*auth_requestor_1_, CertificateSelected(NULL)); | 371 EXPECT_CALL(*auth_requestor_1_.get(), CertificateSelected(NULL)); |
367 | 372 |
368 EXPECT_TRUE(ui_test_utils::SendKeyPressSync( | 373 EXPECT_TRUE(ui_test_utils::SendKeyPressSync( |
369 browser_1_, ui::VKEY_ESCAPE, false, false, false, false)); | 374 browser_1_, ui::VKEY_ESCAPE, false, false, false, false)); |
370 | 375 |
371 Mock::VerifyAndClear(auth_requestor_.get()); | 376 Mock::VerifyAndClear(auth_requestor_.get()); |
372 Mock::VerifyAndClear(auth_requestor_1_.get()); | 377 Mock::VerifyAndClear(auth_requestor_1_.get()); |
373 | 378 |
374 // Now let the default selection for auth_requestor_ mock get checked on | 379 // Now let the default selection for auth_requestor_ mock get checked on |
375 // destruction. | 380 // destruction. |
376 EXPECT_CALL(*auth_requestor_, CertificateSelected(NULL)); | 381 EXPECT_CALL(*auth_requestor_.get(), CertificateSelected(NULL)); |
377 } | 382 } |
378 | 383 |
379 // http://crbug.com/103534 | 384 // http://crbug.com/103534 |
380 IN_PROC_BROWSER_TEST_F(SSLClientCertificateSelectorMultiProfileTest, | 385 IN_PROC_BROWSER_TEST_F(SSLClientCertificateSelectorMultiProfileTest, |
381 DISABLED_SelectDefault) { | 386 DISABLED_SelectDefault) { |
382 EXPECT_CALL(*auth_requestor_1_, | 387 EXPECT_CALL(*auth_requestor_1_.get(), |
383 CertificateSelected(mit_davidben_cert_.get())); | 388 CertificateSelected(mit_davidben_cert_.get())); |
384 | 389 |
385 EXPECT_TRUE(ui_test_utils::SendKeyPressSync( | 390 EXPECT_TRUE(ui_test_utils::SendKeyPressSync( |
386 browser_1_, ui::VKEY_RETURN, false, false, false, false)); | 391 browser_1_, ui::VKEY_RETURN, false, false, false, false)); |
387 | 392 |
388 Mock::VerifyAndClear(auth_requestor_.get()); | 393 Mock::VerifyAndClear(auth_requestor_.get()); |
389 Mock::VerifyAndClear(auth_requestor_1_.get()); | 394 Mock::VerifyAndClear(auth_requestor_1_.get()); |
390 | 395 |
391 // Now let the default selection for auth_requestor_ mock get checked on | 396 // Now let the default selection for auth_requestor_ mock get checked on |
392 // destruction. | 397 // destruction. |
393 EXPECT_CALL(*auth_requestor_, CertificateSelected(NULL)); | 398 EXPECT_CALL(*auth_requestor_.get(), CertificateSelected(NULL)); |
394 } | 399 } |
OLD | NEW |