| Index: net/http/http_auth_handler_negotiate_unittest.cc
|
| diff --git a/net/http/http_auth_handler_negotiate_unittest.cc b/net/http/http_auth_handler_negotiate_unittest.cc
|
| index 64521a6177ff0d0045e9f3bcbcc0e9311138d584..9fe8710b8e8814c205efe7bc94b11298d1bc1232 100644
|
| --- a/net/http/http_auth_handler_negotiate_unittest.cc
|
| +++ b/net/http/http_auth_handler_negotiate_unittest.cc
|
| @@ -32,8 +32,8 @@ class HttpAuthHandlerNegotiateTest : public PlatformTest {
|
| virtual void SetUp() {
|
| auth_library_ = new MockAuthLibrary();
|
| resolver_.reset(new MockHostResolver());
|
| - resolver_->rules()->AddIPLiteralRule("alias", "10.0.0.2",
|
| - "canonical.example.com");
|
| + resolver_->rules()->AddIPLiteralRule(
|
| + "alias", "10.0.0.2", "canonical.example.com");
|
|
|
| url_security_manager_.reset(new MockAllowURLSecurityManager());
|
| factory_.reset(new HttpAuthHandlerNegotiate::Factory());
|
| @@ -98,36 +98,36 @@ class HttpAuthHandlerNegotiateTest : public PlatformTest {
|
| "\x69\xE3\x55\xF9\x30\xD3\xD4\x08\xC8\xCA\x62\xF8\x64\xEC\x9B\x92"
|
| "\x1A\xF1\x03\x2E\xCC\xDC\xEB\x17\xDE\x09\xAC\xA9\x58\x86";
|
| test::GssContextMockImpl context1(
|
| - "localhost", // Source name
|
| - "example.com", // Target name
|
| - 23, // Lifetime
|
| - *CHROME_GSS_SPNEGO_MECH_OID_DESC, // Mechanism
|
| - 0, // Context flags
|
| - 1, // Locally initiated
|
| - 0); // Open
|
| + "localhost", // Source name
|
| + "example.com", // Target name
|
| + 23, // Lifetime
|
| + *CHROME_GSS_SPNEGO_MECH_OID_DESC, // Mechanism
|
| + 0, // Context flags
|
| + 1, // Locally initiated
|
| + 0); // Open
|
| test::GssContextMockImpl context2(
|
| - "localhost", // Source name
|
| - "example.com", // Target name
|
| - 23, // Lifetime
|
| - *CHROME_GSS_SPNEGO_MECH_OID_DESC, // Mechanism
|
| - 0, // Context flags
|
| - 1, // Locally initiated
|
| - 1); // Open
|
| + "localhost", // Source name
|
| + "example.com", // Target name
|
| + 23, // Lifetime
|
| + *CHROME_GSS_SPNEGO_MECH_OID_DESC, // Mechanism
|
| + 0, // Context flags
|
| + 1, // Locally initiated
|
| + 1); // Open
|
| test::MockGSSAPILibrary::SecurityContextQuery queries[] = {
|
| - test::MockGSSAPILibrary::SecurityContextQuery(
|
| - "Negotiate", // Package name
|
| - GSS_S_CONTINUE_NEEDED, // Major response code
|
| - 0, // Minor response code
|
| - context1, // Context
|
| - NULL, // Expected input token
|
| - kAuthResponse), // Output token
|
| - test::MockGSSAPILibrary::SecurityContextQuery(
|
| - "Negotiate", // Package name
|
| - GSS_S_COMPLETE, // Major response code
|
| - 0, // Minor response code
|
| - context2, // Context
|
| - kAuthResponse, // Expected input token
|
| - kAuthResponse) // Output token
|
| + test::MockGSSAPILibrary::SecurityContextQuery(
|
| + "Negotiate", // Package name
|
| + GSS_S_CONTINUE_NEEDED, // Major response code
|
| + 0, // Minor response code
|
| + context1, // Context
|
| + NULL, // Expected input token
|
| + kAuthResponse), // Output token
|
| + test::MockGSSAPILibrary::SecurityContextQuery(
|
| + "Negotiate", // Package name
|
| + GSS_S_COMPLETE, // Major response code
|
| + 0, // Minor response code
|
| + context2, // Context
|
| + kAuthResponse, // Expected input token
|
| + kAuthResponse) // Output token
|
| };
|
|
|
| for (size_t i = 0; i < arraysize(queries); ++i) {
|
| @@ -145,22 +145,21 @@ class HttpAuthHandlerNegotiateTest : public PlatformTest {
|
| void SetupErrorMocks(MockAuthLibrary* mock_library,
|
| int major_status,
|
| int minor_status) {
|
| - const gss_OID_desc kDefaultMech = { 0, NULL };
|
| - test::GssContextMockImpl context(
|
| - "localhost", // Source name
|
| - "example.com", // Target name
|
| - 0, // Lifetime
|
| - kDefaultMech, // Mechanism
|
| - 0, // Context flags
|
| - 1, // Locally initiated
|
| - 0); // Open
|
| + const gss_OID_desc kDefaultMech = {0, NULL};
|
| + test::GssContextMockImpl context("localhost", // Source name
|
| + "example.com", // Target name
|
| + 0, // Lifetime
|
| + kDefaultMech, // Mechanism
|
| + 0, // Context flags
|
| + 1, // Locally initiated
|
| + 0); // Open
|
| test::MockGSSAPILibrary::SecurityContextQuery query(
|
| - "Negotiate", // Package name
|
| - major_status, // Major response code
|
| - minor_status, // Minor response code
|
| - context, // Context
|
| - NULL, // Expected input token
|
| - NULL); // Output token
|
| + "Negotiate", // Package name
|
| + major_status, // Major response code
|
| + minor_status, // Minor response code
|
| + context, // Context
|
| + NULL, // Expected input token
|
| + NULL); // Output token
|
|
|
| mock_library->ExpectSecurityContext(query.expected_package,
|
| query.response_code,
|
| @@ -172,10 +171,11 @@ class HttpAuthHandlerNegotiateTest : public PlatformTest {
|
|
|
| #endif // defined(OS_POSIX)
|
|
|
| - int CreateHandler(bool disable_cname_lookup, bool use_port,
|
| - bool synchronous_resolve_mode,
|
| - const std::string& url_string,
|
| - scoped_ptr<HttpAuthHandlerNegotiate>* handler) {
|
| + int CreateHandler(bool disable_cname_lookup,
|
| + bool use_port,
|
| + bool synchronous_resolve_mode,
|
| + const std::string& url_string,
|
| + scoped_ptr<HttpAuthHandlerNegotiate>* handler) {
|
| factory_->set_disable_cname_lookup(disable_cname_lookup);
|
| factory_->set_use_port(use_port);
|
| resolver_->set_synchronous_mode(synchronous_resolve_mode);
|
| @@ -216,15 +216,16 @@ class HttpAuthHandlerNegotiateTest : public PlatformTest {
|
| TEST_F(HttpAuthHandlerNegotiateTest, DisableCname) {
|
| SetupMocks(AuthLibrary());
|
| scoped_ptr<HttpAuthHandlerNegotiate> auth_handler;
|
| - EXPECT_EQ(OK, CreateHandler(
|
| - true, false, true, "http://alias:500", &auth_handler));
|
| + EXPECT_EQ(
|
| + OK, CreateHandler(true, false, true, "http://alias:500", &auth_handler));
|
|
|
| ASSERT_TRUE(auth_handler.get() != NULL);
|
| TestCompletionCallback callback;
|
| HttpRequestInfo request_info;
|
| std::string token;
|
| - EXPECT_EQ(OK, auth_handler->GenerateAuthToken(NULL, &request_info,
|
| - callback.callback(), &token));
|
| + EXPECT_EQ(OK,
|
| + auth_handler->GenerateAuthToken(
|
| + NULL, &request_info, callback.callback(), &token));
|
| #if defined(OS_WIN)
|
| EXPECT_EQ("HTTP/alias", auth_handler->spn());
|
| #elif defined(OS_POSIX)
|
| @@ -235,14 +236,15 @@ TEST_F(HttpAuthHandlerNegotiateTest, DisableCname) {
|
| TEST_F(HttpAuthHandlerNegotiateTest, DisableCnameStandardPort) {
|
| SetupMocks(AuthLibrary());
|
| scoped_ptr<HttpAuthHandlerNegotiate> auth_handler;
|
| - EXPECT_EQ(OK, CreateHandler(
|
| - true, true, true, "http://alias:80", &auth_handler));
|
| + EXPECT_EQ(OK,
|
| + CreateHandler(true, true, true, "http://alias:80", &auth_handler));
|
| ASSERT_TRUE(auth_handler.get() != NULL);
|
| TestCompletionCallback callback;
|
| HttpRequestInfo request_info;
|
| std::string token;
|
| - EXPECT_EQ(OK, auth_handler->GenerateAuthToken(NULL, &request_info,
|
| - callback.callback(), &token));
|
| + EXPECT_EQ(OK,
|
| + auth_handler->GenerateAuthToken(
|
| + NULL, &request_info, callback.callback(), &token));
|
| #if defined(OS_WIN)
|
| EXPECT_EQ("HTTP/alias", auth_handler->spn());
|
| #elif defined(OS_POSIX)
|
| @@ -253,14 +255,15 @@ TEST_F(HttpAuthHandlerNegotiateTest, DisableCnameStandardPort) {
|
| TEST_F(HttpAuthHandlerNegotiateTest, DisableCnameNonstandardPort) {
|
| SetupMocks(AuthLibrary());
|
| scoped_ptr<HttpAuthHandlerNegotiate> auth_handler;
|
| - EXPECT_EQ(OK, CreateHandler(
|
| - true, true, true, "http://alias:500", &auth_handler));
|
| + EXPECT_EQ(OK,
|
| + CreateHandler(true, true, true, "http://alias:500", &auth_handler));
|
| ASSERT_TRUE(auth_handler.get() != NULL);
|
| TestCompletionCallback callback;
|
| HttpRequestInfo request_info;
|
| std::string token;
|
| - EXPECT_EQ(OK, auth_handler->GenerateAuthToken(NULL, &request_info,
|
| - callback.callback(), &token));
|
| + EXPECT_EQ(OK,
|
| + auth_handler->GenerateAuthToken(
|
| + NULL, &request_info, callback.callback(), &token));
|
| #if defined(OS_WIN)
|
| EXPECT_EQ("HTTP/alias:500", auth_handler->spn());
|
| #elif defined(OS_POSIX)
|
| @@ -271,14 +274,15 @@ TEST_F(HttpAuthHandlerNegotiateTest, DisableCnameNonstandardPort) {
|
| TEST_F(HttpAuthHandlerNegotiateTest, CnameSync) {
|
| SetupMocks(AuthLibrary());
|
| scoped_ptr<HttpAuthHandlerNegotiate> auth_handler;
|
| - EXPECT_EQ(OK, CreateHandler(
|
| - false, false, true, "http://alias:500", &auth_handler));
|
| + EXPECT_EQ(
|
| + OK, CreateHandler(false, false, true, "http://alias:500", &auth_handler));
|
| ASSERT_TRUE(auth_handler.get() != NULL);
|
| TestCompletionCallback callback;
|
| HttpRequestInfo request_info;
|
| std::string token;
|
| - EXPECT_EQ(OK, auth_handler->GenerateAuthToken(NULL, &request_info,
|
| - callback.callback(), &token));
|
| + EXPECT_EQ(OK,
|
| + auth_handler->GenerateAuthToken(
|
| + NULL, &request_info, callback.callback(), &token));
|
| #if defined(OS_WIN)
|
| EXPECT_EQ("HTTP/canonical.example.com", auth_handler->spn());
|
| #elif defined(OS_POSIX)
|
| @@ -289,14 +293,16 @@ TEST_F(HttpAuthHandlerNegotiateTest, CnameSync) {
|
| TEST_F(HttpAuthHandlerNegotiateTest, CnameAsync) {
|
| SetupMocks(AuthLibrary());
|
| scoped_ptr<HttpAuthHandlerNegotiate> auth_handler;
|
| - EXPECT_EQ(OK, CreateHandler(
|
| - false, false, false, "http://alias:500", &auth_handler));
|
| + EXPECT_EQ(
|
| + OK,
|
| + CreateHandler(false, false, false, "http://alias:500", &auth_handler));
|
| ASSERT_TRUE(auth_handler.get() != NULL);
|
| TestCompletionCallback callback;
|
| HttpRequestInfo request_info;
|
| std::string token;
|
| - EXPECT_EQ(ERR_IO_PENDING, auth_handler->GenerateAuthToken(
|
| - NULL, &request_info, callback.callback(), &token));
|
| + EXPECT_EQ(ERR_IO_PENDING,
|
| + auth_handler->GenerateAuthToken(
|
| + NULL, &request_info, callback.callback(), &token));
|
| EXPECT_EQ(OK, callback.WaitForResult());
|
| #if defined(OS_WIN)
|
| EXPECT_EQ("HTTP/canonical.example.com", auth_handler->spn());
|
| @@ -312,14 +318,16 @@ TEST_F(HttpAuthHandlerNegotiateTest, CnameAsync) {
|
| TEST_F(HttpAuthHandlerNegotiateTest, ServerNotInKerberosDatabase) {
|
| SetupErrorMocks(AuthLibrary(), GSS_S_FAILURE, 0x96C73A07); // No server
|
| scoped_ptr<HttpAuthHandlerNegotiate> auth_handler;
|
| - EXPECT_EQ(OK, CreateHandler(
|
| - false, false, false, "http://alias:500", &auth_handler));
|
| + EXPECT_EQ(
|
| + OK,
|
| + CreateHandler(false, false, false, "http://alias:500", &auth_handler));
|
| ASSERT_TRUE(auth_handler.get() != NULL);
|
| TestCompletionCallback callback;
|
| HttpRequestInfo request_info;
|
| std::string token;
|
| - EXPECT_EQ(ERR_IO_PENDING, auth_handler->GenerateAuthToken(
|
| - NULL, &request_info, callback.callback(), &token));
|
| + EXPECT_EQ(ERR_IO_PENDING,
|
| + auth_handler->GenerateAuthToken(
|
| + NULL, &request_info, callback.callback(), &token));
|
| EXPECT_EQ(ERR_MISSING_AUTH_CREDENTIALS, callback.WaitForResult());
|
| }
|
|
|
| @@ -328,14 +336,16 @@ TEST_F(HttpAuthHandlerNegotiateTest, ServerNotInKerberosDatabase) {
|
| TEST_F(HttpAuthHandlerNegotiateTest, NoKerberosCredentials) {
|
| SetupErrorMocks(AuthLibrary(), GSS_S_FAILURE, 0x96C73AC3); // No credentials
|
| scoped_ptr<HttpAuthHandlerNegotiate> auth_handler;
|
| - EXPECT_EQ(OK, CreateHandler(
|
| - false, false, false, "http://alias:500", &auth_handler));
|
| + EXPECT_EQ(
|
| + OK,
|
| + CreateHandler(false, false, false, "http://alias:500", &auth_handler));
|
| ASSERT_TRUE(auth_handler.get() != NULL);
|
| TestCompletionCallback callback;
|
| HttpRequestInfo request_info;
|
| std::string token;
|
| - EXPECT_EQ(ERR_IO_PENDING, auth_handler->GenerateAuthToken(
|
| - NULL, &request_info, callback.callback(), &token));
|
| + EXPECT_EQ(ERR_IO_PENDING,
|
| + auth_handler->GenerateAuthToken(
|
| + NULL, &request_info, callback.callback(), &token));
|
| EXPECT_EQ(ERR_MISSING_AUTH_CREDENTIALS, callback.WaitForResult());
|
| }
|
|
|
| @@ -352,12 +362,11 @@ TEST_F(HttpAuthHandlerNegotiateTest, MissingGSSAPI) {
|
|
|
| GURL gurl("http://www.example.com");
|
| scoped_ptr<HttpAuthHandler> generic_handler;
|
| - int rv = negotiate_factory->CreateAuthHandlerFromString(
|
| - "Negotiate",
|
| - HttpAuth::AUTH_SERVER,
|
| - gurl,
|
| - BoundNetLog(),
|
| - &generic_handler);
|
| + int rv = negotiate_factory->CreateAuthHandlerFromString("Negotiate",
|
| + HttpAuth::AUTH_SERVER,
|
| + gurl,
|
| + BoundNetLog(),
|
| + &generic_handler);
|
| EXPECT_EQ(ERR_UNSUPPORTED_AUTH_SCHEME, rv);
|
| EXPECT_TRUE(generic_handler.get() == NULL);
|
| }
|
|
|