| 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 <utility> | 5 #include <utility> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
| 11 #include "remoting/base/rsa_key_pair.h" | 11 #include "remoting/base/rsa_key_pair.h" |
| 12 #include "remoting/protocol/authenticator_test_base.h" | 12 #include "remoting/protocol/authenticator_test_base.h" |
| 13 #include "remoting/protocol/channel_authenticator.h" | 13 #include "remoting/protocol/channel_authenticator.h" |
| 14 #include "remoting/protocol/connection_tester.h" | 14 #include "remoting/protocol/connection_tester.h" |
| 15 #include "remoting/protocol/fake_authenticator.h" | 15 #include "remoting/protocol/fake_authenticator.h" |
| 16 #include "remoting/protocol/third_party_authenticator_base.h" | 16 #include "remoting/protocol/third_party_authenticator_base.h" |
| 17 #include "remoting/protocol/third_party_client_authenticator.h" | 17 #include "remoting/protocol/third_party_client_authenticator.h" |
| 18 #include "remoting/protocol/third_party_host_authenticator.h" | 18 #include "remoting/protocol/third_party_host_authenticator.h" |
| 19 #include "remoting/protocol/token_validator.h" | 19 #include "remoting/protocol/token_validator.h" |
| 20 #include "remoting/protocol/v2_authenticator.h" |
| 20 #include "testing/gmock/include/gmock/gmock.h" | 21 #include "testing/gmock/include/gmock/gmock.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
| 22 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" | 23 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" |
| 23 | 24 |
| 24 using testing::_; | 25 using testing::_; |
| 25 using testing::DeleteArg; | 26 using testing::DeleteArg; |
| 26 using testing::SaveArg; | 27 using testing::SaveArg; |
| 27 | 28 |
| 28 namespace { | 29 namespace { |
| 29 | 30 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 std::string token_scope_; | 94 std::string token_scope_; |
| 94 base::Callback<void(const std::string& shared_secret)> on_token_validated_; | 95 base::Callback<void(const std::string& shared_secret)> on_token_validated_; |
| 95 }; | 96 }; |
| 96 | 97 |
| 97 public: | 98 public: |
| 98 ThirdPartyAuthenticatorTest() {} | 99 ThirdPartyAuthenticatorTest() {} |
| 99 ~ThirdPartyAuthenticatorTest() override {} | 100 ~ThirdPartyAuthenticatorTest() override {} |
| 100 | 101 |
| 101 protected: | 102 protected: |
| 102 void InitAuthenticators() { | 103 void InitAuthenticators() { |
| 103 scoped_ptr<TokenValidator> token_validator(new FakeTokenValidator()); | 104 token_validator_ = new FakeTokenValidator(); |
| 104 token_validator_ = static_cast<FakeTokenValidator*>(token_validator.get()); | |
| 105 host_.reset(new ThirdPartyHostAuthenticator( | 105 host_.reset(new ThirdPartyHostAuthenticator( |
| 106 host_cert_, key_pair_, std::move(token_validator))); | 106 base::Bind(&V2Authenticator::CreateForHost, host_cert_, key_pair_), |
| 107 scoped_ptr<ThirdPartyClientAuthenticator::TokenFetcher> | 107 make_scoped_ptr(token_validator_))); |
| 108 token_fetcher(new FakeTokenFetcher()); | 108 token_fetcher_ = new FakeTokenFetcher(); |
| 109 token_fetcher_ = static_cast<FakeTokenFetcher*>(token_fetcher.get()); | 109 client_.reset(new ThirdPartyClientAuthenticator( |
| 110 client_.reset(new ThirdPartyClientAuthenticator(std::move(token_fetcher))); | 110 base::Bind(&V2Authenticator::CreateForClient), |
| 111 make_scoped_ptr(token_fetcher_))); |
| 111 } | 112 } |
| 112 | 113 |
| 113 FakeTokenFetcher* token_fetcher_; | 114 FakeTokenFetcher* token_fetcher_; |
| 114 FakeTokenValidator* token_validator_; | 115 FakeTokenValidator* token_validator_; |
| 115 | 116 |
| 116 private: | 117 private: |
| 117 DISALLOW_COPY_AND_ASSIGN(ThirdPartyAuthenticatorTest); | 118 DISALLOW_COPY_AND_ASSIGN(ThirdPartyAuthenticatorTest); |
| 118 }; | 119 }; |
| 119 | 120 |
| 120 TEST_F(ThirdPartyAuthenticatorTest, SuccessfulAuth) { | 121 TEST_F(ThirdPartyAuthenticatorTest, SuccessfulAuth) { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 ASSERT_EQ(Authenticator::PROCESSING_MESSAGE, host_->state()); | 206 ASSERT_EQ(Authenticator::PROCESSING_MESSAGE, host_->state()); |
| 206 ASSERT_NO_FATAL_FAILURE( | 207 ASSERT_NO_FATAL_FAILURE( |
| 207 token_validator_->OnTokenValidated(kSharedSecret)); | 208 token_validator_->OnTokenValidated(kSharedSecret)); |
| 208 | 209 |
| 209 // The end result is that the host rejected the fake authentication. | 210 // The end result is that the host rejected the fake authentication. |
| 210 ASSERT_EQ(Authenticator::REJECTED, client_->state()); | 211 ASSERT_EQ(Authenticator::REJECTED, client_->state()); |
| 211 } | 212 } |
| 212 | 213 |
| 213 } // namespace protocol | 214 } // namespace protocol |
| 214 } // namespace remoting | 215 } // namespace remoting |
| OLD | NEW |