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

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

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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
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
11 MockSSPILibrary::MockSSPILibrary() { 11 MockSSPILibrary::MockSSPILibrary() {
12 } 12 }
13 13
14 MockSSPILibrary::~MockSSPILibrary() { 14 MockSSPILibrary::~MockSSPILibrary() {
15 EXPECT_TRUE(expected_package_queries_.empty()); 15 EXPECT_TRUE(expected_package_queries_.empty());
16 EXPECT_TRUE(expected_freed_packages_.empty()); 16 EXPECT_TRUE(expected_freed_packages_.empty());
17 } 17 }
18 18
19 SECURITY_STATUS MockSSPILibrary::AcquireCredentialsHandle( 19 SECURITY_STATUS MockSSPILibrary::AcquireCredentialsHandle(
20 LPWSTR pszPrincipal, 20 LPWSTR pszPrincipal,
21 LPWSTR pszPackage, 21 LPWSTR pszPackage,
22 unsigned long fCredentialUse, 22 unsigned long fCredentialUse,
23 void* pvLogonId, 23 void* pvLogonId,
24 void* pvAuthData, 24 void* pvAuthData,
25 SEC_GET_KEY_FN pGetKeyFn, 25 SEC_GET_KEY_FN pGetKeyFn,
26 void* pvGetKeyArgument, 26 void* pvGetKeyArgument,
27 PCredHandle phCredential, 27 PCredHandle phCredential,
28 PTimeStamp ptsExpiry) { 28 PTimeStamp ptsExpiry) {
29 // Fill in phCredential with arbitrary value. 29 // Fill in phCredential with arbitrary value.
30 phCredential->dwLower = phCredential->dwUpper = ((ULONG_PTR) ((INT_PTR)0)); 30 phCredential->dwLower = phCredential->dwUpper = ((ULONG_PTR)((INT_PTR)0));
31 return SEC_E_OK; 31 return SEC_E_OK;
32 } 32 }
33 33
34 SECURITY_STATUS MockSSPILibrary::InitializeSecurityContext( 34 SECURITY_STATUS MockSSPILibrary::InitializeSecurityContext(
35 PCredHandle phCredential, 35 PCredHandle phCredential,
36 PCtxtHandle phContext, 36 PCtxtHandle phContext,
37 SEC_WCHAR* pszTargetName, 37 SEC_WCHAR* pszTargetName,
38 unsigned long fContextReq, 38 unsigned long fContextReq,
39 unsigned long Reserved1, 39 unsigned long Reserved1,
40 unsigned long TargetDataRep, 40 unsigned long TargetDataRep,
41 PSecBufferDesc pInput, 41 PSecBufferDesc pInput,
42 unsigned long Reserved2, 42 unsigned long Reserved2,
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 53
54 // Fill in phNewContext with arbitrary value if it's invalid. 54 // Fill in phNewContext with arbitrary value if it's invalid.
55 if (phNewContext != phContext) 55 if (phNewContext != phContext)
56 phNewContext->dwLower = phNewContext->dwUpper = ((ULONG_PTR) ((INT_PTR)0)); 56 phNewContext->dwLower = phNewContext->dwUpper = ((ULONG_PTR)((INT_PTR)0));
57 return SEC_E_OK; 57 return SEC_E_OK;
58 } 58 }
59 59
60 SECURITY_STATUS MockSSPILibrary::QuerySecurityPackageInfo( 60 SECURITY_STATUS MockSSPILibrary::QuerySecurityPackageInfo(
61 LPWSTR pszPackageName, PSecPkgInfoW *pkgInfo) { 61 LPWSTR pszPackageName,
62 PSecPkgInfoW* pkgInfo) {
62 EXPECT_TRUE(!expected_package_queries_.empty()); 63 EXPECT_TRUE(!expected_package_queries_.empty());
63 PackageQuery package_query = expected_package_queries_.front(); 64 PackageQuery package_query = expected_package_queries_.front();
64 expected_package_queries_.pop_front(); 65 expected_package_queries_.pop_front();
65 std::wstring actual_package(pszPackageName); 66 std::wstring actual_package(pszPackageName);
66 EXPECT_EQ(package_query.expected_package, actual_package); 67 EXPECT_EQ(package_query.expected_package, actual_package);
67 *pkgInfo = package_query.package_info; 68 *pkgInfo = package_query.package_info;
68 if (package_query.response_code == SEC_E_OK) 69 if (package_query.response_code == SEC_E_OK)
69 expected_freed_packages_.insert(package_query.package_info); 70 expected_freed_packages_.insert(package_query.package_info);
70 return package_query.response_code; 71 return package_query.response_code;
71 } 72 }
72 73
73 SECURITY_STATUS MockSSPILibrary::FreeCredentialsHandle( 74 SECURITY_STATUS MockSSPILibrary::FreeCredentialsHandle(
74 PCredHandle phCredential) { 75 PCredHandle phCredential) {
75 EXPECT_TRUE(phCredential->dwLower == ((ULONG_PTR) ((INT_PTR) 0))); 76 EXPECT_TRUE(phCredential->dwLower == ((ULONG_PTR)((INT_PTR)0)));
76 EXPECT_TRUE(phCredential->dwLower == ((ULONG_PTR) ((INT_PTR) 0))); 77 EXPECT_TRUE(phCredential->dwLower == ((ULONG_PTR)((INT_PTR)0)));
77 SecInvalidateHandle(phCredential); 78 SecInvalidateHandle(phCredential);
78 return SEC_E_OK; 79 return SEC_E_OK;
79 } 80 }
80 81
81 SECURITY_STATUS MockSSPILibrary::DeleteSecurityContext(PCtxtHandle phContext) { 82 SECURITY_STATUS MockSSPILibrary::DeleteSecurityContext(PCtxtHandle phContext) {
82 EXPECT_TRUE(phContext->dwLower == ((ULONG_PTR) ((INT_PTR) 0))); 83 EXPECT_TRUE(phContext->dwLower == ((ULONG_PTR)((INT_PTR)0)));
83 EXPECT_TRUE(phContext->dwLower == ((ULONG_PTR) ((INT_PTR) 0))); 84 EXPECT_TRUE(phContext->dwLower == ((ULONG_PTR)((INT_PTR)0)));
84 SecInvalidateHandle(phContext); 85 SecInvalidateHandle(phContext);
85 return SEC_E_OK; 86 return SEC_E_OK;
86 } 87 }
87 88
88 SECURITY_STATUS MockSSPILibrary::FreeContextBuffer(PVOID pvContextBuffer) { 89 SECURITY_STATUS MockSSPILibrary::FreeContextBuffer(PVOID pvContextBuffer) {
89 PSecPkgInfoW package_info = static_cast<PSecPkgInfoW>(pvContextBuffer); 90 PSecPkgInfoW package_info = static_cast<PSecPkgInfoW>(pvContextBuffer);
90 std::set<PSecPkgInfoW>::iterator it = expected_freed_packages_.find( 91 std::set<PSecPkgInfoW>::iterator it =
91 package_info); 92 expected_freed_packages_.find(package_info);
92 EXPECT_TRUE(it != expected_freed_packages_.end()); 93 EXPECT_TRUE(it != expected_freed_packages_.end());
93 expected_freed_packages_.erase(it); 94 expected_freed_packages_.erase(it);
94 return SEC_E_OK; 95 return SEC_E_OK;
95 } 96 }
96 97
97 void MockSSPILibrary::ExpectQuerySecurityPackageInfo( 98 void MockSSPILibrary::ExpectQuerySecurityPackageInfo(
98 const std::wstring& expected_package, 99 const std::wstring& expected_package,
99 SECURITY_STATUS response_code, 100 SECURITY_STATUS response_code,
100 PSecPkgInfoW package_info) { 101 PSecPkgInfoW package_info) {
101 PackageQuery package_query = {expected_package, response_code, 102 PackageQuery package_query = {expected_package, response_code, package_info};
102 package_info};
103 expected_package_queries_.push_back(package_query); 103 expected_package_queries_.push_back(package_query);
104 } 104 }
105 105
106 } // namespace net 106 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698