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

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

Issue 959033004: Remove ClientLogin support from remoting host (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 unified diff | Download patch
« no previous file with comments | « remoting/host/host_config_constants.cc ('k') | remoting/host/host_signaling_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "remoting/host/host_config.h" 5 #include "remoting/host/host_config.h"
6 6
7 #include "base/files/file_util.h" 7 #include "base/files/file_util.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 namespace remoting { 13 namespace remoting {
14 14
15 namespace { 15 namespace {
16 16
17 const char* kTestConfig = 17 const char* kTestConfig =
18 "{\n" 18 "{\n"
19 " \"xmpp_login\" : \"test@gmail.com\",\n" 19 " \"xmpp_login\" : \"test@gmail.com\",\n"
20 " \"xmpp_auth_token\" : \"TEST_AUTH_TOKEN\",\n" 20 " \"oauth_refresh_token\" : \"TEST_REFRESH_TOKEN\",\n"
21 " \"host_id\" : \"TEST_HOST_ID\",\n" 21 " \"host_id\" : \"TEST_HOST_ID\",\n"
22 " \"host_name\" : \"TEST_MACHINE_NAME\",\n" 22 " \"host_name\" : \"TEST_MACHINE_NAME\",\n"
23 " \"private_key\" : \"TEST_PRIVATE_KEY\"\n" 23 " \"private_key\" : \"TEST_PRIVATE_KEY\"\n"
24 "}\n"; 24 "}\n";
25 25
26 } // namespace 26 } // namespace
27 27
28 class HostConfigTest : public testing::Test { 28 class HostConfigTest : public testing::Test {
29 protected: 29 protected:
30 HostConfigTest() {} 30 HostConfigTest() {}
(...skipping 19 matching lines...) Expand all
50 TEST_F(HostConfigTest, Read) { 50 TEST_F(HostConfigTest, Read) {
51 ASSERT_TRUE(test_dir_.CreateUniqueTempDir()); 51 ASSERT_TRUE(test_dir_.CreateUniqueTempDir());
52 base::FilePath test_file = test_dir_.path().AppendASCII("read.json"); 52 base::FilePath test_file = test_dir_.path().AppendASCII("read.json");
53 WriteTestFile(test_file); 53 WriteTestFile(test_file);
54 scoped_ptr<base::DictionaryValue> target(HostConfigFromJsonFile(test_file)); 54 scoped_ptr<base::DictionaryValue> target(HostConfigFromJsonFile(test_file));
55 ASSERT_TRUE(target); 55 ASSERT_TRUE(target);
56 56
57 std::string value; 57 std::string value;
58 EXPECT_TRUE(target->GetString(kXmppLoginConfigPath, &value)); 58 EXPECT_TRUE(target->GetString(kXmppLoginConfigPath, &value));
59 EXPECT_EQ("test@gmail.com", value); 59 EXPECT_EQ("test@gmail.com", value);
60 EXPECT_TRUE(target->GetString(kXmppAuthTokenConfigPath, &value)); 60 EXPECT_TRUE(target->GetString(kOAuthRefreshTokenConfigPath, &value));
61 EXPECT_EQ("TEST_AUTH_TOKEN", value); 61 EXPECT_EQ("TEST_REFRESH_TOKEN", value);
62 EXPECT_TRUE(target->GetString(kHostIdConfigPath, &value)); 62 EXPECT_TRUE(target->GetString(kHostIdConfigPath, &value));
63 EXPECT_EQ("TEST_HOST_ID", value); 63 EXPECT_EQ("TEST_HOST_ID", value);
64 EXPECT_TRUE(target->GetString(kHostNameConfigPath, &value)); 64 EXPECT_TRUE(target->GetString(kHostNameConfigPath, &value));
65 EXPECT_EQ("TEST_MACHINE_NAME", value); 65 EXPECT_EQ("TEST_MACHINE_NAME", value);
66 EXPECT_TRUE(target->GetString(kPrivateKeyConfigPath, &value)); 66 EXPECT_TRUE(target->GetString(kPrivateKeyConfigPath, &value));
67 EXPECT_EQ("TEST_PRIVATE_KEY", value); 67 EXPECT_EQ("TEST_PRIVATE_KEY", value);
68 68
69 EXPECT_FALSE(target->GetString("non_existent_value", &value)); 69 EXPECT_FALSE(target->GetString("non_existent_value", &value));
70 } 70 }
71 71
72 TEST_F(HostConfigTest, Write) { 72 TEST_F(HostConfigTest, Write) {
73 ASSERT_TRUE(test_dir_.CreateUniqueTempDir()); 73 ASSERT_TRUE(test_dir_.CreateUniqueTempDir());
74 74
75 base::FilePath test_file = test_dir_.path().AppendASCII("write.json"); 75 base::FilePath test_file = test_dir_.path().AppendASCII("write.json");
76 WriteTestFile(test_file); 76 WriteTestFile(test_file);
77 scoped_ptr<base::DictionaryValue> target(HostConfigFromJsonFile(test_file)); 77 scoped_ptr<base::DictionaryValue> target(HostConfigFromJsonFile(test_file));
78 ASSERT_TRUE(target); 78 ASSERT_TRUE(target);
79 79
80 std::string new_auth_token_value = "NEW_AUTH_TOKEN"; 80 std::string new_refresh_token_value = "NEW_REFRESH_TOKEN";
81 target->SetString(kXmppAuthTokenConfigPath, new_auth_token_value); 81 target->SetString(kOAuthRefreshTokenConfigPath, new_refresh_token_value);
82 ASSERT_TRUE(HostConfigToJsonFile(*target, test_file)); 82 ASSERT_TRUE(HostConfigToJsonFile(*target, test_file));
83 83
84 // Now read the file again and check that the value has been written. 84 // Now read the file again and check that the value has been written.
85 scoped_ptr<base::DictionaryValue> reader(HostConfigFromJsonFile(test_file)); 85 scoped_ptr<base::DictionaryValue> reader(HostConfigFromJsonFile(test_file));
86 ASSERT_TRUE(reader); 86 ASSERT_TRUE(reader);
87 87
88 std::string value; 88 std::string value;
89 EXPECT_TRUE(reader->GetString(kXmppLoginConfigPath, &value)); 89 EXPECT_TRUE(reader->GetString(kXmppLoginConfigPath, &value));
90 EXPECT_EQ("test@gmail.com", value); 90 EXPECT_EQ("test@gmail.com", value);
91 EXPECT_TRUE(reader->GetString(kXmppAuthTokenConfigPath, &value)); 91 EXPECT_TRUE(reader->GetString(kOAuthRefreshTokenConfigPath, &value));
92 EXPECT_EQ(new_auth_token_value, value); 92 EXPECT_EQ(new_refresh_token_value, value);
93 EXPECT_TRUE(reader->GetString(kHostIdConfigPath, &value)); 93 EXPECT_TRUE(reader->GetString(kHostIdConfigPath, &value));
94 EXPECT_EQ("TEST_HOST_ID", value); 94 EXPECT_EQ("TEST_HOST_ID", value);
95 EXPECT_TRUE(reader->GetString(kHostNameConfigPath, &value)); 95 EXPECT_TRUE(reader->GetString(kHostNameConfigPath, &value));
96 EXPECT_EQ("TEST_MACHINE_NAME", value); 96 EXPECT_EQ("TEST_MACHINE_NAME", value);
97 EXPECT_TRUE(reader->GetString(kPrivateKeyConfigPath, &value)); 97 EXPECT_TRUE(reader->GetString(kPrivateKeyConfigPath, &value));
98 EXPECT_EQ("TEST_PRIVATE_KEY", value); 98 EXPECT_EQ("TEST_PRIVATE_KEY", value);
99 } 99 }
100 100
101 } // namespace remoting 101 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/host_config_constants.cc ('k') | remoting/host/host_signaling_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698