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

Side by Side Diff: remoting/protocol/third_party_authenticator_unittest.cc

Issue 418173004: Enable and fix CRLSet and remoting tests on non-Android OpenSSL. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Also build crl_set.cc on NaCl Created 6 years, 4 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "net/base/net_errors.h" 6 #include "net/base/net_errors.h"
7 #include "remoting/base/rsa_key_pair.h" 7 #include "remoting/base/rsa_key_pair.h"
8 #include "remoting/protocol/authenticator_test_base.h" 8 #include "remoting/protocol/authenticator_test_base.h"
9 #include "remoting/protocol/channel_authenticator.h" 9 #include "remoting/protocol/channel_authenticator.h"
10 #include "remoting/protocol/connection_tester.h" 10 #include "remoting/protocol/connection_tester.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 client_.reset(new ThirdPartyClientAuthenticator(token_fetcher.Pass())); 114 client_.reset(new ThirdPartyClientAuthenticator(token_fetcher.Pass()));
115 } 115 }
116 116
117 FakeTokenFetcher* token_fetcher_; 117 FakeTokenFetcher* token_fetcher_;
118 FakeTokenValidator* token_validator_; 118 FakeTokenValidator* token_validator_;
119 119
120 private: 120 private:
121 DISALLOW_COPY_AND_ASSIGN(ThirdPartyAuthenticatorTest); 121 DISALLOW_COPY_AND_ASSIGN(ThirdPartyAuthenticatorTest);
122 }; 122 };
123 123
124 // These tests use net::SSLServerSocket which is not implemented for OpenSSL. 124 TEST_F(ThirdPartyAuthenticatorTest, SuccessfulAuth) {
125 #if defined(USE_OPENSSL)
126 #define MAYBE(x) DISABLED_##x
127 #else
128 #define MAYBE(x) x
129 #endif
130
131 TEST_F(ThirdPartyAuthenticatorTest, MAYBE(SuccessfulAuth)) {
132 ASSERT_NO_FATAL_FAILURE(InitAuthenticators()); 125 ASSERT_NO_FATAL_FAILURE(InitAuthenticators());
133 ASSERT_NO_FATAL_FAILURE(RunHostInitiatedAuthExchange()); 126 ASSERT_NO_FATAL_FAILURE(RunHostInitiatedAuthExchange());
134 ASSERT_EQ(Authenticator::PROCESSING_MESSAGE, client_->state()); 127 ASSERT_EQ(Authenticator::PROCESSING_MESSAGE, client_->state());
135 ASSERT_NO_FATAL_FAILURE(token_fetcher_->OnTokenFetched( 128 ASSERT_NO_FATAL_FAILURE(token_fetcher_->OnTokenFetched(
136 kToken, kSharedSecret)); 129 kToken, kSharedSecret));
137 ASSERT_EQ(Authenticator::PROCESSING_MESSAGE, host_->state()); 130 ASSERT_EQ(Authenticator::PROCESSING_MESSAGE, host_->state());
138 ASSERT_NO_FATAL_FAILURE( 131 ASSERT_NO_FATAL_FAILURE(
139 token_validator_->OnTokenValidated(kSharedSecret)); 132 token_validator_->OnTokenValidated(kSharedSecret));
140 133
141 // Both sides have finished. 134 // Both sides have finished.
142 ASSERT_EQ(Authenticator::ACCEPTED, host_->state()); 135 ASSERT_EQ(Authenticator::ACCEPTED, host_->state());
143 ASSERT_EQ(Authenticator::ACCEPTED, client_->state()); 136 ASSERT_EQ(Authenticator::ACCEPTED, client_->state());
144 137
145 // An authenticated channel can be created after the authentication. 138 // An authenticated channel can be created after the authentication.
146 client_auth_ = client_->CreateChannelAuthenticator(); 139 client_auth_ = client_->CreateChannelAuthenticator();
147 host_auth_ = host_->CreateChannelAuthenticator(); 140 host_auth_ = host_->CreateChannelAuthenticator();
148 RunChannelAuth(false); 141 RunChannelAuth(false);
149 142
150 StreamConnectionTester tester(host_socket_.get(), client_socket_.get(), 143 StreamConnectionTester tester(host_socket_.get(), client_socket_.get(),
151 kMessageSize, kMessages); 144 kMessageSize, kMessages);
152 145
153 tester.Start(); 146 tester.Start();
154 message_loop_.Run(); 147 message_loop_.Run();
155 tester.CheckResults(); 148 tester.CheckResults();
156 } 149 }
157 150
158 TEST_F(ThirdPartyAuthenticatorTest, MAYBE(ClientNoSecret)) { 151 TEST_F(ThirdPartyAuthenticatorTest, ClientNoSecret) {
159 ASSERT_NO_FATAL_FAILURE(InitAuthenticators()); 152 ASSERT_NO_FATAL_FAILURE(InitAuthenticators());
160 ASSERT_NO_FATAL_FAILURE(RunHostInitiatedAuthExchange()); 153 ASSERT_NO_FATAL_FAILURE(RunHostInitiatedAuthExchange());
161 ASSERT_EQ(Authenticator::PROCESSING_MESSAGE, client_->state()); 154 ASSERT_EQ(Authenticator::PROCESSING_MESSAGE, client_->state());
162 ASSERT_NO_FATAL_FAILURE( 155 ASSERT_NO_FATAL_FAILURE(
163 token_fetcher_->OnTokenFetched(kToken, std::string())); 156 token_fetcher_->OnTokenFetched(kToken, std::string()));
164 157
165 // The end result is that the client rejected the connection, since it 158 // The end result is that the client rejected the connection, since it
166 // couldn't fetch the secret. 159 // couldn't fetch the secret.
167 ASSERT_EQ(Authenticator::REJECTED, client_->state()); 160 ASSERT_EQ(Authenticator::REJECTED, client_->state());
168 } 161 }
169 162
170 TEST_F(ThirdPartyAuthenticatorTest, MAYBE(InvalidToken)) { 163 TEST_F(ThirdPartyAuthenticatorTest, InvalidToken) {
171 ASSERT_NO_FATAL_FAILURE(InitAuthenticators()); 164 ASSERT_NO_FATAL_FAILURE(InitAuthenticators());
172 ASSERT_NO_FATAL_FAILURE(RunHostInitiatedAuthExchange()); 165 ASSERT_NO_FATAL_FAILURE(RunHostInitiatedAuthExchange());
173 ASSERT_EQ(Authenticator::PROCESSING_MESSAGE, client_->state()); 166 ASSERT_EQ(Authenticator::PROCESSING_MESSAGE, client_->state());
174 ASSERT_NO_FATAL_FAILURE(token_fetcher_->OnTokenFetched( 167 ASSERT_NO_FATAL_FAILURE(token_fetcher_->OnTokenFetched(
175 kToken, kSharedSecret)); 168 kToken, kSharedSecret));
176 ASSERT_EQ(Authenticator::PROCESSING_MESSAGE, host_->state()); 169 ASSERT_EQ(Authenticator::PROCESSING_MESSAGE, host_->state());
177 ASSERT_NO_FATAL_FAILURE(token_validator_->OnTokenValidated(std::string())); 170 ASSERT_NO_FATAL_FAILURE(token_validator_->OnTokenValidated(std::string()));
178 171
179 // The end result is that the host rejected the token. 172 // The end result is that the host rejected the token.
180 ASSERT_EQ(Authenticator::REJECTED, host_->state()); 173 ASSERT_EQ(Authenticator::REJECTED, host_->state());
181 } 174 }
182 175
183 TEST_F(ThirdPartyAuthenticatorTest, MAYBE(CannotFetchToken)) { 176 TEST_F(ThirdPartyAuthenticatorTest, CannotFetchToken) {
184 ASSERT_NO_FATAL_FAILURE(InitAuthenticators()); 177 ASSERT_NO_FATAL_FAILURE(InitAuthenticators());
185 ASSERT_NO_FATAL_FAILURE(RunHostInitiatedAuthExchange()); 178 ASSERT_NO_FATAL_FAILURE(RunHostInitiatedAuthExchange());
186 ASSERT_EQ(Authenticator::PROCESSING_MESSAGE, client_->state()); 179 ASSERT_EQ(Authenticator::PROCESSING_MESSAGE, client_->state());
187 ASSERT_NO_FATAL_FAILURE( 180 ASSERT_NO_FATAL_FAILURE(
188 token_fetcher_->OnTokenFetched(std::string(), std::string())); 181 token_fetcher_->OnTokenFetched(std::string(), std::string()));
189 182
190 // The end result is that the client rejected the connection, since it 183 // The end result is that the client rejected the connection, since it
191 // couldn't fetch the token. 184 // couldn't fetch the token.
192 ASSERT_EQ(Authenticator::REJECTED, client_->state()); 185 ASSERT_EQ(Authenticator::REJECTED, client_->state());
193 } 186 }
194 187
195 // Test that negotiation stops when the fake authentication is rejected. 188 // Test that negotiation stops when the fake authentication is rejected.
196 TEST_F(ThirdPartyAuthenticatorTest, MAYBE(HostBadSecret)) { 189 TEST_F(ThirdPartyAuthenticatorTest, HostBadSecret) {
197 ASSERT_NO_FATAL_FAILURE(InitAuthenticators()); 190 ASSERT_NO_FATAL_FAILURE(InitAuthenticators());
198 ASSERT_NO_FATAL_FAILURE(RunHostInitiatedAuthExchange()); 191 ASSERT_NO_FATAL_FAILURE(RunHostInitiatedAuthExchange());
199 ASSERT_EQ(Authenticator::PROCESSING_MESSAGE, client_->state()); 192 ASSERT_EQ(Authenticator::PROCESSING_MESSAGE, client_->state());
200 ASSERT_NO_FATAL_FAILURE(token_fetcher_->OnTokenFetched( 193 ASSERT_NO_FATAL_FAILURE(token_fetcher_->OnTokenFetched(
201 kToken, kSharedSecret)); 194 kToken, kSharedSecret));
202 ASSERT_EQ(Authenticator::PROCESSING_MESSAGE, host_->state()); 195 ASSERT_EQ(Authenticator::PROCESSING_MESSAGE, host_->state());
203 ASSERT_NO_FATAL_FAILURE( 196 ASSERT_NO_FATAL_FAILURE(
204 token_validator_->OnTokenValidated(kSharedSecretBad)); 197 token_validator_->OnTokenValidated(kSharedSecretBad));
205 198
206 // The end result is that the host rejected the fake authentication. 199 // The end result is that the host rejected the fake authentication.
207 ASSERT_EQ(Authenticator::REJECTED, client_->state()); 200 ASSERT_EQ(Authenticator::REJECTED, client_->state());
208 } 201 }
209 202
210 TEST_F(ThirdPartyAuthenticatorTest, MAYBE(ClientBadSecret)) { 203 TEST_F(ThirdPartyAuthenticatorTest, ClientBadSecret) {
211 ASSERT_NO_FATAL_FAILURE(InitAuthenticators()); 204 ASSERT_NO_FATAL_FAILURE(InitAuthenticators());
212 ASSERT_NO_FATAL_FAILURE(RunHostInitiatedAuthExchange()); 205 ASSERT_NO_FATAL_FAILURE(RunHostInitiatedAuthExchange());
213 ASSERT_EQ(Authenticator::PROCESSING_MESSAGE, client_->state()); 206 ASSERT_EQ(Authenticator::PROCESSING_MESSAGE, client_->state());
214 ASSERT_NO_FATAL_FAILURE( 207 ASSERT_NO_FATAL_FAILURE(
215 token_fetcher_->OnTokenFetched(kToken, kSharedSecretBad)); 208 token_fetcher_->OnTokenFetched(kToken, kSharedSecretBad));
216 ASSERT_EQ(Authenticator::PROCESSING_MESSAGE, host_->state()); 209 ASSERT_EQ(Authenticator::PROCESSING_MESSAGE, host_->state());
217 ASSERT_NO_FATAL_FAILURE( 210 ASSERT_NO_FATAL_FAILURE(
218 token_validator_->OnTokenValidated(kSharedSecret)); 211 token_validator_->OnTokenValidated(kSharedSecret));
219 212
220 // The end result is that the host rejected the fake authentication. 213 // The end result is that the host rejected the fake authentication.
221 ASSERT_EQ(Authenticator::REJECTED, client_->state()); 214 ASSERT_EQ(Authenticator::REJECTED, client_->state());
222 } 215 }
223 216
224 } // namespace protocol 217 } // namespace protocol
225 } // namespace remoting 218 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/ssl_hmac_channel_authenticator_unittest.cc ('k') | remoting/protocol/v2_authenticator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698