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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 | 43 |
44 protected: | 44 protected: |
45 void InitAuthenticators( | 45 void InitAuthenticators( |
46 const std::string& client_secret, | 46 const std::string& client_secret, |
47 const std::string& host_secret, | 47 const std::string& host_secret, |
48 AuthenticationMethod::HashFunction hash_function, | 48 AuthenticationMethod::HashFunction hash_function, |
49 bool client_hmac_only) { | 49 bool client_hmac_only) { |
50 std::string host_secret_hash = AuthenticationMethod::ApplyHashFunction( | 50 std::string host_secret_hash = AuthenticationMethod::ApplyHashFunction( |
51 hash_function, kTestHostId, host_secret); | 51 hash_function, kTestHostId, host_secret); |
52 host_ = NegotiatingHostAuthenticator::CreateWithSharedSecret( | 52 host_ = NegotiatingHostAuthenticator::CreateWithSharedSecret( |
53 host_cert_, key_pair_, host_secret_hash, hash_function); | 53 host_cert_, key_pair_, host_secret_hash, hash_function, NULL); |
54 | 54 |
55 std::vector<AuthenticationMethod> methods; | 55 std::vector<AuthenticationMethod> methods; |
56 methods.push_back(AuthenticationMethod::Spake2( | 56 methods.push_back(AuthenticationMethod::Spake2( |
57 AuthenticationMethod::HMAC_SHA256)); | 57 AuthenticationMethod::HMAC_SHA256)); |
58 if (!client_hmac_only) { | 58 if (!client_hmac_only) { |
59 methods.push_back(AuthenticationMethod::Spake2( | 59 methods.push_back(AuthenticationMethod::Spake2( |
60 AuthenticationMethod::NONE)); | 60 AuthenticationMethod::NONE)); |
61 } | 61 } |
62 client_.reset(new NegotiatingClientAuthenticator( | 62 client_.reset(new NegotiatingClientAuthenticator( |
| 63 "", "", |
63 kTestHostId, base::Bind(&NegotiatingAuthenticatorTest::FetchSecret, | 64 kTestHostId, base::Bind(&NegotiatingAuthenticatorTest::FetchSecret, |
64 client_secret), | 65 client_secret), |
65 scoped_ptr<ThirdPartyClientAuthenticator::TokenFetcher>(), methods)); | 66 scoped_ptr<ThirdPartyClientAuthenticator::TokenFetcher>(), methods)); |
66 } | 67 } |
67 | 68 |
68 static void FetchSecret( | 69 static void FetchSecret( |
69 const std::string& client_secret, | 70 const std::string& client_secret, |
70 const protocol::SecretFetchedCallback& secret_fetched_callback) { | 71 const protocol::SecretFetchedCallback& secret_fetched_callback) { |
71 secret_fetched_callback.Run(client_secret); | 72 secret_fetched_callback.Run(client_secret); |
72 } | 73 } |
| 74 |
73 void VerifyRejected(Authenticator::RejectionReason reason) { | 75 void VerifyRejected(Authenticator::RejectionReason reason) { |
74 ASSERT_TRUE((client_->state() == Authenticator::REJECTED && | 76 ASSERT_TRUE((client_->state() == Authenticator::REJECTED && |
75 (client_->rejection_reason() == reason)) || | 77 (client_->rejection_reason() == reason)) || |
76 (host_->state() == Authenticator::REJECTED && | 78 (host_->state() == Authenticator::REJECTED && |
77 (host_->rejection_reason() == reason))); | 79 (host_->rejection_reason() == reason))); |
78 } | 80 } |
79 | 81 |
80 void VerifyAccepted() { | 82 void VerifyAccepted() { |
81 ASSERT_NO_FATAL_FAILURE(RunAuthExchange()); | 83 ASSERT_NO_FATAL_FAILURE(RunAuthExchange()); |
82 | 84 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 ASSERT_NO_FATAL_FAILURE(InitAuthenticators( | 140 ASSERT_NO_FATAL_FAILURE(InitAuthenticators( |
139 kTestSharedSecret, kTestSharedSecretBad, | 141 kTestSharedSecret, kTestSharedSecretBad, |
140 AuthenticationMethod::NONE, true)); | 142 AuthenticationMethod::NONE, true)); |
141 ASSERT_NO_FATAL_FAILURE(RunAuthExchange()); | 143 ASSERT_NO_FATAL_FAILURE(RunAuthExchange()); |
142 | 144 |
143 VerifyRejected(Authenticator::PROTOCOL_ERROR); | 145 VerifyRejected(Authenticator::PROTOCOL_ERROR); |
144 } | 146 } |
145 | 147 |
146 } // namespace protocol | 148 } // namespace protocol |
147 } // namespace remoting | 149 } // namespace remoting |
OLD | NEW |