blob: bf3b97046e723727b4ee21862fe335ba39bc0441 [file] [log] [blame]
mukesh agrawal9da07772013-05-15 14:15:17 -07001// 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
14using std::map;
15using std::string;
16
17namespace shill {
18
mukesh agrawalf407d592013-07-31 11:37:57 -070019// TODO(quiche): Add test for UpdateIPConfigFromPPP. crbug.com/266404
20
mukesh agrawal9da07772013-05-15 14:15:17 -070021TEST(PPPDeviceTest, GetInterfaceName) {
22 map<string, string> config;
23 config[kPPPInterfaceName] = "ppp0";
24 config["foo"] = "bar";
25 EXPECT_EQ("ppp0", PPPDevice::GetInterfaceName(config));
26}
27
28TEST(PPPDeviceTest, ParseIPConfiguration) {
29 map<string, string> config;
30 config[kPPPInternalIP4Address] = "4.5.6.7";
31 config[kPPPExternalIP4Address] = "33.44.55.66";
32 config[kPPPGatewayAddress] = "192.168.1.1";
33 config[kPPPDNS1] = "1.1.1.1";
34 config[kPPPDNS2] = "2.2.2.2";
35 config[kPPPInterfaceName] = "ppp0";
36 config[kPPPLNSAddress] = "99.88.77.66";
37 config["foo"] = "bar";
38 IPConfig::Properties props;
39 PPPDevice::ParseIPConfiguration("in-test", config, &props);
40 EXPECT_EQ(IPAddress::kFamilyIPv4, props.address_family);
41 EXPECT_EQ("4.5.6.7", props.address);
42 EXPECT_EQ("33.44.55.66", props.peer_address);
43 EXPECT_EQ("192.168.1.1", props.gateway);
44 EXPECT_EQ("99.88.77.66", props.trusted_ip);
45 ASSERT_EQ(2, props.dns_servers.size());
46 EXPECT_EQ("1.1.1.1", props.dns_servers[0]);
47 EXPECT_EQ("2.2.2.2", props.dns_servers[1]);
48}
49
50} // namespace shill