Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(372)

Unified Diff: remoting/host/it2me/it2me_host_unittest.cc

Issue 2682473003: Add support for multiple allowed domains (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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_);

Powered by Google App Engine
This is Rietveld 408576698