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 23 matching lines...) Expand all Loading... |
34 } // namespace | 34 } // namespace |
35 | 35 |
36 namespace remoting { | 36 namespace remoting { |
37 namespace protocol { | 37 namespace protocol { |
38 | 38 |
39 class ThirdPartyAuthenticatorTest : public AuthenticatorTestBase { | 39 class ThirdPartyAuthenticatorTest : public AuthenticatorTestBase { |
40 class FakeTokenFetcher : public ThirdPartyClientAuthenticator::TokenFetcher { | 40 class FakeTokenFetcher : public ThirdPartyClientAuthenticator::TokenFetcher { |
41 public: | 41 public: |
42 virtual void FetchThirdPartyToken( | 42 virtual void FetchThirdPartyToken( |
43 const GURL& token_url, | 43 const GURL& token_url, |
44 const std::string& host_public_key, | |
45 const std::string& scope, | 44 const std::string& scope, |
46 const TokenFetchedCallback& token_fetched_callback) OVERRIDE { | 45 const TokenFetchedCallback& token_fetched_callback) OVERRIDE { |
47 ASSERT_EQ(token_url.spec(), kTokenUrl); | 46 ASSERT_EQ(token_url.spec(), kTokenUrl); |
48 ASSERT_EQ(scope, kTokenScope); | 47 ASSERT_EQ(scope, kTokenScope); |
49 ASSERT_FALSE(token_fetched_callback.is_null()); | 48 ASSERT_FALSE(token_fetched_callback.is_null()); |
50 on_token_fetched_ = token_fetched_callback; | 49 on_token_fetched_ = token_fetched_callback; |
51 } | 50 } |
52 | 51 |
53 void OnTokenFetched(const std::string& token, | 52 void OnTokenFetched(const std::string& token, |
54 const std::string& shared_secret) { | 53 const std::string& shared_secret) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 protected: | 105 protected: |
107 void InitAuthenticators() { | 106 void InitAuthenticators() { |
108 scoped_ptr<ThirdPartyHostAuthenticator::TokenValidator> | 107 scoped_ptr<ThirdPartyHostAuthenticator::TokenValidator> |
109 token_validator(new FakeTokenValidator()); | 108 token_validator(new FakeTokenValidator()); |
110 token_validator_ = static_cast<FakeTokenValidator*>(token_validator.get()); | 109 token_validator_ = static_cast<FakeTokenValidator*>(token_validator.get()); |
111 host_.reset(new ThirdPartyHostAuthenticator( | 110 host_.reset(new ThirdPartyHostAuthenticator( |
112 host_cert_, key_pair_, token_validator.Pass())); | 111 host_cert_, key_pair_, token_validator.Pass())); |
113 scoped_ptr<ThirdPartyClientAuthenticator::TokenFetcher> | 112 scoped_ptr<ThirdPartyClientAuthenticator::TokenFetcher> |
114 token_fetcher(new FakeTokenFetcher()); | 113 token_fetcher(new FakeTokenFetcher()); |
115 token_fetcher_ = static_cast<FakeTokenFetcher*>(token_fetcher.get()); | 114 token_fetcher_ = static_cast<FakeTokenFetcher*>(token_fetcher.get()); |
116 client_.reset(new ThirdPartyClientAuthenticator( | 115 client_.reset(new ThirdPartyClientAuthenticator(token_fetcher.Pass())); |
117 host_public_key_, token_fetcher.Pass())); | |
118 } | 116 } |
119 | 117 |
120 FakeTokenFetcher* token_fetcher_; | 118 FakeTokenFetcher* token_fetcher_; |
121 FakeTokenValidator* token_validator_; | 119 FakeTokenValidator* token_validator_; |
122 | 120 |
123 private: | 121 private: |
124 DISALLOW_COPY_AND_ASSIGN(ThirdPartyAuthenticatorTest); | 122 DISALLOW_COPY_AND_ASSIGN(ThirdPartyAuthenticatorTest); |
125 }; | 123 }; |
126 | 124 |
127 TEST_F(ThirdPartyAuthenticatorTest, SuccessfulAuth) { | 125 TEST_F(ThirdPartyAuthenticatorTest, SuccessfulAuth) { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 ASSERT_EQ(Authenticator::PROCESSING_MESSAGE, host_->state()); | 208 ASSERT_EQ(Authenticator::PROCESSING_MESSAGE, host_->state()); |
211 ASSERT_NO_FATAL_FAILURE( | 209 ASSERT_NO_FATAL_FAILURE( |
212 token_validator_->OnTokenValidated(kSharedSecret)); | 210 token_validator_->OnTokenValidated(kSharedSecret)); |
213 | 211 |
214 // The end result is that the host rejected the fake authentication. | 212 // The end result is that the host rejected the fake authentication. |
215 ASSERT_EQ(Authenticator::REJECTED, client_->state()); | 213 ASSERT_EQ(Authenticator::REJECTED, client_->state()); |
216 } | 214 } |
217 | 215 |
218 } // namespace protocol | 216 } // namespace protocol |
219 } // namespace remoting | 217 } // namespace remoting |
OLD | NEW |