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

Unified Diff: remoting/host/access_verifier_unittest.cc

Issue 3303001: Basic user access check for chromoting host. (Closed)
Patch Set: - Created 10 years, 4 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
« no previous file with comments | « remoting/host/access_verifier.cc ('k') | remoting/host/chromoting_host.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/access_verifier_unittest.cc
diff --git a/remoting/host/access_verifier_unittest.cc b/remoting/host/access_verifier_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7d151f5538dfa2b088a3defa41e92328c9f9a1de
--- /dev/null
+++ b/remoting/host/access_verifier_unittest.cc
@@ -0,0 +1,60 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/ref_counted.h"
+#include "base/task.h"
+#include "remoting/host/access_verifier.h"
+#include "remoting/host/in_memory_host_config.h"
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace remoting {
+
+namespace {
+const char kTestJid[] = "host@domain.com";
+} // namespace
+
+class AccessVerifierTest : public testing::Test {
+ protected:
+ class TestConfigUpdater :
+ public base::RefCountedThreadSafe<TestConfigUpdater> {
+ public:
+ void DoUpdate(scoped_refptr<InMemoryHostConfig> target) {
+ target->SetString(kXmppLoginConfigPath, kTestJid);
+ }
+ };
+
+ virtual void SetUp() {
+ config_ = new InMemoryHostConfig();
+ }
+
+ void InitConfig() {
+ scoped_refptr<TestConfigUpdater> config_updater(new TestConfigUpdater());
+ config_->Update(
+ NewRunnableMethod(config_updater.get(), &TestConfigUpdater::DoUpdate,
+ config_));
+ }
+
+ scoped_refptr<InMemoryHostConfig> config_;
+};
+
+TEST_F(AccessVerifierTest, InvalidConfig) {
+ AccessVerifier target;
+ EXPECT_FALSE(target.Init(config_));
+}
+
+TEST_F(AccessVerifierTest, VerifyPermissions) {
+ AccessVerifier target;
+ InitConfig();
+ ASSERT_TRUE(target.Init(config_));
+ EXPECT_TRUE(target.VerifyPermissions("host@domain.com/123123"));
+ EXPECT_FALSE(target.VerifyPermissions("host@domain.com"));
+ EXPECT_FALSE(target.VerifyPermissions("otherhost@domain.com/123123"));
+ EXPECT_FALSE(target.VerifyPermissions("host@otherdomain.com/123123"));
+ EXPECT_FALSE(target.VerifyPermissions(""));
+ EXPECT_FALSE(target.VerifyPermissions("host@domain.co/saf"));
+ EXPECT_FALSE(target.VerifyPermissions("host@domain.com.other/blah"));
+}
+
+} // namespace remoting
« no previous file with comments | « remoting/host/access_verifier.cc ('k') | remoting/host/chromoting_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698