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

Side by Side Diff: net/http/mock_sspi_library_win.cc

Issue 3360017: Fix multi-round authentication.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: SocketStream fix Created 10 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « net/http/http_network_transaction_unittest.cc ('k') | net/socket_stream/socket_stream.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "net/http/mock_sspi_library_win.h" 5 #include "net/http/mock_sspi_library_win.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 namespace net { 9 namespace net {
10 10
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 PCtxtHandle phNewContext, 43 PCtxtHandle phNewContext,
44 PSecBufferDesc pOutput, 44 PSecBufferDesc pOutput,
45 unsigned long* contextAttr, 45 unsigned long* contextAttr,
46 PTimeStamp ptsExpiry) { 46 PTimeStamp ptsExpiry) {
47 // Fill in the outbound buffer with garbage data. 47 // Fill in the outbound buffer with garbage data.
48 PSecBuffer out_buffer = pOutput->pBuffers; 48 PSecBuffer out_buffer = pOutput->pBuffers;
49 out_buffer->cbBuffer = 2; 49 out_buffer->cbBuffer = 2;
50 uint8* buf = reinterpret_cast<uint8 *>(out_buffer->pvBuffer); 50 uint8* buf = reinterpret_cast<uint8 *>(out_buffer->pvBuffer);
51 buf[0] = 0xAB; 51 buf[0] = 0xAB;
52 buf[1] = 0xBA; 52 buf[1] = 0xBA;
53
54 // Fill in phNewContext with arbitrary value if it's invalid.
55 if (phNewContext != phContext)
56 phNewContext->dwLower = phNewContext->dwUpper = ((ULONG_PTR) ((INT_PTR)0));
53 return SEC_E_OK; 57 return SEC_E_OK;
54 } 58 }
55 59
56 SECURITY_STATUS MockSSPILibrary::QuerySecurityPackageInfo( 60 SECURITY_STATUS MockSSPILibrary::QuerySecurityPackageInfo(
57 LPWSTR pszPackageName, PSecPkgInfoW *pkgInfo) { 61 LPWSTR pszPackageName, PSecPkgInfoW *pkgInfo) {
58 EXPECT_TRUE(!expected_package_queries_.empty()); 62 EXPECT_TRUE(!expected_package_queries_.empty());
59 PackageQuery package_query = expected_package_queries_.front(); 63 PackageQuery package_query = expected_package_queries_.front();
60 expected_package_queries_.pop_front(); 64 expected_package_queries_.pop_front();
61 std::wstring actual_package(pszPackageName); 65 std::wstring actual_package(pszPackageName);
62 EXPECT_EQ(package_query.expected_package, actual_package); 66 EXPECT_EQ(package_query.expected_package, actual_package);
63 *pkgInfo = package_query.package_info; 67 *pkgInfo = package_query.package_info;
64 if (package_query.response_code == SEC_E_OK) 68 if (package_query.response_code == SEC_E_OK)
65 expected_freed_packages_.insert(package_query.package_info); 69 expected_freed_packages_.insert(package_query.package_info);
66 return package_query.response_code; 70 return package_query.response_code;
67 } 71 }
68 72
69 SECURITY_STATUS MockSSPILibrary::FreeCredentialsHandle( 73 SECURITY_STATUS MockSSPILibrary::FreeCredentialsHandle(
70 PCredHandle phCredential) { 74 PCredHandle phCredential) {
71 EXPECT_TRUE(phCredential->dwLower == ((ULONG_PTR) ((INT_PTR) 0))); 75 EXPECT_TRUE(phCredential->dwLower == ((ULONG_PTR) ((INT_PTR) 0)));
72 EXPECT_TRUE(phCredential->dwLower == ((ULONG_PTR) ((INT_PTR) 0))); 76 EXPECT_TRUE(phCredential->dwLower == ((ULONG_PTR) ((INT_PTR) 0)));
73 SecInvalidateHandle(phCredential); 77 SecInvalidateHandle(phCredential);
74 return SEC_E_OK; 78 return SEC_E_OK;
75 } 79 }
76 80
77 SECURITY_STATUS MockSSPILibrary::DeleteSecurityContext(PCtxtHandle phContext) { 81 SECURITY_STATUS MockSSPILibrary::DeleteSecurityContext(PCtxtHandle phContext) {
78 ADD_FAILURE(); 82 EXPECT_TRUE(phContext->dwLower == ((ULONG_PTR) ((INT_PTR) 0)));
79 return ERROR_CALL_NOT_IMPLEMENTED; 83 EXPECT_TRUE(phContext->dwLower == ((ULONG_PTR) ((INT_PTR) 0)));
84 SecInvalidateHandle(phContext);
85 return SEC_E_OK;
80 } 86 }
81 87
82 SECURITY_STATUS MockSSPILibrary::FreeContextBuffer(PVOID pvContextBuffer) { 88 SECURITY_STATUS MockSSPILibrary::FreeContextBuffer(PVOID pvContextBuffer) {
83 PSecPkgInfoW package_info = static_cast<PSecPkgInfoW>(pvContextBuffer); 89 PSecPkgInfoW package_info = static_cast<PSecPkgInfoW>(pvContextBuffer);
84 std::set<PSecPkgInfoW>::iterator it = expected_freed_packages_.find( 90 std::set<PSecPkgInfoW>::iterator it = expected_freed_packages_.find(
85 package_info); 91 package_info);
86 EXPECT_TRUE(it != expected_freed_packages_.end()); 92 EXPECT_TRUE(it != expected_freed_packages_.end());
87 expected_freed_packages_.erase(it); 93 expected_freed_packages_.erase(it);
88 return SEC_E_OK; 94 return SEC_E_OK;
89 } 95 }
90 96
91 void MockSSPILibrary::ExpectQuerySecurityPackageInfo( 97 void MockSSPILibrary::ExpectQuerySecurityPackageInfo(
92 const std::wstring& expected_package, 98 const std::wstring& expected_package,
93 SECURITY_STATUS response_code, 99 SECURITY_STATUS response_code,
94 PSecPkgInfoW package_info) { 100 PSecPkgInfoW package_info) {
95 PackageQuery package_query = {expected_package, response_code, 101 PackageQuery package_query = {expected_package, response_code,
96 package_info}; 102 package_info};
97 expected_package_queries_.push_back(package_query); 103 expected_package_queries_.push_back(package_query);
98 } 104 }
99 105
100 } // namespace net 106 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_network_transaction_unittest.cc ('k') | net/socket_stream/socket_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698