| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "remoting/host/it2me/it2me_host.h" | 5 #include "remoting/host/it2me/it2me_host.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 namespace remoting { | 30 namespace remoting { |
| 31 | 31 |
| 32 namespace { | 32 namespace { |
| 33 | 33 |
| 34 // Shortening some type names for readability. | 34 // Shortening some type names for readability. |
| 35 typedef protocol::ValidatingAuthenticator::Result ValidationResult; | 35 typedef protocol::ValidatingAuthenticator::Result ValidationResult; |
| 36 typedef It2MeConfirmationDialog::Result DialogResult; | 36 typedef It2MeConfirmationDialog::Result DialogResult; |
| 37 | 37 |
| 38 const char kTestClientUserName[] = "ficticious_user@gmail.com"; | 38 const char kTestClientUserName[] = "ficticious_user@gmail.com"; |
| 39 const char kTestClientJid[] = "ficticious_user@gmail.com/jid_resource"; | 39 const char kTestClientJid[] = "ficticious_user@gmail.com/jid_resource"; |
| 40 const char kTestClientJid2[] = "ficticious_user_2@gmail.com/jid_resource"; |
| 40 const char kTestClientUsernameNoJid[] = "completely_ficticious_user@gmail.com"; | 41 const char kTestClientUsernameNoJid[] = "completely_ficticious_user@gmail.com"; |
| 41 const char kTestClientJidWithSlash[] = "fake/user@gmail.com/jid_resource"; | 42 const char kTestClientJidWithSlash[] = "fake/user@gmail.com/jid_resource"; |
| 42 const char kResourceOnly[] = "/jid_resource"; | 43 const char kResourceOnly[] = "/jid_resource"; |
| 43 const char kMatchingDomain[] = "gmail.com"; | 44 const char kMatchingDomain[] = "gmail.com"; |
| 44 const char kMismatchedDomain1[] = "similar_to_gmail.com"; | 45 const char kMismatchedDomain1[] = "similar_to_gmail.com"; |
| 45 const char kMismatchedDomain2[] = "gmail_at_the_beginning.com"; | 46 const char kMismatchedDomain2[] = "gmail_at_the_beginning.com"; |
| 46 const char kMismatchedDomain3[] = "not_even_close.com"; | 47 const char kMismatchedDomain3[] = "not_even_close.com"; |
| 47 | 48 |
| 48 } // namespace | 49 } // namespace |
| 49 | 50 |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 TEST_F(It2MeHostTest, ConnectionValidation_ConfirmationDialog_Reject) { | 350 TEST_F(It2MeHostTest, ConnectionValidation_ConfirmationDialog_Reject) { |
| 350 dialog_->set_dialog_result(DialogResult::CANCEL); | 351 dialog_->set_dialog_result(DialogResult::CANCEL); |
| 351 SimulateClientConnection(); | 352 SimulateClientConnection(); |
| 352 RunValidationCallback(kTestClientJid); | 353 RunValidationCallback(kTestClientJid); |
| 353 ASSERT_EQ(ValidationResult::ERROR_REJECTED_BY_USER, validation_result_); | 354 ASSERT_EQ(ValidationResult::ERROR_REJECTED_BY_USER, validation_result_); |
| 354 RunUntilStateChanged(It2MeHostState::kDisconnected); | 355 RunUntilStateChanged(It2MeHostState::kDisconnected); |
| 355 ASSERT_EQ(It2MeHostState::kDisconnected, last_host_state_); | 356 ASSERT_EQ(It2MeHostState::kDisconnected, last_host_state_); |
| 356 ASSERT_STREQ(kTestClientUserName, remote_user_email_.c_str()); | 357 ASSERT_STREQ(kTestClientUserName, remote_user_email_.c_str()); |
| 357 } | 358 } |
| 358 | 359 |
| 360 TEST_F(It2MeHostTest, MultipleConnectionsTriggerDisconnect) { |
| 361 SimulateClientConnection(); |
| 362 RunValidationCallback(kTestClientJid); |
| 363 ASSERT_EQ(ValidationResult::SUCCESS, validation_result_); |
| 364 ASSERT_EQ(It2MeHostState::kConnecting, last_host_state_); |
| 365 ASSERT_STREQ(kTestClientUserName, remote_user_email_.c_str()); |
| 366 |
| 367 RunValidationCallback(kTestClientJid2); |
| 368 ASSERT_EQ(ValidationResult::ERROR_TOO_MANY_CONNECTIONS, validation_result_); |
| 369 RunUntilStateChanged(It2MeHostState::kDisconnected); |
| 370 ASSERT_EQ(It2MeHostState::kDisconnected, last_host_state_); |
| 371 } |
| 372 |
| 359 } // namespace remoting | 373 } // namespace remoting |
| OLD | NEW |