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

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

Issue 2109503009: Refactor net tests to use GMock matchers for checking net::Error results (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert changes to contents.txt files Created 4 years, 5 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
« no previous file with comments | « net/http/http_auth_handler_negotiate_unittest.cc ('k') | net/http/http_cache_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/base/net_errors.h" 5 #include "net/base/net_errors.h"
6 #include "net/http/http_auth_challenge_tokenizer.h" 6 #include "net/http/http_auth_challenge_tokenizer.h"
7 #include "net/http/http_auth_sspi_win.h" 7 #include "net/http/http_auth_sspi_win.h"
8 #include "net/http/mock_sspi_library_win.h" 8 #include "net/http/mock_sspi_library_win.h"
9 #include "net/test/gtest_util.h"
10 #include "testing/gmock/include/gmock/gmock.h"
9 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
10 12
13 using net::test::IsError;
14 using net::test::IsOk;
15
11 namespace net { 16 namespace net {
12 17
13 namespace { 18 namespace {
14 19
15 void MatchDomainUserAfterSplit(const std::wstring& combined, 20 void MatchDomainUserAfterSplit(const std::wstring& combined,
16 const std::wstring& expected_domain, 21 const std::wstring& expected_domain,
17 const std::wstring& expected_user) { 22 const std::wstring& expected_user) {
18 std::wstring actual_domain; 23 std::wstring actual_domain;
19 std::wstring actual_user; 24 std::wstring actual_user;
20 SplitDomainAndUser(combined, &actual_domain, &actual_user); 25 SplitDomainAndUser(combined, &actual_domain, &actual_user);
(...skipping 18 matching lines...) Expand all
39 44
40 TEST(HttpAuthSSPITest, DetermineMaxTokenLength_Normal) { 45 TEST(HttpAuthSSPITest, DetermineMaxTokenLength_Normal) {
41 SecPkgInfoW package_info; 46 SecPkgInfoW package_info;
42 memset(&package_info, 0x0, sizeof(package_info)); 47 memset(&package_info, 0x0, sizeof(package_info));
43 package_info.cbMaxToken = 1337; 48 package_info.cbMaxToken = 1337;
44 49
45 MockSSPILibrary mock_library; 50 MockSSPILibrary mock_library;
46 mock_library.ExpectQuerySecurityPackageInfo(L"NTLM", SEC_E_OK, &package_info); 51 mock_library.ExpectQuerySecurityPackageInfo(L"NTLM", SEC_E_OK, &package_info);
47 ULONG max_token_length = kMaxTokenLength; 52 ULONG max_token_length = kMaxTokenLength;
48 int rv = DetermineMaxTokenLength(&mock_library, L"NTLM", &max_token_length); 53 int rv = DetermineMaxTokenLength(&mock_library, L"NTLM", &max_token_length);
49 EXPECT_EQ(OK, rv); 54 EXPECT_THAT(rv, IsOk());
50 EXPECT_EQ(1337u, max_token_length); 55 EXPECT_EQ(1337u, max_token_length);
51 } 56 }
52 57
53 TEST(HttpAuthSSPITest, DetermineMaxTokenLength_InvalidPackage) { 58 TEST(HttpAuthSSPITest, DetermineMaxTokenLength_InvalidPackage) {
54 MockSSPILibrary mock_library; 59 MockSSPILibrary mock_library;
55 mock_library.ExpectQuerySecurityPackageInfo(L"Foo", SEC_E_SECPKG_NOT_FOUND, 60 mock_library.ExpectQuerySecurityPackageInfo(L"Foo", SEC_E_SECPKG_NOT_FOUND,
56 NULL); 61 NULL);
57 ULONG max_token_length = kMaxTokenLength; 62 ULONG max_token_length = kMaxTokenLength;
58 int rv = DetermineMaxTokenLength(&mock_library, L"Foo", &max_token_length); 63 int rv = DetermineMaxTokenLength(&mock_library, L"Foo", &max_token_length);
59 EXPECT_EQ(ERR_UNSUPPORTED_AUTH_SCHEME, rv); 64 EXPECT_THAT(rv, IsError(ERR_UNSUPPORTED_AUTH_SCHEME));
60 // |DetermineMaxTokenLength()| interface states that |max_token_length| should 65 // |DetermineMaxTokenLength()| interface states that |max_token_length| should
61 // not change on failure. 66 // not change on failure.
62 EXPECT_EQ(100u, max_token_length); 67 EXPECT_EQ(100u, max_token_length);
63 } 68 }
64 69
65 TEST(HttpAuthSSPITest, ParseChallenge_FirstRound) { 70 TEST(HttpAuthSSPITest, ParseChallenge_FirstRound) {
66 // The first round should just consist of an unadorned "Negotiate" header. 71 // The first round should just consist of an unadorned "Negotiate" header.
67 MockSSPILibrary mock_library; 72 MockSSPILibrary mock_library;
68 HttpAuthSSPI auth_sspi(&mock_library, "Negotiate", 73 HttpAuthSSPI auth_sspi(&mock_library, "Negotiate",
69 NEGOSSP_NAME, kMaxTokenLength); 74 NEGOSSP_NAME, kMaxTokenLength);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 std::string(), &auth_token, 157 std::string(), &auth_token,
153 base::Bind(&UnexpectedCallback))); 158 base::Bind(&UnexpectedCallback)));
154 std::string second_challenge_text = "Negotiate =happyjoy="; 159 std::string second_challenge_text = "Negotiate =happyjoy=";
155 HttpAuthChallengeTokenizer second_challenge(second_challenge_text.begin(), 160 HttpAuthChallengeTokenizer second_challenge(second_challenge_text.begin(),
156 second_challenge_text.end()); 161 second_challenge_text.end());
157 EXPECT_EQ(HttpAuth::AUTHORIZATION_RESULT_INVALID, 162 EXPECT_EQ(HttpAuth::AUTHORIZATION_RESULT_INVALID,
158 auth_sspi.ParseChallenge(&second_challenge)); 163 auth_sspi.ParseChallenge(&second_challenge));
159 } 164 }
160 165
161 } // namespace net 166 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_auth_handler_negotiate_unittest.cc ('k') | net/http/http_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698