| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 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/memory/ref_counted.h" | |
| 6 #include "base/task.h" | |
| 7 #include "remoting/host/in_memory_host_config.h" | |
| 8 #include "remoting/host/self_access_verifier.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 SelfAccessVerifierTest : public testing::Test { | |
| 19 protected: | |
| 20 virtual void SetUp() { | |
| 21 config_ = new InMemoryHostConfig(); | |
| 22 } | |
| 23 | |
| 24 void InitConfig() { | |
| 25 config_->SetString(kXmppLoginConfigPath, kTestJid); | |
| 26 } | |
| 27 | |
| 28 scoped_refptr<InMemoryHostConfig> config_; | |
| 29 }; | |
| 30 | |
| 31 TEST_F(SelfAccessVerifierTest, InvalidConfig) { | |
| 32 SelfAccessVerifier target; | |
| 33 EXPECT_FALSE(target.Init(config_)); | |
| 34 } | |
| 35 | |
| 36 TEST_F(SelfAccessVerifierTest, VerifyPermissions) { | |
| 37 SelfAccessVerifier target; | |
| 38 InitConfig(); | |
| 39 ASSERT_TRUE(target.Init(config_)); | |
| 40 EXPECT_TRUE(target.VerifyPermissions("host@domain.com/123123", "")); | |
| 41 EXPECT_TRUE(target.VerifyPermissions("hOsT@domain.com/123123", "")); | |
| 42 EXPECT_FALSE(target.VerifyPermissions("host@domain.com", "")); | |
| 43 EXPECT_FALSE(target.VerifyPermissions("otherhost@domain.com/123123", "")); | |
| 44 EXPECT_FALSE(target.VerifyPermissions("host@otherdomain.com/123123", "")); | |
| 45 EXPECT_FALSE(target.VerifyPermissions("", "")); | |
| 46 EXPECT_FALSE(target.VerifyPermissions("host@domain.co/saf", "")); | |
| 47 EXPECT_FALSE(target.VerifyPermissions("host@domain.com.other/blah", "")); | |
| 48 | |
| 49 // Non ASCII string. | |
| 50 EXPECT_FALSE(target.VerifyPermissions("абв@domain.com/saf", "")); | |
| 51 } | |
| 52 | |
| 53 } // namespace remoting | |
| OLD | NEW |