| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium OS 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 "chromeos/process_mock.h" | 5 #include "chromeos/process_mock.h" |
| 6 #include "chromeos/syslog_logging.h" | 6 #include "chromeos/syslog_logging.h" |
| 7 #include "chromeos/test_helpers.h" | 7 #include "chromeos/test_helpers.h" |
| 8 #include "gflags/gflags.h" | 8 #include "gflags/gflags.h" |
| 9 #include "gtest/gtest.h" | 9 #include "gtest/gtest.h" |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 using ::testing::InSequence; | 21 using ::testing::InSequence; |
| 22 using ::testing::Return; | 22 using ::testing::Return; |
| 23 | 23 |
| 24 class L2tpManagerTest : public ::testing::Test { | 24 class L2tpManagerTest : public ::testing::Test { |
| 25 public: | 25 public: |
| 26 void SetUp() { | 26 void SetUp() { |
| 27 test_path_ = FilePath("test"); | 27 test_path_ = FilePath("test"); |
| 28 ServiceManager::temp_path_ = new FilePath(test_path_); | 28 ServiceManager::temp_path_ = new FilePath(test_path_); |
| 29 file_util::Delete(test_path_, true); | 29 file_util::Delete(test_path_, true); |
| 30 file_util::CreateDirectory(test_path_); | 30 file_util::CreateDirectory(test_path_); |
| 31 remote_ = "1.2.3.4"; | 31 remote_hostname_ = "vpnserver"; |
| 32 control_path_ = test_path_.Append("control"); | 32 control_path_ = test_path_.Append("control"); |
| 33 pppd_config_path_ = test_path_.Append("pppd.config"); | 33 pppd_config_path_ = test_path_.Append("pppd.config"); |
| 34 ppp_interface_path_ = test_path_.Append("ppp0"); | 34 ppp_interface_path_ = test_path_.Append("ppp0"); |
| 35 l2tpd_ = new ProcessMock; | 35 l2tpd_ = new ProcessMock; |
| 36 l2tp_.l2tpd_.reset(l2tpd_); | 36 l2tp_.l2tpd_.reset(l2tpd_); |
| 37 l2tp_.l2tpd_control_path_ = control_path_; | 37 l2tp_.l2tpd_control_path_ = control_path_; |
| 38 l2tp_.ppp_interface_path_ = ppp_interface_path_; | 38 l2tp_.ppp_interface_path_ = ppp_interface_path_; |
| 39 FLAGS_pppd_plugin = ""; | 39 FLAGS_pppd_plugin = ""; |
| 40 FLAGS_user = "me"; | 40 FLAGS_user = "me"; |
| 41 EXPECT_TRUE(l2tp_.Initialize(remote_)); | 41 EXPECT_TRUE(l2tp_.Initialize(remote_hostname_)); |
| 42 } | 42 } |
| 43 | 43 |
| 44 protected: | 44 protected: |
| 45 std::string remote_; | 45 std::string remote_hostname_; |
| 46 FilePath test_path_; | 46 FilePath test_path_; |
| 47 FilePath control_path_; | 47 FilePath control_path_; |
| 48 FilePath pppd_config_path_; | 48 FilePath pppd_config_path_; |
| 49 FilePath ppp_interface_path_; | 49 FilePath ppp_interface_path_; |
| 50 L2tpManager l2tp_; | 50 L2tpManager l2tp_; |
| 51 ProcessMock* l2tpd_; | 51 ProcessMock* l2tpd_; |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 TEST_F(L2tpManagerTest, FormatL2tpdConfiguration) { | 54 TEST_F(L2tpManagerTest, FormatL2tpdConfiguration) { |
| 55 static const char kBaseExpected[] = | 55 static const char kBaseExpected[] = |
| 56 "[lac managed]\n" | 56 "[lac managed]\n" |
| 57 "lns = 1.2.3.4\n" | 57 "lns = vpnserver\n" |
| 58 "require chap = yes\n" | 58 "require chap = yes\n" |
| 59 "refuse pap = yes\n" | 59 "refuse pap = yes\n" |
| 60 "require authentication = yes\n" | 60 "require authentication = yes\n" |
| 61 "name = me\n" | 61 "name = me\n" |
| 62 "ppp debug = yes\n" | 62 "ppp debug = yes\n" |
| 63 "pppoptfile = test/pppd.config\n" | 63 "pppoptfile = test/pppd.config\n" |
| 64 "length bit = yes\n"; | 64 "length bit = yes\n"; |
| 65 EXPECT_EQ(kBaseExpected, | 65 EXPECT_EQ(kBaseExpected, |
| 66 l2tp_.FormatL2tpdConfiguration(pppd_config_path_.value())); | 66 l2tp_.FormatL2tpdConfiguration(pppd_config_path_.value())); |
| 67 } | 67 } |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 | 171 |
| 172 TEST_F(L2tpManagerTest, PollNothingIfRunning) { | 172 TEST_F(L2tpManagerTest, PollNothingIfRunning) { |
| 173 l2tp_.is_running_ = true; | 173 l2tp_.is_running_ = true; |
| 174 EXPECT_EQ(-1, l2tp_.Poll()); | 174 EXPECT_EQ(-1, l2tp_.Poll()); |
| 175 } | 175 } |
| 176 | 176 |
| 177 int main(int argc, char** argv) { | 177 int main(int argc, char** argv) { |
| 178 SetUpTests(&argc, argv, true); | 178 SetUpTests(&argc, argv, true); |
| 179 return RUN_ALL_TESTS(); | 179 return RUN_ALL_TESTS(); |
| 180 } | 180 } |
| OLD | NEW |