OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 13 matching lines...) Expand all Loading... |
24 namespace remoting { | 24 namespace remoting { |
25 namespace protocol { | 25 namespace protocol { |
26 | 26 |
27 namespace { | 27 namespace { |
28 | 28 |
29 const int kMessageSize = 100; | 29 const int kMessageSize = 100; |
30 const int kMessages = 1; | 30 const int kMessages = 1; |
31 | 31 |
32 const char kNoClientId[] = ""; | 32 const char kNoClientId[] = ""; |
33 const char kNoPairedSecret[] = ""; | 33 const char kNoPairedSecret[] = ""; |
| 34 const char kTestClientName[] = "client-name"; |
34 const char kTestClientId[] = "client-id"; | 35 const char kTestClientId[] = "client-id"; |
35 const char kTestHostId[] = "12345678910123456"; | 36 const char kTestHostId[] = "12345678910123456"; |
36 | 37 |
37 const char kTestPairedSecret[] = "1111-2222-3333"; | 38 const char kTestPairedSecret[] = "1111-2222-3333"; |
38 const char kTestPairedSecretBad[] = "4444-5555-6666"; | 39 const char kTestPairedSecretBad[] = "4444-5555-6666"; |
39 const char kTestPin[] = "123456"; | 40 const char kTestPin[] = "123456"; |
40 const char kTestPinBad[] = "654321"; | 41 const char kTestPinBad[] = "654321"; |
41 | 42 |
42 } // namespace | 43 } // namespace |
43 | 44 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 client_as_negotiating_authenticator_ = new NegotiatingClientAuthenticator( | 79 client_as_negotiating_authenticator_ = new NegotiatingClientAuthenticator( |
79 client_id, client_paired_secret, | 80 client_id, client_paired_secret, |
80 kTestHostId, fetch_secret_callback, | 81 kTestHostId, fetch_secret_callback, |
81 scoped_ptr<ThirdPartyClientAuthenticator::TokenFetcher>(), methods); | 82 scoped_ptr<ThirdPartyClientAuthenticator::TokenFetcher>(), methods); |
82 client_.reset(client_as_negotiating_authenticator_); | 83 client_.reset(client_as_negotiating_authenticator_); |
83 } | 84 } |
84 | 85 |
85 void CreatePairingRegistry(bool with_paired_client) { | 86 void CreatePairingRegistry(bool with_paired_client) { |
86 mock_delegate_ = new MockPairingRegistryDelegate; | 87 mock_delegate_ = new MockPairingRegistryDelegate; |
87 if (with_paired_client) { | 88 if (with_paired_client) { |
88 PairingRegistry::Pairing pairing; | 89 PairingRegistry::Pairing pairing( |
89 pairing.client_id = kTestClientId; | 90 base::Time(), kTestClientName, kTestClientId, kTestPairedSecret); |
90 pairing.shared_secret = kTestPairedSecret; | 91 mock_delegate_->AddPairing(pairing, |
91 mock_delegate_->AddPairing(pairing); | 92 PairingRegistry::AddPairingCallback()); |
92 } | 93 } |
93 pairing_registry_ = new PairingRegistry( | 94 pairing_registry_ = new PairingRegistry( |
94 scoped_ptr<PairingRegistry::Delegate>(mock_delegate_)); | 95 scoped_ptr<PairingRegistry::Delegate>(mock_delegate_)); |
95 } | 96 } |
96 | 97 |
97 static void FetchSecret( | 98 static void FetchSecret( |
98 const std::string& client_secret, | 99 const std::string& client_secret, |
99 bool pairing_supported, | 100 bool pairing_supported, |
100 bool pairing_expected, | 101 bool pairing_expected, |
101 const protocol::SecretFetchedCallback& secret_fetched_callback) { | 102 const protocol::SecretFetchedCallback& secret_fetched_callback) { |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 ASSERT_NO_FATAL_FAILURE(InitAuthenticators( | 256 ASSERT_NO_FATAL_FAILURE(InitAuthenticators( |
256 kTestClientId, kTestPairedSecretBad, kTestPinBad, kTestPin, | 257 kTestClientId, kTestPairedSecretBad, kTestPinBad, kTestPin, |
257 AuthenticationMethod::HMAC_SHA256, false)); | 258 AuthenticationMethod::HMAC_SHA256, false)); |
258 ASSERT_NO_FATAL_FAILURE(RunAuthExchange()); | 259 ASSERT_NO_FATAL_FAILURE(RunAuthExchange()); |
259 mock_delegate_->RunCallback(); | 260 mock_delegate_->RunCallback(); |
260 VerifyRejected(Authenticator::INVALID_CREDENTIALS); | 261 VerifyRejected(Authenticator::INVALID_CREDENTIALS); |
261 } | 262 } |
262 | 263 |
263 } // namespace protocol | 264 } // namespace protocol |
264 } // namespace remoting | 265 } // namespace remoting |
OLD | NEW |