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

Side by Side Diff: ios/web/web_state/http_auth_inttest.mm

Issue 2721553004: Remove auto raw pointer deduction from non-linux specific code. (Closed)
Patch Set: rebase Created 3 years, 9 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/memory/ptr_util.h" 5 #include "base/memory/ptr_util.h"
6 #include "base/strings/sys_string_conversions.h" 6 #include "base/strings/sys_string_conversions.h"
7 #include "base/test/ios/wait_util.h" 7 #include "base/test/ios/wait_util.h"
8 #import "ios/web/public/navigation_manager.h" 8 #import "ios/web/public/navigation_manager.h"
9 #import "ios/web/public/test/http_server.h" 9 #import "ios/web/public/test/http_server.h"
10 #include "ios/web/public/test/http_server_util.h" 10 #include "ios/web/public/test/http_server_util.h"
(...skipping 20 matching lines...) Expand all
31 // Loads a page with URL and waits for OnAuthRequired callback. 31 // Loads a page with URL and waits for OnAuthRequired callback.
32 void LoadUrlWithAuthChallenge(const GURL& url) { 32 void LoadUrlWithAuthChallenge(const GURL& url) {
33 NavigationManager::WebLoadParams params(url); 33 NavigationManager::WebLoadParams params(url);
34 navigation_manager()->LoadURLWithParams(params); 34 navigation_manager()->LoadURLWithParams(params);
35 WaitForOnAuthRequiredCallback(); 35 WaitForOnAuthRequiredCallback();
36 } 36 }
37 37
38 // Authenticates and waits until the page finishes loading. 38 // Authenticates and waits until the page finishes loading.
39 void Authenticate(NSString* username, NSString* password) { 39 void Authenticate(NSString* username, NSString* password) {
40 ASSERT_TRUE(web_state()->IsLoading()); 40 ASSERT_TRUE(web_state()->IsLoading());
41 auto auth_request = web_state_delegate_.last_authentication_request(); 41 auto* auth_request = web_state_delegate_.last_authentication_request();
42 auth_request->auth_callback.Run(username, password); 42 auth_request->auth_callback.Run(username, password);
43 base::test::ios::WaitUntilCondition(^bool { 43 base::test::ios::WaitUntilCondition(^bool {
44 return !web_state()->IsLoading(); 44 return !web_state()->IsLoading();
45 }); 45 });
46 } 46 }
47 }; 47 };
48 48
49 // Tests successful basic authentication. 49 // Tests successful basic authentication.
50 TEST_F(HttpAuthTest, SuccessfullBasicAuth) { 50 TEST_F(HttpAuthTest, SuccessfullBasicAuth) {
51 // Load the page which requests basic HTTP authentication. 51 // Load the page which requests basic HTTP authentication.
52 GURL url = HttpServer::MakeUrl("http://good-auth"); 52 GURL url = HttpServer::MakeUrl("http://good-auth");
53 test::SetUpHttpServer(base::MakeUnique<HttpAuthResponseProvider>( 53 test::SetUpHttpServer(base::MakeUnique<HttpAuthResponseProvider>(
54 url, "GoodRealm", "gooduser", "goodpass")); 54 url, "GoodRealm", "gooduser", "goodpass"));
55 LoadUrlWithAuthChallenge(url); 55 LoadUrlWithAuthChallenge(url);
56 56
57 // Verify that callback receives correct WebState. 57 // Verify that callback receives correct WebState.
58 auto auth_request = web_state_delegate_.last_authentication_request(); 58 auto* auth_request = web_state_delegate_.last_authentication_request();
59 EXPECT_EQ(web_state(), auth_request->web_state); 59 EXPECT_EQ(web_state(), auth_request->web_state);
60 60
61 // Verify that callback receives correctly configured protection space. 61 // Verify that callback receives correctly configured protection space.
62 NSURLProtectionSpace* protection_space = auth_request->protection_space; 62 NSURLProtectionSpace* protection_space = auth_request->protection_space;
63 EXPECT_NSEQ(@"GoodRealm", protection_space.realm); 63 EXPECT_NSEQ(@"GoodRealm", protection_space.realm);
64 EXPECT_FALSE(protection_space.receivesCredentialSecurely); 64 EXPECT_FALSE(protection_space.receivesCredentialSecurely);
65 EXPECT_FALSE([protection_space isProxy]); 65 EXPECT_FALSE([protection_space isProxy]);
66 EXPECT_EQ(url.host(), base::SysNSStringToUTF8(protection_space.host)); 66 EXPECT_EQ(url.host(), base::SysNSStringToUTF8(protection_space.host));
67 EXPECT_EQ( 67 EXPECT_EQ(
68 base::checked_cast<uint16_t>(HttpServer::GetSharedInstance().GetPort()), 68 base::checked_cast<uint16_t>(HttpServer::GetSharedInstance().GetPort()),
(...skipping 12 matching lines...) Expand all
81 81
82 // Tests unsuccessful basic authentication. 82 // Tests unsuccessful basic authentication.
83 TEST_F(HttpAuthTest, UnsucessfulBasicAuth) { 83 TEST_F(HttpAuthTest, UnsucessfulBasicAuth) {
84 // Load the page which requests basic HTTP authentication. 84 // Load the page which requests basic HTTP authentication.
85 GURL url = HttpServer::MakeUrl("http://bad-auth"); 85 GURL url = HttpServer::MakeUrl("http://bad-auth");
86 test::SetUpHttpServer(base::MakeUnique<HttpAuthResponseProvider>( 86 test::SetUpHttpServer(base::MakeUnique<HttpAuthResponseProvider>(
87 url, "BadRealm", "baduser", "badpass")); 87 url, "BadRealm", "baduser", "badpass"));
88 LoadUrlWithAuthChallenge(url); 88 LoadUrlWithAuthChallenge(url);
89 89
90 // Make sure that incorrect credentials request authentication again. 90 // Make sure that incorrect credentials request authentication again.
91 auto auth_request = web_state_delegate_.last_authentication_request(); 91 auto* auth_request = web_state_delegate_.last_authentication_request();
92 auth_request->auth_callback.Run(@"gooduser", @"goodpass"); 92 auth_request->auth_callback.Run(@"gooduser", @"goodpass");
93 WaitForOnAuthRequiredCallback(); 93 WaitForOnAuthRequiredCallback();
94 94
95 // Verify that callback receives correct WebState. 95 // Verify that callback receives correct WebState.
96 auth_request = web_state_delegate_.last_authentication_request(); 96 auth_request = web_state_delegate_.last_authentication_request();
97 EXPECT_EQ(web_state(), auth_request->web_state); 97 EXPECT_EQ(web_state(), auth_request->web_state);
98 98
99 // Verify that callback receives correctly configured protection space. 99 // Verify that callback receives correctly configured protection space.
100 NSURLProtectionSpace* protection_space = auth_request->protection_space; 100 NSURLProtectionSpace* protection_space = auth_request->protection_space;
101 EXPECT_NSEQ(@"BadRealm", protection_space.realm); 101 EXPECT_NSEQ(@"BadRealm", protection_space.realm);
(...skipping 10 matching lines...) Expand all
112 112
113 // Cancel authentication and make sure that the page is blank. 113 // Cancel authentication and make sure that the page is blank.
114 auth_request->auth_callback.Run(nil, nil); 114 auth_request->auth_callback.Run(nil, nil);
115 base::test::ios::WaitUntilCondition(^bool { 115 base::test::ios::WaitUntilCondition(^bool {
116 return !web_state()->IsLoading(); 116 return !web_state()->IsLoading();
117 }); 117 });
118 EXPECT_FALSE(ExecuteJavaScript(@"window.document")); 118 EXPECT_FALSE(ExecuteJavaScript(@"window.document"));
119 } 119 }
120 120
121 } // web 121 } // web
OLDNEW
« no previous file with comments | « ios/chrome/browser/web/repost_form_tab_helper_unittest.mm ('k') | media/gpu/avda_codec_allocator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698