[email protected] | de70211 | 2012-01-30 23:31:43 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
Jinho Bang | 138fde3 | 2018-01-18 23:13:42 | [diff] [blame] | 5 | #include <memory> |
| 6 | |
[email protected] | de70211 | 2012-01-30 23:31:43 | [diff] [blame] | 7 | #include "base/bind.h" |
avi | 5a080f01 | 2015-12-22 23:15:43 | [diff] [blame] | 8 | #include "base/macros.h" |
fdoray | 6d056ff | 2016-07-04 21:56:42 | [diff] [blame] | 9 | #include "base/run_loop.h" |
[email protected] | de70211 | 2012-01-30 23:31:43 | [diff] [blame] | 10 | #include "net/base/net_errors.h" |
[email protected] | 8f1504b | 2013-03-07 13:43:10 | [diff] [blame] | 11 | #include "remoting/base/rsa_key_pair.h" |
sergeyu | 42cb6f9f | 2016-03-09 05:37:03 | [diff] [blame] | 12 | #include "remoting/protocol/auth_util.h" |
[email protected] | de70211 | 2012-01-30 23:31:43 | [diff] [blame] | 13 | #include "remoting/protocol/authenticator_test_base.h" |
| 14 | #include "remoting/protocol/channel_authenticator.h" |
| 15 | #include "remoting/protocol/connection_tester.h" |
[email protected] | 76cfd03 | 2013-04-03 10:49:44 | [diff] [blame] | 16 | #include "remoting/protocol/negotiating_authenticator_base.h" |
| 17 | #include "remoting/protocol/negotiating_client_authenticator.h" |
| 18 | #include "remoting/protocol/negotiating_host_authenticator.h" |
[email protected] | 8835692 | 2013-06-04 06:26:01 | [diff] [blame] | 19 | #include "remoting/protocol/pairing_registry.h" |
[email protected] | 40dade3 | 2013-06-14 07:08:11 | [diff] [blame] | 20 | #include "remoting/protocol/protocol_mock_objects.h" |
[email protected] | de70211 | 2012-01-30 23:31:43 | [diff] [blame] | 21 | #include "testing/gmock/include/gmock/gmock.h" |
| 22 | #include "testing/gtest/include/gtest/gtest.h" |
kjellander | f0e410b | 2017-01-04 14:45:01 | [diff] [blame] | 23 | #include "third_party/libjingle_xmpp/xmllite/xmlelement.h" |
[email protected] | de70211 | 2012-01-30 23:31:43 | [diff] [blame] | 24 | |
| 25 | using testing::_; |
| 26 | using testing::DeleteArg; |
| 27 | using testing::SaveArg; |
| 28 | |
| 29 | namespace remoting { |
| 30 | namespace protocol { |
| 31 | |
| 32 | namespace { |
| 33 | |
| 34 | const int kMessageSize = 100; |
| 35 | const int kMessages = 1; |
| 36 | |
[email protected] | 6434bfe | 2013-05-22 09:00:23 | [diff] [blame] | 37 | const char kNoClientId[] = ""; |
| 38 | const char kNoPairedSecret[] = ""; |
[email protected] | df5189f | 2013-06-18 12:12:05 | [diff] [blame] | 39 | const char kTestClientName[] = "client-name"; |
[email protected] | 6434bfe | 2013-05-22 09:00:23 | [diff] [blame] | 40 | const char kTestClientId[] = "client-id"; |
[email protected] | de70211 | 2012-01-30 23:31:43 | [diff] [blame] | 41 | const char kTestHostId[] = "12345678910123456"; |
| 42 | |
sergeyu | 4357fda5 | 2016-03-12 07:23:24 | [diff] [blame] | 43 | const char kClientJid[] = "[email protected]/abc"; |
| 44 | const char kHostJid[] = "[email protected]/123"; |
| 45 | |
[email protected] | 6434bfe | 2013-05-22 09:00:23 | [diff] [blame] | 46 | const char kTestPairedSecret[] = "1111-2222-3333"; |
| 47 | const char kTestPairedSecretBad[] = "4444-5555-6666"; |
| 48 | const char kTestPin[] = "123456"; |
| 49 | const char kTestPinBad[] = "654321"; |
[email protected] | de70211 | 2012-01-30 23:31:43 | [diff] [blame] | 50 | |
| 51 | } // namespace |
| 52 | |
| 53 | class NegotiatingAuthenticatorTest : public AuthenticatorTestBase { |
| 54 | public: |
Chris Watkins | 6fe52aa | 2017-11-28 03:24:05 | [diff] [blame] | 55 | NegotiatingAuthenticatorTest() = default; |
| 56 | ~NegotiatingAuthenticatorTest() override = default; |
[email protected] | de70211 | 2012-01-30 23:31:43 | [diff] [blame] | 57 | |
| 58 | protected: |
sergeyu | 410cd11 | 2016-03-17 06:15:00 | [diff] [blame] | 59 | virtual void InitAuthenticators(const std::string& client_id, |
| 60 | const std::string& client_paired_secret, |
| 61 | const std::string& client_interactive_pin, |
sergeyu | d5d7539f | 2016-03-17 18:08:03 | [diff] [blame] | 62 | const std::string& host_secret) { |
| 63 | std::string host_secret_hash = |
| 64 | GetSharedSecretHash(kTestHostId, host_secret); |
dcheng | 0765c49 | 2016-04-06 22:41:53 | [diff] [blame] | 65 | std::unique_ptr<NegotiatingHostAuthenticator> host = |
sergeyu | d5d7539f | 2016-03-17 18:08:03 | [diff] [blame] | 66 | NegotiatingHostAuthenticator::CreateWithSharedSecret( |
| 67 | kHostJid, kClientJid, host_cert_, key_pair_, host_secret_hash, |
| 68 | pairing_registry_); |
| 69 | host_as_negotiating_authenticator_ = host.get(); |
| 70 | host_ = std::move(host); |
[email protected] | de70211 | 2012-01-30 23:31:43 | [diff] [blame] | 71 | |
sergeyu | 396d933 | 2016-03-12 01:58:58 | [diff] [blame] | 72 | protocol::ClientAuthenticationConfig client_auth_config; |
| 73 | client_auth_config.host_id = kTestHostId; |
| 74 | client_auth_config.pairing_client_id = client_id; |
sergeyu | 410cd11 | 2016-03-17 06:15:00 | [diff] [blame] | 75 | client_auth_config.pairing_secret = client_paired_secret; |
sergeyu | c5f104b | 2015-01-09 19:33:24 | [diff] [blame] | 76 | bool pairing_expected = pairing_registry_.get() != nullptr; |
sergeyu | 396d933 | 2016-03-12 01:58:58 | [diff] [blame] | 77 | client_auth_config.fetch_secret_callback = |
[email protected] | f9d8a77 | 2013-06-01 04:33:17 | [diff] [blame] | 78 | base::Bind(&NegotiatingAuthenticatorTest::FetchSecret, |
sergeyu | 396d933 | 2016-03-12 01:58:58 | [diff] [blame] | 79 | client_interactive_pin, pairing_expected); |
sergeyu | 4357fda5 | 2016-03-12 07:23:24 | [diff] [blame] | 80 | client_as_negotiating_authenticator_ = new NegotiatingClientAuthenticator( |
| 81 | kClientJid, kHostJid, client_auth_config); |
[email protected] | 6434bfe | 2013-05-22 09:00:23 | [diff] [blame] | 82 | client_.reset(client_as_negotiating_authenticator_); |
| 83 | } |
| 84 | |
sergeyu | 410cd11 | 2016-03-17 06:15:00 | [diff] [blame] | 85 | void DisableMethodOnClient(NegotiatingAuthenticatorBase::Method method) { |
| 86 | auto* methods = &(client_as_negotiating_authenticator_->methods_); |
| 87 | auto iter = std::find(methods->begin(), methods->end(), method); |
| 88 | ASSERT_TRUE(iter != methods->end()); |
| 89 | methods->erase(iter); |
| 90 | } |
| 91 | |
| 92 | void DisableMethodOnHost(NegotiatingAuthenticatorBase::Method method) { |
| 93 | auto* methods = &(host_as_negotiating_authenticator_->methods_); |
| 94 | auto iter = std::find(methods->begin(), methods->end(), method); |
| 95 | ASSERT_TRUE(iter != methods->end()); |
| 96 | methods->erase(iter); |
| 97 | } |
| 98 | |
[email protected] | 40dade3 | 2013-06-14 07:08:11 | [diff] [blame] | 99 | void CreatePairingRegistry(bool with_paired_client) { |
[email protected] | 37846603 | 2013-08-02 01:35:16 | [diff] [blame] | 100 | pairing_registry_ = new SynchronousPairingRegistry( |
Jinho Bang | 138fde3 | 2018-01-18 23:13:42 | [diff] [blame] | 101 | std::make_unique<MockPairingRegistryDelegate>()); |
[email protected] | 40dade3 | 2013-06-14 07:08:11 | [diff] [blame] | 102 | if (with_paired_client) { |
[email protected] | df5189f | 2013-06-18 12:12:05 | [diff] [blame] | 103 | PairingRegistry::Pairing pairing( |
| 104 | base::Time(), kTestClientName, kTestClientId, kTestPairedSecret); |
[email protected] | b1ae901 | 2013-06-23 14:10:30 | [diff] [blame] | 105 | pairing_registry_->AddPairing(pairing); |
[email protected] | 6434bfe | 2013-05-22 09:00:23 | [diff] [blame] | 106 | } |
[email protected] | de70211 | 2012-01-30 23:31:43 | [diff] [blame] | 107 | } |
| 108 | |
[email protected] | 2125752 | 2013-03-23 18:39:13 | [diff] [blame] | 109 | static void FetchSecret( |
| 110 | const std::string& client_secret, |
[email protected] | 4cc63fc | 2013-05-24 07:06:39 | [diff] [blame] | 111 | bool pairing_supported, |
| 112 | bool pairing_expected, |
[email protected] | 2125752 | 2013-03-23 18:39:13 | [diff] [blame] | 113 | const protocol::SecretFetchedCallback& secret_fetched_callback) { |
| 114 | secret_fetched_callback.Run(client_secret); |
[email protected] | 4cc63fc | 2013-05-24 07:06:39 | [diff] [blame] | 115 | ASSERT_EQ(pairing_supported, pairing_expected); |
[email protected] | 2125752 | 2013-03-23 18:39:13 | [diff] [blame] | 116 | } |
[email protected] | 6434bfe | 2013-05-22 09:00:23 | [diff] [blame] | 117 | |
[email protected] | de70211 | 2012-01-30 23:31:43 | [diff] [blame] | 118 | void VerifyRejected(Authenticator::RejectionReason reason) { |
[email protected] | 6434bfe | 2013-05-22 09:00:23 | [diff] [blame] | 119 | ASSERT_TRUE(client_->state() == Authenticator::REJECTED || |
| 120 | host_->state() == Authenticator::REJECTED); |
| 121 | if (client_->state() == Authenticator::REJECTED) { |
| 122 | ASSERT_EQ(client_->rejection_reason(), reason); |
| 123 | } |
| 124 | if (host_->state() == Authenticator::REJECTED) { |
| 125 | ASSERT_EQ(host_->rejection_reason(), reason); |
| 126 | } |
[email protected] | de70211 | 2012-01-30 23:31:43 | [diff] [blame] | 127 | } |
| 128 | |
sergeyu | 410cd11 | 2016-03-17 06:15:00 | [diff] [blame] | 129 | virtual void VerifyAccepted() { |
[email protected] | 2125752 | 2013-03-23 18:39:13 | [diff] [blame] | 130 | ASSERT_NO_FATAL_FAILURE(RunAuthExchange()); |
| 131 | |
| 132 | ASSERT_EQ(Authenticator::ACCEPTED, host_->state()); |
| 133 | ASSERT_EQ(Authenticator::ACCEPTED, client_->state()); |
| 134 | |
| 135 | client_auth_ = client_->CreateChannelAuthenticator(); |
| 136 | host_auth_ = host_->CreateChannelAuthenticator(); |
| 137 | RunChannelAuth(false); |
| 138 | |
sergeyu | c5f104b | 2015-01-09 19:33:24 | [diff] [blame] | 139 | EXPECT_TRUE(client_socket_.get() != nullptr); |
| 140 | EXPECT_TRUE(host_socket_.get() != nullptr); |
[email protected] | 2125752 | 2013-03-23 18:39:13 | [diff] [blame] | 141 | |
| 142 | StreamConnectionTester tester(host_socket_.get(), client_socket_.get(), |
| 143 | kMessageSize, kMessages); |
| 144 | |
| 145 | tester.Start(); |
fdoray | 6d056ff | 2016-07-04 21:56:42 | [diff] [blame] | 146 | base::RunLoop().Run(); |
[email protected] | 2125752 | 2013-03-23 18:39:13 | [diff] [blame] | 147 | tester.CheckResults(); |
sergeyu | 410cd11 | 2016-03-17 06:15:00 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | NegotiatingAuthenticatorBase::Method current_method() { |
| 151 | return client_as_negotiating_authenticator_->current_method_; |
[email protected] | 2125752 | 2013-03-23 18:39:13 | [diff] [blame] | 152 | } |
| 153 | |
[email protected] | 6434bfe | 2013-05-22 09:00:23 | [diff] [blame] | 154 | // Use a bare pointer because the storage is managed by the base class. |
sergeyu | 410cd11 | 2016-03-17 06:15:00 | [diff] [blame] | 155 | NegotiatingHostAuthenticator* host_as_negotiating_authenticator_; |
[email protected] | 6434bfe | 2013-05-22 09:00:23 | [diff] [blame] | 156 | NegotiatingClientAuthenticator* client_as_negotiating_authenticator_; |
| 157 | |
[email protected] | 2125752 | 2013-03-23 18:39:13 | [diff] [blame] | 158 | private: |
[email protected] | 40dade3 | 2013-06-14 07:08:11 | [diff] [blame] | 159 | scoped_refptr<PairingRegistry> pairing_registry_; |
| 160 | |
[email protected] | de70211 | 2012-01-30 23:31:43 | [diff] [blame] | 161 | DISALLOW_COPY_AND_ASSIGN(NegotiatingAuthenticatorTest); |
| 162 | }; |
| 163 | |
sergeyu | 410cd11 | 2016-03-17 06:15:00 | [diff] [blame] | 164 | struct PairingTestParameters { |
| 165 | bool p224_on_client; |
| 166 | bool curve25519_on_client; |
| 167 | bool p224_on_host; |
| 168 | bool curve25519_on_host; |
| 169 | |
| 170 | bool expect_curve25519_used; |
| 171 | }; |
| 172 | |
| 173 | class NegotiatingPairingAuthenticatorTest |
| 174 | : public NegotiatingAuthenticatorTest, |
| 175 | public testing::WithParamInterface<PairingTestParameters> { |
| 176 | public: |
| 177 | void InitAuthenticators(const std::string& client_id, |
| 178 | const std::string& client_paired_secret, |
| 179 | const std::string& client_interactive_pin, |
sergeyu | d5d7539f | 2016-03-17 18:08:03 | [diff] [blame] | 180 | const std::string& host_secret) override { |
sergeyu | 410cd11 | 2016-03-17 06:15:00 | [diff] [blame] | 181 | NegotiatingAuthenticatorTest::InitAuthenticators( |
sergeyu | d5d7539f | 2016-03-17 18:08:03 | [diff] [blame] | 182 | client_id, client_paired_secret, client_interactive_pin, host_secret); |
sergeyu | 410cd11 | 2016-03-17 06:15:00 | [diff] [blame] | 183 | if (!GetParam().p224_on_client) { |
| 184 | DisableMethodOnClient( |
| 185 | NegotiatingAuthenticatorBase::Method::PAIRED_SPAKE2_P224); |
| 186 | } |
| 187 | if (!GetParam().curve25519_on_client) { |
| 188 | DisableMethodOnClient( |
| 189 | NegotiatingAuthenticatorBase::Method::PAIRED_SPAKE2_CURVE25519); |
| 190 | } |
| 191 | if (!GetParam().p224_on_host) { |
| 192 | DisableMethodOnHost( |
| 193 | NegotiatingAuthenticatorBase::Method::PAIRED_SPAKE2_P224); |
| 194 | } |
| 195 | if (!GetParam().curve25519_on_host) { |
| 196 | DisableMethodOnHost( |
| 197 | NegotiatingAuthenticatorBase::Method::PAIRED_SPAKE2_CURVE25519); |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | void VerifyAccepted() override { |
| 202 | NegotiatingAuthenticatorTest::VerifyAccepted(); |
| 203 | EXPECT_TRUE( |
| 204 | current_method() == |
| 205 | NegotiatingAuthenticatorBase::Method::PAIRED_SPAKE2_P224 || |
| 206 | current_method() == |
| 207 | NegotiatingAuthenticatorBase::Method::PAIRED_SPAKE2_CURVE25519); |
| 208 | } |
| 209 | }; |
| 210 | |
| 211 | INSTANTIATE_TEST_CASE_P( |
| 212 | PairingParams, |
| 213 | NegotiatingPairingAuthenticatorTest, |
| 214 | testing::Values( |
| 215 | // Only P224. |
| 216 | PairingTestParameters{true, false, true, false}, |
| 217 | |
| 218 | // Only curve25519. |
| 219 | PairingTestParameters{false, true, false, true}, |
| 220 | |
| 221 | // Both P224 and curve25519. |
| 222 | PairingTestParameters{true, true, true, true}, |
| 223 | |
| 224 | // One end supports both, the other supports only P224 or curve25519. |
| 225 | PairingTestParameters{false, true, true, true}, |
| 226 | PairingTestParameters{true, false, true, true}, |
| 227 | PairingTestParameters{true, true, false, true}, |
| 228 | PairingTestParameters{true, true, true, false})); |
| 229 | |
sergeyu | d5d7539f | 2016-03-17 18:08:03 | [diff] [blame] | 230 | TEST_F(NegotiatingAuthenticatorTest, SuccessfulAuthSharedSecret) { |
sergeyu | 3c75924 | 2016-03-04 21:34:33 | [diff] [blame] | 231 | ASSERT_NO_FATAL_FAILURE(InitAuthenticators(kNoClientId, kNoPairedSecret, |
sergeyu | d5d7539f | 2016-03-17 18:08:03 | [diff] [blame] | 232 | kTestPin, kTestPin)); |
sergeyu | 410cd11 | 2016-03-17 06:15:00 | [diff] [blame] | 233 | VerifyAccepted(); |
| 234 | EXPECT_EQ( |
| 235 | NegotiatingAuthenticatorBase::Method::SHARED_SECRET_SPAKE2_CURVE25519, |
| 236 | current_method()); |
[email protected] | de70211 | 2012-01-30 23:31:43 | [diff] [blame] | 237 | } |
| 238 | |
sergeyu | d5d7539f | 2016-03-17 18:08:03 | [diff] [blame] | 239 | TEST_F(NegotiatingAuthenticatorTest, InvalidSharedSecret) { |
sergeyu | 3c75924 | 2016-03-04 21:34:33 | [diff] [blame] | 240 | ASSERT_NO_FATAL_FAILURE(InitAuthenticators(kNoClientId, kNoPairedSecret, |
sergeyu | d5d7539f | 2016-03-17 18:08:03 | [diff] [blame] | 241 | kTestPinBad, kTestPin)); |
[email protected] | de70211 | 2012-01-30 23:31:43 | [diff] [blame] | 242 | ASSERT_NO_FATAL_FAILURE(RunAuthExchange()); |
| 243 | |
| 244 | VerifyRejected(Authenticator::INVALID_CREDENTIALS); |
| 245 | } |
| 246 | |
[email protected] | 591cffcd | 2014-08-18 20:02:30 | [diff] [blame] | 247 | TEST_F(NegotiatingAuthenticatorTest, IncompatibleMethods) { |
sergeyu | d5d7539f | 2016-03-17 18:08:03 | [diff] [blame] | 248 | ASSERT_NO_FATAL_FAILURE( |
| 249 | InitAuthenticators(kNoClientId, kNoPairedSecret, kTestPin, kTestPinBad)); |
sergeyu | 410cd11 | 2016-03-17 06:15:00 | [diff] [blame] | 250 | DisableMethodOnClient( |
sergeyu | d5d7539f | 2016-03-17 18:08:03 | [diff] [blame] | 251 | NegotiatingAuthenticatorBase::Method::SHARED_SECRET_SPAKE2_P224); |
| 252 | DisableMethodOnHost( |
| 253 | NegotiatingAuthenticatorBase::Method::SHARED_SECRET_SPAKE2_CURVE25519); |
sergeyu | 42cb6f9f | 2016-03-09 05:37:03 | [diff] [blame] | 254 | |
[email protected] | de70211 | 2012-01-30 23:31:43 | [diff] [blame] | 255 | ASSERT_NO_FATAL_FAILURE(RunAuthExchange()); |
| 256 | |
| 257 | VerifyRejected(Authenticator::PROTOCOL_ERROR); |
| 258 | } |
| 259 | |
[email protected] | 591cffcd | 2014-08-18 20:02:30 | [diff] [blame] | 260 | TEST_F(NegotiatingAuthenticatorTest, PairingNotSupported) { |
sergeyu | d5d7539f | 2016-03-17 18:08:03 | [diff] [blame] | 261 | ASSERT_NO_FATAL_FAILURE( |
| 262 | InitAuthenticators(kTestClientId, kTestPairedSecret, kTestPin, kTestPin)); |
[email protected] | 6434bfe | 2013-05-22 09:00:23 | [diff] [blame] | 263 | ASSERT_NO_FATAL_FAILURE(RunAuthExchange()); |
sergeyu | 410cd11 | 2016-03-17 06:15:00 | [diff] [blame] | 264 | VerifyAccepted(); |
| 265 | EXPECT_EQ( |
| 266 | NegotiatingAuthenticatorBase::Method::SHARED_SECRET_SPAKE2_CURVE25519, |
| 267 | current_method()); |
[email protected] | 6434bfe | 2013-05-22 09:00:23 | [diff] [blame] | 268 | } |
| 269 | |
sergeyu | 410cd11 | 2016-03-17 06:15:00 | [diff] [blame] | 270 | TEST_P(NegotiatingPairingAuthenticatorTest, PairingSupportedButNotPaired) { |
[email protected] | 40dade3 | 2013-06-14 07:08:11 | [diff] [blame] | 271 | CreatePairingRegistry(false); |
sergeyu | d5d7539f | 2016-03-17 18:08:03 | [diff] [blame] | 272 | ASSERT_NO_FATAL_FAILURE( |
| 273 | InitAuthenticators(kNoClientId, kNoPairedSecret, kTestPin, kTestPin)); |
[email protected] | 6434bfe | 2013-05-22 09:00:23 | [diff] [blame] | 274 | ASSERT_NO_FATAL_FAILURE(RunAuthExchange()); |
sergeyu | 410cd11 | 2016-03-17 06:15:00 | [diff] [blame] | 275 | VerifyAccepted(); |
[email protected] | 6434bfe | 2013-05-22 09:00:23 | [diff] [blame] | 276 | } |
| 277 | |
sergeyu | 410cd11 | 2016-03-17 06:15:00 | [diff] [blame] | 278 | TEST_P(NegotiatingPairingAuthenticatorTest, PairingRevokedPinOkay) { |
[email protected] | 40dade3 | 2013-06-14 07:08:11 | [diff] [blame] | 279 | CreatePairingRegistry(false); |
sergeyu | d5d7539f | 2016-03-17 18:08:03 | [diff] [blame] | 280 | ASSERT_NO_FATAL_FAILURE( |
| 281 | InitAuthenticators(kTestClientId, kTestPairedSecret, kTestPin, kTestPin)); |
[email protected] | 6434bfe | 2013-05-22 09:00:23 | [diff] [blame] | 282 | ASSERT_NO_FATAL_FAILURE(RunAuthExchange()); |
sergeyu | 410cd11 | 2016-03-17 06:15:00 | [diff] [blame] | 283 | VerifyAccepted(); |
[email protected] | 6434bfe | 2013-05-22 09:00:23 | [diff] [blame] | 284 | } |
| 285 | |
sergeyu | 410cd11 | 2016-03-17 06:15:00 | [diff] [blame] | 286 | TEST_P(NegotiatingPairingAuthenticatorTest, PairingRevokedPinBad) { |
[email protected] | 40dade3 | 2013-06-14 07:08:11 | [diff] [blame] | 287 | CreatePairingRegistry(false); |
sergeyu | 42cb6f9f | 2016-03-09 05:37:03 | [diff] [blame] | 288 | ASSERT_NO_FATAL_FAILURE(InitAuthenticators(kTestClientId, kTestPairedSecret, |
sergeyu | d5d7539f | 2016-03-17 18:08:03 | [diff] [blame] | 289 | kTestPinBad, kTestPin)); |
[email protected] | 6434bfe | 2013-05-22 09:00:23 | [diff] [blame] | 290 | ASSERT_NO_FATAL_FAILURE(RunAuthExchange()); |
| 291 | VerifyRejected(Authenticator::INVALID_CREDENTIALS); |
| 292 | } |
| 293 | |
sergeyu | 410cd11 | 2016-03-17 06:15:00 | [diff] [blame] | 294 | TEST_P(NegotiatingPairingAuthenticatorTest, PairingSucceeded) { |
[email protected] | 40dade3 | 2013-06-14 07:08:11 | [diff] [blame] | 295 | CreatePairingRegistry(true); |
sergeyu | 42cb6f9f | 2016-03-09 05:37:03 | [diff] [blame] | 296 | ASSERT_NO_FATAL_FAILURE(InitAuthenticators(kTestClientId, kTestPairedSecret, |
sergeyu | d5d7539f | 2016-03-17 18:08:03 | [diff] [blame] | 297 | kTestPinBad, kTestPin)); |
[email protected] | 6434bfe | 2013-05-22 09:00:23 | [diff] [blame] | 298 | ASSERT_NO_FATAL_FAILURE(RunAuthExchange()); |
sergeyu | 410cd11 | 2016-03-17 06:15:00 | [diff] [blame] | 299 | VerifyAccepted(); |
[email protected] | 6434bfe | 2013-05-22 09:00:23 | [diff] [blame] | 300 | } |
| 301 | |
sergeyu | 410cd11 | 2016-03-17 06:15:00 | [diff] [blame] | 302 | TEST_P(NegotiatingPairingAuthenticatorTest, |
[email protected] | 591cffcd | 2014-08-18 20:02:30 | [diff] [blame] | 303 | PairingSucceededInvalidSecretButPinOkay) { |
[email protected] | 40dade3 | 2013-06-14 07:08:11 | [diff] [blame] | 304 | CreatePairingRegistry(true); |
[email protected] | 6434bfe | 2013-05-22 09:00:23 | [diff] [blame] | 305 | ASSERT_NO_FATAL_FAILURE(InitAuthenticators( |
sergeyu | d5d7539f | 2016-03-17 18:08:03 | [diff] [blame] | 306 | kTestClientId, kTestPairedSecretBad, kTestPin, kTestPin)); |
[email protected] | 6434bfe | 2013-05-22 09:00:23 | [diff] [blame] | 307 | ASSERT_NO_FATAL_FAILURE(RunAuthExchange()); |
sergeyu | 410cd11 | 2016-03-17 06:15:00 | [diff] [blame] | 308 | VerifyAccepted(); |
[email protected] | 6434bfe | 2013-05-22 09:00:23 | [diff] [blame] | 309 | } |
| 310 | |
sergeyu | 410cd11 | 2016-03-17 06:15:00 | [diff] [blame] | 311 | TEST_P(NegotiatingPairingAuthenticatorTest, PairingFailedInvalidSecretAndPin) { |
[email protected] | 40dade3 | 2013-06-14 07:08:11 | [diff] [blame] | 312 | CreatePairingRegistry(true); |
sergeyu | 42cb6f9f | 2016-03-09 05:37:03 | [diff] [blame] | 313 | ASSERT_NO_FATAL_FAILURE(InitAuthenticators( |
sergeyu | d5d7539f | 2016-03-17 18:08:03 | [diff] [blame] | 314 | kTestClientId, kTestPairedSecretBad, kTestPinBad, kTestPin)); |
[email protected] | 6434bfe | 2013-05-22 09:00:23 | [diff] [blame] | 315 | ASSERT_NO_FATAL_FAILURE(RunAuthExchange()); |
| 316 | VerifyRejected(Authenticator::INVALID_CREDENTIALS); |
| 317 | } |
| 318 | |
[email protected] | de70211 | 2012-01-30 23:31:43 | [diff] [blame] | 319 | } // namespace protocol |
| 320 | } // namespace remoting |