Chromium Code Reviews

Side by Side Diff: remoting/host/access_verifier_unittest.cc

Issue 3303001: Basic user access check for chromoting host. (Closed)
Patch Set: - Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « remoting/host/access_verifier.cc ('k') | remoting/host/chromoting_host.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2010 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
5 #include "base/ref_counted.h"
6 #include "base/task.h"
7 #include "remoting/host/access_verifier.h"
8 #include "remoting/host/in_memory_host_config.h"
9 #include "testing/gmock/include/gmock/gmock.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11
12 namespace remoting {
13
14 namespace {
15 const char kTestJid[] = "host@domain.com";
16 } // namespace
17
18 class AccessVerifierTest : public testing::Test {
19 protected:
20 class TestConfigUpdater :
21 public base::RefCountedThreadSafe<TestConfigUpdater> {
22 public:
23 void DoUpdate(scoped_refptr<InMemoryHostConfig> target) {
24 target->SetString(kXmppLoginConfigPath, kTestJid);
25 }
26 };
27
28 virtual void SetUp() {
29 config_ = new InMemoryHostConfig();
30 }
31
32 void InitConfig() {
33 scoped_refptr<TestConfigUpdater> config_updater(new TestConfigUpdater());
34 config_->Update(
35 NewRunnableMethod(config_updater.get(), &TestConfigUpdater::DoUpdate,
36 config_));
37 }
38
39 scoped_refptr<InMemoryHostConfig> config_;
40 };
41
42 TEST_F(AccessVerifierTest, InvalidConfig) {
43 AccessVerifier target;
44 EXPECT_FALSE(target.Init(config_));
45 }
46
47 TEST_F(AccessVerifierTest, VerifyPermissions) {
48 AccessVerifier target;
49 InitConfig();
50 ASSERT_TRUE(target.Init(config_));
51 EXPECT_TRUE(target.VerifyPermissions("host@domain.com/123123"));
52 EXPECT_FALSE(target.VerifyPermissions("host@domain.com"));
53 EXPECT_FALSE(target.VerifyPermissions("otherhost@domain.com/123123"));
54 EXPECT_FALSE(target.VerifyPermissions("host@otherdomain.com/123123"));
55 EXPECT_FALSE(target.VerifyPermissions(""));
56 EXPECT_FALSE(target.VerifyPermissions("host@domain.co/saf"));
57 EXPECT_FALSE(target.VerifyPermissions("host@domain.com.other/blah"));
58 }
59
60 } // namespace remoting
OLDNEW
« 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