summaryrefslogtreecommitdiffstats
path: root/net/http/mock_sspi_library_win.cc
diff options
context:
space:
mode:
authorcbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-20 17:25:09 +0000
committercbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-20 17:25:09 +0000
commit5c2471b3621992761ea946b3929c7fde86fb24ce (patch)
tree10e876bca6a07c90155d008e94ace2162b11e66d /net/http/mock_sspi_library_win.cc
parentdd224e13b5371d1d313424247eea37f5b0d20acb (diff)
downloadchromium_src-5c2471b3621992761ea946b3929c7fde86fb24ce.zip
chromium_src-5c2471b3621992761ea946b3929c7fde86fb24ce.tar.gz
chromium_src-5c2471b3621992761ea946b3929c7fde86fb24ce.tar.bz2
This CL moves the MockSSPILibrary out of http_auth_sspi_win_unittests.cc and into it's own file at mock_http_auth_sspi_win.[h|cc].
I did this in preparation of another CL which uses the mock SSPI library in http_auth_handler_negotiate_win_unittest.cc. There are no behavior changes introduced in this CL. BUG=None TEST=net_unittests.exe --gtest_filter="*HttpAuthSSPI*" Review URL: http://codereview.chromium.org/1600032 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45046 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http/mock_sspi_library_win.cc')
-rw-r--r--net/http/mock_sspi_library_win.cc92
1 files changed, 92 insertions, 0 deletions
diff --git a/net/http/mock_sspi_library_win.cc b/net/http/mock_sspi_library_win.cc
new file mode 100644
index 0000000..de8f828
--- /dev/null
+++ b/net/http/mock_sspi_library_win.cc
@@ -0,0 +1,92 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/http/mock_sspi_library_win.h"
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace net {
+
+MockSSPILibrary::MockSSPILibrary() {
+}
+
+MockSSPILibrary::~MockSSPILibrary() {
+ EXPECT_TRUE(expected_package_queries_.empty());
+ EXPECT_TRUE(expected_freed_packages_.empty());
+}
+
+SECURITY_STATUS MockSSPILibrary::AcquireCredentialsHandle(
+ LPWSTR pszPrincipal,
+ LPWSTR pszPackage,
+ unsigned long fCredentialUse,
+ void* pvLogonId,
+ void* pvAuthData,
+ SEC_GET_KEY_FN pGetKeyFn,
+ void* pvGetKeyArgument,
+ PCredHandle phCredential,
+ PTimeStamp ptsExpiry) {
+ ADD_FAILURE();
+ return ERROR_CALL_NOT_IMPLEMENTED;
+}
+
+SECURITY_STATUS MockSSPILibrary::InitializeSecurityContext(
+ PCredHandle phCredential,
+ PCtxtHandle phContext,
+ SEC_WCHAR* pszTargetName,
+ unsigned long fContextReq,
+ unsigned long Reserved1,
+ unsigned long TargetDataRep,
+ PSecBufferDesc pInput,
+ unsigned long Reserved2,
+ PCtxtHandle phNewContext,
+ PSecBufferDesc pOutput,
+ unsigned long* contextAttr,
+ PTimeStamp ptsExpiry) {
+ ADD_FAILURE();
+ return ERROR_CALL_NOT_IMPLEMENTED;
+}
+
+SECURITY_STATUS MockSSPILibrary::QuerySecurityPackageInfo(
+ LPWSTR pszPackageName, PSecPkgInfoW *pkgInfo) {
+ EXPECT_TRUE(!expected_package_queries_.empty());
+ PackageQuery package_query = expected_package_queries_.front();
+ expected_package_queries_.pop_front();
+ std::wstring actual_package(pszPackageName);
+ EXPECT_EQ(package_query.expected_package, actual_package);
+ *pkgInfo = package_query.package_info;
+ if (package_query.response_code == SEC_E_OK)
+ expected_freed_packages_.insert(package_query.package_info);
+ return package_query.response_code;
+}
+
+SECURITY_STATUS MockSSPILibrary::FreeCredentialsHandle(
+ PCredHandle phCredential) {
+ ADD_FAILURE();
+ return ERROR_CALL_NOT_IMPLEMENTED;
+}
+
+SECURITY_STATUS MockSSPILibrary::DeleteSecurityContext(PCtxtHandle phContext) {
+ ADD_FAILURE();
+ return ERROR_CALL_NOT_IMPLEMENTED;
+}
+
+SECURITY_STATUS MockSSPILibrary::FreeContextBuffer(PVOID pvContextBuffer) {
+ PSecPkgInfoW package_info = static_cast<PSecPkgInfoW>(pvContextBuffer);
+ std::set<PSecPkgInfoW>::iterator it = expected_freed_packages_.find(
+ package_info);
+ EXPECT_TRUE(it != expected_freed_packages_.end());
+ expected_freed_packages_.erase(it);
+ return SEC_E_OK;
+}
+
+void MockSSPILibrary::ExpectQuerySecurityPackageInfo(
+ const std::wstring& expected_package,
+ SECURITY_STATUS response_code,
+ PSecPkgInfoW package_info) {
+ PackageQuery package_query = {expected_package, response_code,
+ package_info};
+ expected_package_queries_.push_back(package_query);
+}
+
+} // namespace net