mukesh agrawal | 9da0777 | 2013-05-15 14:15:17 -0700 | [diff] [blame] | 1 | // Copyright (c) 2013 The Chromium OS 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 "shill/ppp_device.h" |
| 6 | |
| 7 | #include <map> |
| 8 | #include <string> |
| 9 | |
| 10 | #include <gtest/gtest.h> |
| 11 | |
| 12 | #include "shill/mock_ppp_device.h" |
| 13 | |
| 14 | using std::map; |
| 15 | using std::string; |
| 16 | |
| 17 | namespace shill { |
| 18 | |
| 19 | TEST(PPPDeviceTest, GetInterfaceName) { |
| 20 | map<string, string> config; |
| 21 | config[kPPPInterfaceName] = "ppp0"; |
| 22 | config["foo"] = "bar"; |
| 23 | EXPECT_EQ("ppp0", PPPDevice::GetInterfaceName(config)); |
| 24 | } |
| 25 | |
| 26 | TEST(PPPDeviceTest, ParseIPConfiguration) { |
| 27 | map<string, string> config; |
| 28 | config[kPPPInternalIP4Address] = "4.5.6.7"; |
| 29 | config[kPPPExternalIP4Address] = "33.44.55.66"; |
| 30 | config[kPPPGatewayAddress] = "192.168.1.1"; |
| 31 | config[kPPPDNS1] = "1.1.1.1"; |
| 32 | config[kPPPDNS2] = "2.2.2.2"; |
| 33 | config[kPPPInterfaceName] = "ppp0"; |
| 34 | config[kPPPLNSAddress] = "99.88.77.66"; |
| 35 | config["foo"] = "bar"; |
| 36 | IPConfig::Properties props; |
| 37 | PPPDevice::ParseIPConfiguration("in-test", config, &props); |
| 38 | EXPECT_EQ(IPAddress::kFamilyIPv4, props.address_family); |
| 39 | EXPECT_EQ("4.5.6.7", props.address); |
| 40 | EXPECT_EQ("33.44.55.66", props.peer_address); |
| 41 | EXPECT_EQ("192.168.1.1", props.gateway); |
| 42 | EXPECT_EQ("99.88.77.66", props.trusted_ip); |
| 43 | ASSERT_EQ(2, props.dns_servers.size()); |
| 44 | EXPECT_EQ("1.1.1.1", props.dns_servers[0]); |
| 45 | EXPECT_EQ("2.2.2.2", props.dns_servers[1]); |
| 46 | } |
| 47 | |
| 48 | } // namespace shill |