OLD | NEW |
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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 | 146 |
147 tester.Start(); | 147 tester.Start(); |
148 message_loop_.Run(); | 148 message_loop_.Run(); |
149 tester.CheckResults(); | 149 tester.CheckResults(); |
150 } | 150 } |
151 | 151 |
152 TEST_F(ThirdPartyAuthenticatorTest, ClientNoSecret) { | 152 TEST_F(ThirdPartyAuthenticatorTest, ClientNoSecret) { |
153 ASSERT_NO_FATAL_FAILURE(InitAuthenticators()); | 153 ASSERT_NO_FATAL_FAILURE(InitAuthenticators()); |
154 ASSERT_NO_FATAL_FAILURE(RunHostInitiatedAuthExchange()); | 154 ASSERT_NO_FATAL_FAILURE(RunHostInitiatedAuthExchange()); |
155 ASSERT_EQ(Authenticator::PROCESSING_MESSAGE, client_->state()); | 155 ASSERT_EQ(Authenticator::PROCESSING_MESSAGE, client_->state()); |
156 ASSERT_NO_FATAL_FAILURE(token_fetcher_->OnTokenFetched(kToken, "")); | 156 ASSERT_NO_FATAL_FAILURE( |
| 157 token_fetcher_->OnTokenFetched(kToken, std::string())); |
157 | 158 |
158 // The end result is that the client rejected the connection, since it | 159 // The end result is that the client rejected the connection, since it |
159 // couldn't fetch the secret. | 160 // couldn't fetch the secret. |
160 ASSERT_EQ(Authenticator::REJECTED, client_->state()); | 161 ASSERT_EQ(Authenticator::REJECTED, client_->state()); |
161 } | 162 } |
162 | 163 |
163 TEST_F(ThirdPartyAuthenticatorTest, InvalidToken) { | 164 TEST_F(ThirdPartyAuthenticatorTest, InvalidToken) { |
164 ASSERT_NO_FATAL_FAILURE(InitAuthenticators()); | 165 ASSERT_NO_FATAL_FAILURE(InitAuthenticators()); |
165 ASSERT_NO_FATAL_FAILURE(RunHostInitiatedAuthExchange()); | 166 ASSERT_NO_FATAL_FAILURE(RunHostInitiatedAuthExchange()); |
166 ASSERT_EQ(Authenticator::PROCESSING_MESSAGE, client_->state()); | 167 ASSERT_EQ(Authenticator::PROCESSING_MESSAGE, client_->state()); |
167 ASSERT_NO_FATAL_FAILURE(token_fetcher_->OnTokenFetched( | 168 ASSERT_NO_FATAL_FAILURE(token_fetcher_->OnTokenFetched( |
168 kToken, kSharedSecret)); | 169 kToken, kSharedSecret)); |
169 ASSERT_EQ(Authenticator::PROCESSING_MESSAGE, host_->state()); | 170 ASSERT_EQ(Authenticator::PROCESSING_MESSAGE, host_->state()); |
170 ASSERT_NO_FATAL_FAILURE(token_validator_->OnTokenValidated("")); | 171 ASSERT_NO_FATAL_FAILURE(token_validator_->OnTokenValidated(std::string())); |
171 | 172 |
172 // The end result is that the host rejected the token. | 173 // The end result is that the host rejected the token. |
173 ASSERT_EQ(Authenticator::REJECTED, host_->state()); | 174 ASSERT_EQ(Authenticator::REJECTED, host_->state()); |
174 } | 175 } |
175 | 176 |
176 TEST_F(ThirdPartyAuthenticatorTest, CannotFetchToken) { | 177 TEST_F(ThirdPartyAuthenticatorTest, CannotFetchToken) { |
177 ASSERT_NO_FATAL_FAILURE(InitAuthenticators()); | 178 ASSERT_NO_FATAL_FAILURE(InitAuthenticators()); |
178 ASSERT_NO_FATAL_FAILURE(RunHostInitiatedAuthExchange()); | 179 ASSERT_NO_FATAL_FAILURE(RunHostInitiatedAuthExchange()); |
179 ASSERT_EQ(Authenticator::PROCESSING_MESSAGE, client_->state()); | 180 ASSERT_EQ(Authenticator::PROCESSING_MESSAGE, client_->state()); |
180 ASSERT_NO_FATAL_FAILURE(token_fetcher_->OnTokenFetched("", "")); | 181 ASSERT_NO_FATAL_FAILURE( |
| 182 token_fetcher_->OnTokenFetched(std::string(), std::string())); |
181 | 183 |
182 // The end result is that the client rejected the connection, since it | 184 // The end result is that the client rejected the connection, since it |
183 // couldn't fetch the token. | 185 // couldn't fetch the token. |
184 ASSERT_EQ(Authenticator::REJECTED, client_->state()); | 186 ASSERT_EQ(Authenticator::REJECTED, client_->state()); |
185 } | 187 } |
186 | 188 |
187 // Test that negotiation stops when the fake authentication is rejected. | 189 // Test that negotiation stops when the fake authentication is rejected. |
188 TEST_F(ThirdPartyAuthenticatorTest, HostBadSecret) { | 190 TEST_F(ThirdPartyAuthenticatorTest, HostBadSecret) { |
189 ASSERT_NO_FATAL_FAILURE(InitAuthenticators()); | 191 ASSERT_NO_FATAL_FAILURE(InitAuthenticators()); |
190 ASSERT_NO_FATAL_FAILURE(RunHostInitiatedAuthExchange()); | 192 ASSERT_NO_FATAL_FAILURE(RunHostInitiatedAuthExchange()); |
(...skipping 17 matching lines...) Expand all Loading... |
208 ASSERT_EQ(Authenticator::PROCESSING_MESSAGE, host_->state()); | 210 ASSERT_EQ(Authenticator::PROCESSING_MESSAGE, host_->state()); |
209 ASSERT_NO_FATAL_FAILURE( | 211 ASSERT_NO_FATAL_FAILURE( |
210 token_validator_->OnTokenValidated(kSharedSecret)); | 212 token_validator_->OnTokenValidated(kSharedSecret)); |
211 | 213 |
212 // The end result is that the host rejected the fake authentication. | 214 // The end result is that the host rejected the fake authentication. |
213 ASSERT_EQ(Authenticator::REJECTED, client_->state()); | 215 ASSERT_EQ(Authenticator::REJECTED, client_->state()); |
214 } | 216 } |
215 | 217 |
216 } // namespace protocol | 218 } // namespace protocol |
217 } // namespace remoting | 219 } // namespace remoting |
OLD | NEW |