Index: net/http/http_auth_controller_unittest.cc |
diff --git a/net/http/http_auth_controller_unittest.cc b/net/http/http_auth_controller_unittest.cc |
index 1a59b8d4f68d9d8d172169b561d0177710d3ae71..749ec9532fbabb0fdbbbcc9b0d943f39087919c4 100644 |
--- a/net/http/http_auth_controller_unittest.cc |
+++ b/net/http/http_auth_controller_unittest.cc |
@@ -20,20 +20,14 @@ namespace net { |
namespace { |
-enum HandlerRunMode { |
- RUN_HANDLER_SYNC, |
- RUN_HANDLER_ASYNC |
-}; |
+enum HandlerRunMode { RUN_HANDLER_SYNC, RUN_HANDLER_ASYNC }; |
-enum SchemeState { |
- SCHEME_IS_DISABLED, |
- SCHEME_IS_ENABLED |
-}; |
+enum SchemeState { SCHEME_IS_DISABLED, SCHEME_IS_ENABLED }; |
scoped_refptr<HttpResponseHeaders> HeadersFromString(const char* string) { |
std::string raw_string(string); |
- std::string headers_string = HttpUtil::AssembleRawHeaders( |
- raw_string.c_str(), raw_string.length()); |
+ std::string headers_string = |
+ HttpUtil::AssembleRawHeaders(raw_string.c_str(), raw_string.length()); |
scoped_refptr<HttpResponseHeaders> headers( |
new HttpResponseHeaders(headers_string)); |
return headers; |
@@ -71,7 +65,8 @@ void RunSingleRoundAuthTest(HandlerRunMode run_mode, |
scoped_refptr<HttpAuthController> controller( |
new HttpAuthController(HttpAuth::AUTH_PROXY, |
GURL("http://example.com"), |
- &dummy_auth_cache, &auth_handler_factory)); |
+ &dummy_auth_cache, |
+ &auth_handler_factory)); |
ASSERT_EQ(OK, |
controller->HandleAuthChallenge(headers, false, false, dummy_log)); |
ASSERT_TRUE(controller->HaveAuthHandler()); |
@@ -79,10 +74,10 @@ void RunSingleRoundAuthTest(HandlerRunMode run_mode, |
EXPECT_TRUE(controller->HaveAuth()); |
TestCompletionCallback callback; |
- EXPECT_EQ((run_mode == RUN_HANDLER_ASYNC)? ERR_IO_PENDING: |
- expected_controller_rv, |
- controller->MaybeGenerateAuthToken(&request, callback.callback(), |
- dummy_log)); |
+ EXPECT_EQ( |
+ (run_mode == RUN_HANDLER_ASYNC) ? ERR_IO_PENDING : expected_controller_rv, |
+ controller->MaybeGenerateAuthToken( |
+ &request, callback.callback(), dummy_log)); |
if (run_mode == RUN_HANDLER_ASYNC) |
EXPECT_EQ(expected_controller_rv, callback.WaitForResult()); |
EXPECT_EQ((scheme_state == SCHEME_IS_DISABLED), |
@@ -95,25 +90,27 @@ void RunSingleRoundAuthTest(HandlerRunMode run_mode, |
// permanent error, the HttpAuthController should disable the scheme |
// used and retry the request. |
TEST(HttpAuthControllerTest, PermanentErrors) { |
- |
// Run a synchronous handler that returns |
// ERR_UNEXPECTED_SECURITY_LIBRARY_STATUS. We expect a return value |
// of OK from the controller so we can retry the request. |
RunSingleRoundAuthTest(RUN_HANDLER_SYNC, |
ERR_UNEXPECTED_SECURITY_LIBRARY_STATUS, |
- OK, SCHEME_IS_DISABLED); |
+ OK, |
+ SCHEME_IS_DISABLED); |
// Now try an async handler that returns |
// ERR_MISSING_AUTH_CREDENTIALS. Async and sync handlers invoke |
// different code paths in HttpAuthController when generating |
// tokens. |
- RunSingleRoundAuthTest(RUN_HANDLER_ASYNC, ERR_MISSING_AUTH_CREDENTIALS, OK, |
- SCHEME_IS_DISABLED); |
+ RunSingleRoundAuthTest( |
+ RUN_HANDLER_ASYNC, ERR_MISSING_AUTH_CREDENTIALS, OK, SCHEME_IS_DISABLED); |
// If a non-permanent error is returned by the handler, then the |
// controller should report it unchanged. |
- RunSingleRoundAuthTest(RUN_HANDLER_ASYNC, ERR_INVALID_AUTH_CREDENTIALS, |
- ERR_INVALID_AUTH_CREDENTIALS, SCHEME_IS_ENABLED); |
+ RunSingleRoundAuthTest(RUN_HANDLER_ASYNC, |
+ ERR_INVALID_AUTH_CREDENTIALS, |
+ ERR_INVALID_AUTH_CREDENTIALS, |
+ SCHEME_IS_ENABLED); |
} |
// If an HttpAuthHandler indicates that it doesn't allow explicit |
@@ -147,12 +144,9 @@ TEST(HttpAuthControllerTest, NoExplicitCredentialsAllowed) { |
const HttpRequestInfo* request, |
const CompletionCallback& callback, |
std::string* auth_token) OVERRIDE { |
- int result = |
- HttpAuthHandlerMock::GenerateAuthTokenImpl(credentials, |
- request, callback, |
- auth_token); |
- EXPECT_TRUE(result != OK || |
- !AllowsExplicitCredentials() || |
+ int result = HttpAuthHandlerMock::GenerateAuthTokenImpl( |
+ credentials, request, callback, auth_token); |
+ EXPECT_TRUE(result != OK || !AllowsExplicitCredentials() || |
!credentials->Empty()); |
return result; |
} |
@@ -201,14 +195,14 @@ TEST(HttpAuthControllerTest, NoExplicitCredentialsAllowed) { |
new MockHandler(ERR_UNEXPECTED, HttpAuth::AUTH_SCHEME_MOCK), |
HttpAuth::AUTH_SERVER); |
auth_handler_factory.AddMockHandler( |
- new MockHandler(OK, HttpAuth::AUTH_SCHEME_BASIC), |
- HttpAuth::AUTH_SERVER); |
+ new MockHandler(OK, HttpAuth::AUTH_SCHEME_BASIC), HttpAuth::AUTH_SERVER); |
auth_handler_factory.set_do_init_from_challenge(true); |
scoped_refptr<HttpAuthController> controller( |
new HttpAuthController(HttpAuth::AUTH_SERVER, |
GURL("http://example.com"), |
- &dummy_auth_cache, &auth_handler_factory)); |
+ &dummy_auth_cache, |
+ &auth_handler_factory)); |
ASSERT_EQ(OK, |
controller->HandleAuthChallenge(headers, false, false, dummy_log)); |
ASSERT_TRUE(controller->HaveAuthHandler()); |
@@ -216,8 +210,9 @@ TEST(HttpAuthControllerTest, NoExplicitCredentialsAllowed) { |
EXPECT_TRUE(controller->HaveAuth()); |
// Should only succeed if we are using the AUTH_SCHEME_MOCK MockHandler. |
- EXPECT_EQ(OK, controller->MaybeGenerateAuthToken( |
- &request, CompletionCallback(), dummy_log)); |
+ EXPECT_EQ(OK, |
+ controller->MaybeGenerateAuthToken( |
+ &request, CompletionCallback(), dummy_log)); |
controller->AddAuthorizationHeader(&request_headers); |
// Once a token is generated, simulate the receipt of a server response |
@@ -225,15 +220,16 @@ TEST(HttpAuthControllerTest, NoExplicitCredentialsAllowed) { |
ASSERT_EQ(OK, |
controller->HandleAuthChallenge(headers, false, false, dummy_log)); |
ASSERT_TRUE(controller->HaveAuthHandler()); |
- controller->ResetAuth(AuthCredentials(base::ASCIIToUTF16("Hello"), |
- base::string16())); |
+ controller->ResetAuth( |
+ AuthCredentials(base::ASCIIToUTF16("Hello"), base::string16())); |
EXPECT_TRUE(controller->HaveAuth()); |
EXPECT_TRUE(controller->IsAuthSchemeDisabled(HttpAuth::AUTH_SCHEME_MOCK)); |
EXPECT_FALSE(controller->IsAuthSchemeDisabled(HttpAuth::AUTH_SCHEME_BASIC)); |
// Should only succeed if we are using the AUTH_SCHEME_BASIC MockHandler. |
- EXPECT_EQ(OK, controller->MaybeGenerateAuthToken( |
- &request, CompletionCallback(), dummy_log)); |
+ EXPECT_EQ(OK, |
+ controller->MaybeGenerateAuthToken( |
+ &request, CompletionCallback(), dummy_log)); |
} |
} // namespace net |