| Index: remoting/host/it2me/it2me_host_unittest.cc
|
| diff --git a/remoting/host/it2me/it2me_host_unittest.cc b/remoting/host/it2me/it2me_host_unittest.cc
|
| index c578985257a9ca65847a00d1673b582939e96d56..09f765d3ca756a383344177fef813a4659f46dfe 100644
|
| --- a/remoting/host/it2me/it2me_host_unittest.cc
|
| +++ b/remoting/host/it2me/it2me_host_unittest.cc
|
| @@ -93,6 +93,7 @@ class It2MeHostTest : public testing::Test {
|
|
|
| protected:
|
| void SetClientDomainPolicy(const std::string& policy_value);
|
| + void SetClientDomainListPolicy(const std::vector<std::string>& policy_value);
|
|
|
| void RunValidationCallback(const std::string& remote_jid);
|
|
|
| @@ -157,6 +158,19 @@ void It2MeHostTest::SetClientDomainPolicy(const std::string& policy_value) {
|
| run_loop.Run();
|
| }
|
|
|
| +void It2MeHostTest::SetClientDomainListPolicy(
|
| + const std::vector<std::string> &policy_value) {
|
| + auto policies = base::MakeUnique<base::DictionaryValue>();
|
| + auto domains = base::MakeUnique<base::ListValue>();
|
| + domains->AppendStrings(policy_value);
|
| + policies->Set(policy::key::kRemoteAccessHostClientDomainList,
|
| + std::move(domains));
|
| +
|
| + base::RunLoop run_loop;
|
| + it2me_host_->SetPolicyForTesting(std::move(policies), run_loop.QuitClosure());
|
| + run_loop.Run();
|
| +}
|
| +
|
| void It2MeHostTest::RunValidationCallback(const std::string& remote_jid) {
|
| base::RunLoop run_loop;
|
|
|
| @@ -242,6 +256,59 @@ TEST_F(It2MeHostTest, ConnectionValidation_WrongClientDomain_MatchEnd) {
|
| ASSERT_EQ(ValidationResult::ERROR_INVALID_ACCOUNT, validation_result_);
|
| }
|
|
|
| +TEST_F(It2MeHostTest, ConnectionValidation_ClientDomainListPolicy_Match) {
|
| + SetClientDomainListPolicy({kMismatchedDomain1, kMismatchedDomain2,
|
| + kMatchingDomain, kMismatchedDomain3});
|
| + RunValidationCallback(kTestClientJid);
|
| + ASSERT_EQ(ValidationResult::SUCCESS, validation_result_);
|
| +}
|
| +
|
| +TEST_F(It2MeHostTest, ConnectionValidation_ClientDomainListPolicy_NoMatch) {
|
| + SetClientDomainListPolicy({kMismatchedDomain1, kMismatchedDomain2,
|
| + kMismatchedDomain3});
|
| + RunValidationCallback(kTestClientJid);
|
| + ASSERT_EQ(ValidationResult::ERROR_INVALID_ACCOUNT, validation_result_);
|
| +}
|
| +
|
| +TEST_F(It2MeHostTest,
|
| + ConnectionValidation_ClientDomainListPolicy_InvalidUsername) {
|
| + SetClientDomainListPolicy({kMismatchedDomain1, kMismatchedDomain2,
|
| + kMatchingDomain, kMismatchedDomain3});
|
| + RunValidationCallback(kTestClientJidWithSlash);
|
| + ASSERT_EQ(ValidationResult::ERROR_INVALID_ACCOUNT, validation_result_);
|
| +}
|
| +
|
| +TEST_F(It2MeHostTest, ConnectionValidation_ClientDomainListPolicy_NoJid) {
|
| + SetClientDomainListPolicy({kMismatchedDomain1, kMismatchedDomain2,
|
| + kMatchingDomain, kMismatchedDomain3});
|
| + RunValidationCallback(kTestClientUsernameNoJid);
|
| + ASSERT_EQ(ValidationResult::ERROR_INVALID_ACCOUNT, validation_result_);
|
| +}
|
| +
|
| +TEST_F(It2MeHostTest, ConnectionValidation_ClientDomainPolicy_List_Match) {
|
| + SetClientDomainPolicy(kMatchingDomain);
|
| + SetClientDomainListPolicy({kMismatchedDomain1, kMismatchedDomain2,
|
| + kMatchingDomain, kMismatchedDomain3});
|
| + RunValidationCallback(kTestClientJid);
|
| + ASSERT_EQ(ValidationResult::SUCCESS, validation_result_);
|
| +}
|
| +
|
| +TEST_F(It2MeHostTest, ConnectionValidation_ClientDomainPolicy_List_NoMatch1) {
|
| + SetClientDomainPolicy(kMatchingDomain);
|
| + SetClientDomainListPolicy({kMismatchedDomain1, kMismatchedDomain2,
|
| + kMismatchedDomain3});
|
| + RunValidationCallback(kTestClientJid);
|
| + ASSERT_EQ(ValidationResult::ERROR_INVALID_ACCOUNT, validation_result_);
|
| +}
|
| +
|
| +TEST_F(It2MeHostTest, ConnectionValidation_ClientDomainPolicy_List_NoMatch2) {
|
| + SetClientDomainPolicy(kMismatchedDomain1);
|
| + SetClientDomainListPolicy({kMismatchedDomain1, kMismatchedDomain2,
|
| + kMatchingDomain, kMismatchedDomain3});
|
| + RunValidationCallback(kTestClientJid);
|
| + ASSERT_EQ(ValidationResult::ERROR_INVALID_ACCOUNT, validation_result_);
|
| +}
|
| +
|
| TEST_F(It2MeHostTest, ConnectionValidation_ConfirmationDialog_Accept) {
|
| RunValidationCallback(kTestClientJid);
|
| ASSERT_EQ(ValidationResult::SUCCESS, validation_result_);
|
|
|