blob: 115b0f76db0515fb7da398fa7fddb53e08261334 [file] [log] [blame]
mukesh agrawal6bb9e7c2012-01-30 14:57:54 -08001// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
Darin Petkove7cb7f82011-06-03 13:21:51 -07002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Chris Masone8a7b8be2011-07-22 12:43:37 -07005#include "shill/dhcp_config.h"
6
Eric Shienbrood3e20a232012-02-16 11:35:56 -05007#include <base/bind.h>
Darin Petkov92c43902011-06-09 20:46:06 -07008#include <base/file_util.h>
Eric Shienbrood3e20a232012-02-16 11:35:56 -05009#include <base/scoped_temp_dir.h>
Darin Petkov92c43902011-06-09 20:46:06 -070010#include <base/stringprintf.h>
Chris Masone43b48a12011-07-01 13:37:07 -070011#include <chromeos/dbus/service_constants.h>
Chris Masone8a7b8be2011-07-22 12:43:37 -070012#include <gtest/gtest.h>
Darin Petkov92c43902011-06-09 20:46:06 -070013
Chris Masone43b48a12011-07-01 13:37:07 -070014#include "shill/dbus_adaptor.h"
Darin Petkovf7897bc2011-06-08 17:13:36 -070015#include "shill/dhcp_provider.h"
Paul Stewart26b327e2011-10-19 11:38:09 -070016#include "shill/event_dispatcher.h"
Chris Masone19e30402011-07-19 15:48:47 -070017#include "shill/mock_control.h"
Darin Petkov98dd6a02011-06-10 15:12:57 -070018#include "shill/mock_dhcp_proxy.h"
Darin Petkovf7897bc2011-06-08 17:13:36 -070019#include "shill/mock_glib.h"
Chris Masone43b48a12011-07-01 13:37:07 -070020#include "shill/property_store_unittest.h"
Darin Petkova7b89492011-07-27 12:48:17 -070021#include "shill/proxy_factory.h"
Darin Petkove7cb7f82011-06-03 13:21:51 -070022
Eric Shienbrood3e20a232012-02-16 11:35:56 -050023using base::Bind;
24using base::Unretained;
Darin Petkove7cb7f82011-06-03 13:21:51 -070025using std::string;
26using std::vector;
Darin Petkovf7897bc2011-06-08 17:13:36 -070027using testing::_;
28using testing::Return;
29using testing::SetArgumentPointee;
Darin Petkove7cb7f82011-06-03 13:21:51 -070030using testing::Test;
31
32namespace shill {
33
Darin Petkov92c43902011-06-09 20:46:06 -070034namespace {
Darin Petkova7b89492011-07-27 12:48:17 -070035const char kDeviceName[] = "eth0";
Paul Stewartd32f4842012-01-11 16:08:13 -080036const char kHostName[] = "hostname";
Darin Petkov92c43902011-06-09 20:46:06 -070037} // namespace {}
38
Chris Masone43b48a12011-07-01 13:37:07 -070039class DHCPConfigTest : public PropertyStoreTest {
Darin Petkove7cb7f82011-06-03 13:21:51 -070040 public:
Darin Petkovf7897bc2011-06-08 17:13:36 -070041 DHCPConfigTest()
Darin Petkovf65e9282011-06-21 14:29:56 -070042 : proxy_(new MockDHCPProxy()),
Darin Petkova7b89492011-07-27 12:48:17 -070043 proxy_factory_(this),
Chris Masone19e30402011-07-19 15:48:47 -070044 config_(new DHCPConfig(&control_,
Chris Masone2176a882011-09-14 22:29:15 -070045 dispatcher(),
Chris Masone19e30402011-07-19 15:48:47 -070046 DHCPProvider::GetInstance(),
Darin Petkov92c43902011-06-09 20:46:06 -070047 kDeviceName,
Paul Stewartd32f4842012-01-11 16:08:13 -080048 kHostName,
Chris Masone2176a882011-09-14 22:29:15 -070049 glib())) {}
Darin Petkova7b89492011-07-27 12:48:17 -070050
51 virtual void SetUp() {
Darin Petkovab565bb2011-10-06 02:55:51 -070052 config_->proxy_factory_ = &proxy_factory_;
Darin Petkova7b89492011-07-27 12:48:17 -070053 }
54
55 virtual void TearDown() {
Darin Petkovab565bb2011-10-06 02:55:51 -070056 config_->proxy_factory_ = NULL;
Darin Petkov98dd6a02011-06-10 15:12:57 -070057 }
Darin Petkove7cb7f82011-06-03 13:21:51 -070058
59 protected:
Darin Petkova7b89492011-07-27 12:48:17 -070060 class TestProxyFactory : public ProxyFactory {
61 public:
Paul Stewart7355ce12011-09-02 10:47:01 -070062 explicit TestProxyFactory(DHCPConfigTest *test) : test_(test) {}
Darin Petkova7b89492011-07-27 12:48:17 -070063
mukesh agrawal1830fa12011-09-26 14:31:40 -070064 virtual DHCPProxyInterface *CreateDHCPProxy(const string &/*service*/) {
Darin Petkova7b89492011-07-27 12:48:17 -070065 return test_->proxy_.release();
66 }
67
68 private:
69 DHCPConfigTest *test_;
70 };
71
Darin Petkova7b89492011-07-27 12:48:17 -070072 scoped_ptr<MockDHCPProxy> proxy_;
73 TestProxyFactory proxy_factory_;
Chris Masone19e30402011-07-19 15:48:47 -070074 MockControl control_;
Darin Petkovf7897bc2011-06-08 17:13:36 -070075 DHCPConfigRefPtr config_;
Darin Petkove7cb7f82011-06-03 13:21:51 -070076};
77
78TEST_F(DHCPConfigTest, GetIPv4AddressString) {
Darin Petkovf7897bc2011-06-08 17:13:36 -070079 EXPECT_EQ("255.255.255.255", config_->GetIPv4AddressString(0xffffffff));
80 EXPECT_EQ("0.0.0.0", config_->GetIPv4AddressString(0));
81 EXPECT_EQ("1.2.3.4", config_->GetIPv4AddressString(0x04030201));
Darin Petkove7cb7f82011-06-03 13:21:51 -070082}
83
Darin Petkova7b89492011-07-27 12:48:17 -070084TEST_F(DHCPConfigTest, InitProxy) {
85 static const char kService[] = ":1.200";
Darin Petkova7b89492011-07-27 12:48:17 -070086 EXPECT_TRUE(proxy_.get());
87 EXPECT_FALSE(config_->proxy_.get());
Eric Shienbrood9a245532012-03-07 14:20:39 -050088 config_->InitProxy(kService);
Darin Petkova7b89492011-07-27 12:48:17 -070089 EXPECT_FALSE(proxy_.get());
90 EXPECT_TRUE(config_->proxy_.get());
91
92 config_->InitProxy(kService);
Darin Petkova7b89492011-07-27 12:48:17 -070093}
94
Darin Petkove7cb7f82011-06-03 13:21:51 -070095TEST_F(DHCPConfigTest, ParseConfiguration) {
96 DHCPConfig::Configuration conf;
97 conf[DHCPConfig::kConfigurationKeyIPAddress].writer().append_uint32(
98 0x01020304);
99 conf[DHCPConfig::kConfigurationKeySubnetCIDR].writer().append_byte(
100 16);
101 conf[DHCPConfig::kConfigurationKeyBroadcastAddress].writer().append_uint32(
102 0x10203040);
103 {
Darin Petkove7cb7f82011-06-03 13:21:51 -0700104 vector<unsigned int> routers;
105 routers.push_back(0x02040608);
106 routers.push_back(0x03050709);
Darin Petkovf7897bc2011-06-08 17:13:36 -0700107 DBus::MessageIter writer =
108 conf[DHCPConfig::kConfigurationKeyRouters].writer();
Darin Petkove7cb7f82011-06-03 13:21:51 -0700109 writer << routers;
Darin Petkove7cb7f82011-06-03 13:21:51 -0700110 }
111 {
Darin Petkove7cb7f82011-06-03 13:21:51 -0700112 vector<unsigned int> dns;
113 dns.push_back(0x09070503);
114 dns.push_back(0x08060402);
Darin Petkovf7897bc2011-06-08 17:13:36 -0700115 DBus::MessageIter writer = conf[DHCPConfig::kConfigurationKeyDNS].writer();
Darin Petkove7cb7f82011-06-03 13:21:51 -0700116 writer << dns;
Darin Petkove7cb7f82011-06-03 13:21:51 -0700117 }
118 conf[DHCPConfig::kConfigurationKeyDomainName].writer().append_string(
119 "domain-name");
120 {
Darin Petkove7cb7f82011-06-03 13:21:51 -0700121 vector<string> search;
122 search.push_back("foo.com");
123 search.push_back("bar.com");
Darin Petkovf7897bc2011-06-08 17:13:36 -0700124 DBus::MessageIter writer =
125 conf[DHCPConfig::kConfigurationKeyDomainSearch].writer();
Darin Petkove7cb7f82011-06-03 13:21:51 -0700126 writer << search;
Darin Petkove7cb7f82011-06-03 13:21:51 -0700127 }
128 conf[DHCPConfig::kConfigurationKeyMTU].writer().append_uint16(600);
129 conf["UnknownKey"] = DBus::Variant();
130
Darin Petkove7cb7f82011-06-03 13:21:51 -0700131 IPConfig::Properties properties;
Darin Petkovf7897bc2011-06-08 17:13:36 -0700132 ASSERT_TRUE(config_->ParseConfiguration(conf, &properties));
Darin Petkove7cb7f82011-06-03 13:21:51 -0700133 EXPECT_EQ("4.3.2.1", properties.address);
Paul Stewart48100b02012-03-19 07:53:52 -0700134 EXPECT_EQ(16, properties.subnet_prefix);
Darin Petkove7cb7f82011-06-03 13:21:51 -0700135 EXPECT_EQ("64.48.32.16", properties.broadcast_address);
136 EXPECT_EQ("8.6.4.2", properties.gateway);
137 ASSERT_EQ(2, properties.dns_servers.size());
138 EXPECT_EQ("3.5.7.9", properties.dns_servers[0]);
139 EXPECT_EQ("2.4.6.8", properties.dns_servers[1]);
140 EXPECT_EQ("domain-name", properties.domain_name);
141 ASSERT_EQ(2, properties.domain_search.size());
142 EXPECT_EQ("foo.com", properties.domain_search[0]);
143 EXPECT_EQ("bar.com", properties.domain_search[1]);
144 EXPECT_EQ(600, properties.mtu);
145}
146
Darin Petkov92c43902011-06-09 20:46:06 -0700147TEST_F(DHCPConfigTest, StartFail) {
Chris Masone2176a882011-09-14 22:29:15 -0700148 EXPECT_CALL(*glib(), SpawnAsync(_, _, _, _, _, _, _, _))
Darin Petkovf7897bc2011-06-08 17:13:36 -0700149 .WillOnce(Return(false));
Chris Masone2176a882011-09-14 22:29:15 -0700150 EXPECT_CALL(*glib(), ChildWatchAdd(_, _, _)).Times(0);
Darin Petkovf7897bc2011-06-08 17:13:36 -0700151 EXPECT_FALSE(config_->Start());
152 EXPECT_EQ(0, config_->pid_);
Darin Petkov92c43902011-06-09 20:46:06 -0700153}
Darin Petkovf7897bc2011-06-08 17:13:36 -0700154
Paul Stewartd32f4842012-01-11 16:08:13 -0800155MATCHER_P(IsDHCPCDArgs, has_hostname, "") {
156 if (string(arg[0]) != "/sbin/dhcpcd" ||
157 string(arg[1]) != "-B" ||
158 string(arg[2]) != kDeviceName) {
159 return false;
160 }
161
162 if (has_hostname) {
163 if (string(arg[3]) != "-h" ||
164 string(arg[4]) != kHostName ||
165 arg[5] != NULL) {
166 return false;
167 }
168 } else {
169 if (arg[3] != NULL) {
170 return false;
171 }
172 }
173
174 return true;
175}
176
177TEST_F(DHCPConfigTest, StartWithHostname) {
178 EXPECT_CALL(*glib(), SpawnAsync(_, IsDHCPCDArgs(true), _, _, _, _, _, _))
179 .WillOnce(Return(false));
180 EXPECT_FALSE(config_->Start());
181}
182
183TEST_F(DHCPConfigTest, StartWithoutHostname) {
184 DHCPConfigRefPtr config(new DHCPConfig(&control_,
185 dispatcher(),
186 DHCPProvider::GetInstance(),
187 kDeviceName,
188 "",
189 glib()));
190
191 EXPECT_CALL(*glib(), SpawnAsync(_, IsDHCPCDArgs(false), _, _, _, _, _, _))
192 .WillOnce(Return(false));
193 EXPECT_FALSE(config->Start());
194}
195
Darin Petkovf9b0ca82011-06-20 12:10:23 -0700196namespace {
197
198class UpdateCallbackTest {
199 public:
200 UpdateCallbackTest(const string &message,
Chris Masone2b105542011-06-22 10:58:09 -0700201 const IPConfigRefPtr &ipconfig,
Darin Petkovf9b0ca82011-06-20 12:10:23 -0700202 bool success)
203 : message_(message),
204 ipconfig_(ipconfig),
205 success_(success),
206 called_(false) {}
207
Chris Masone2b105542011-06-22 10:58:09 -0700208 void Callback(const IPConfigRefPtr &ipconfig, bool success) {
Darin Petkovf9b0ca82011-06-20 12:10:23 -0700209 called_ = true;
210 EXPECT_EQ(ipconfig_.get(), ipconfig.get()) << message_;
211 EXPECT_EQ(success_, success) << message_;
212 }
213
214 bool called() const { return called_; }
215
216 private:
217 const string message_;
218 IPConfigRefPtr ipconfig_;
219 bool success_;
220 bool called_;
221};
222
223} // namespace {}
224
225TEST_F(DHCPConfigTest, ProcessEventSignalFail) {
226 DHCPConfig::Configuration conf;
227 conf[DHCPConfig::kConfigurationKeyIPAddress].writer().append_uint32(
228 0x01020304);
229 UpdateCallbackTest callback_test(DHCPConfig::kReasonFail, config_, false);
230 config_->RegisterUpdateCallback(
Eric Shienbrood3e20a232012-02-16 11:35:56 -0500231 Bind(&UpdateCallbackTest::Callback, Unretained(&callback_test)));
Darin Petkovf9b0ca82011-06-20 12:10:23 -0700232 config_->ProcessEventSignal(DHCPConfig::kReasonFail, conf);
233 EXPECT_TRUE(callback_test.called());
234 EXPECT_TRUE(config_->properties().address.empty());
235}
236
237TEST_F(DHCPConfigTest, ProcessEventSignalSuccess) {
238 static const char * const kReasons[] = {
239 DHCPConfig::kReasonBound,
240 DHCPConfig::kReasonRebind,
241 DHCPConfig::kReasonReboot,
242 DHCPConfig::kReasonRenew
243 };
244 for (size_t r = 0; r < arraysize(kReasons); r++) {
245 DHCPConfig::Configuration conf;
246 string message = string(kReasons[r]) + " failed";
247 conf[DHCPConfig::kConfigurationKeyIPAddress].writer().append_uint32(r);
248 UpdateCallbackTest callback_test(message, config_, true);
249 config_->RegisterUpdateCallback(
Eric Shienbrood3e20a232012-02-16 11:35:56 -0500250 Bind(&UpdateCallbackTest::Callback, Unretained(&callback_test)));
Darin Petkovf9b0ca82011-06-20 12:10:23 -0700251 config_->ProcessEventSignal(kReasons[r], conf);
252 EXPECT_TRUE(callback_test.called()) << message;
Paul Stewart83224402011-11-30 14:52:30 -0800253 EXPECT_EQ(base::StringPrintf("%zu.0.0.0", r), config_->properties().address)
Darin Petkovf9b0ca82011-06-20 12:10:23 -0700254 << message;
255 }
256}
257
258TEST_F(DHCPConfigTest, ProcessEventSignalUnknown) {
259 DHCPConfig::Configuration conf;
260 conf[DHCPConfig::kConfigurationKeyIPAddress].writer().append_uint32(
261 0x01020304);
262 static const char kReasonUnknown[] = "UNKNOWN_REASON";
263 UpdateCallbackTest callback_test(kReasonUnknown, config_, false);
264 config_->RegisterUpdateCallback(
Eric Shienbrood3e20a232012-02-16 11:35:56 -0500265 Bind(&UpdateCallbackTest::Callback, Unretained(&callback_test)));
Darin Petkovf9b0ca82011-06-20 12:10:23 -0700266 config_->ProcessEventSignal(kReasonUnknown, conf);
267 EXPECT_FALSE(callback_test.called());
268 EXPECT_TRUE(config_->properties().address.empty());
269}
270
271
Darin Petkov98dd6a02011-06-10 15:12:57 -0700272TEST_F(DHCPConfigTest, ReleaseIP) {
273 config_->pid_ = 1 << 18; // Ensure unknown positive PID.
Darin Petkovaceede32011-07-18 15:32:38 -0700274 EXPECT_CALL(*proxy_, Release(kDeviceName)).Times(1);
Darin Petkova7b89492011-07-27 12:48:17 -0700275 config_->proxy_.reset(proxy_.release());
Darin Petkov98dd6a02011-06-10 15:12:57 -0700276 EXPECT_TRUE(config_->ReleaseIP());
277 config_->pid_ = 0;
278}
279
280TEST_F(DHCPConfigTest, RenewIP) {
281 config_->pid_ = 456;
Darin Petkovaceede32011-07-18 15:32:38 -0700282 EXPECT_CALL(*proxy_, Rebind(kDeviceName)).Times(1);
Darin Petkova7b89492011-07-27 12:48:17 -0700283 config_->proxy_.reset(proxy_.release());
Darin Petkov98dd6a02011-06-10 15:12:57 -0700284 EXPECT_TRUE(config_->RenewIP());
285 config_->pid_ = 0;
286}
287
288TEST_F(DHCPConfigTest, RequestIP) {
289 config_->pid_ = 567;
Darin Petkovaceede32011-07-18 15:32:38 -0700290 EXPECT_CALL(*proxy_, Rebind(kDeviceName)).Times(1);
Darin Petkova7b89492011-07-27 12:48:17 -0700291 config_->proxy_.reset(proxy_.release());
Darin Petkov98dd6a02011-06-10 15:12:57 -0700292 EXPECT_TRUE(config_->RenewIP());
293 config_->pid_ = 0;
294}
295
296TEST_F(DHCPConfigTest, Restart) {
297 const int kPID1 = 1 << 17; // Ensure unknown positive PID.
298 const int kPID2 = 987;
299 const unsigned int kTag1 = 11;
300 const unsigned int kTag2 = 22;
301 config_->pid_ = kPID1;
302 config_->child_watch_tag_ = kTag1;
303 DHCPProvider::GetInstance()->BindPID(kPID1, config_);
Chris Masone2176a882011-09-14 22:29:15 -0700304 EXPECT_CALL(*glib(), SourceRemove(kTag1)).WillOnce(Return(true));
305 EXPECT_CALL(*glib(), SpawnClosePID(kPID1)).Times(1);
306 EXPECT_CALL(*glib(), SpawnAsync(_, _, _, _, _, _, _, _))
Darin Petkov98dd6a02011-06-10 15:12:57 -0700307 .WillOnce(DoAll(SetArgumentPointee<6>(kPID2), Return(true)));
Chris Masone2176a882011-09-14 22:29:15 -0700308 EXPECT_CALL(*glib(), ChildWatchAdd(kPID2, _, _)).WillOnce(Return(kTag2));
Darin Petkov98dd6a02011-06-10 15:12:57 -0700309 EXPECT_TRUE(config_->Restart());
310 EXPECT_EQ(kPID2, config_->pid_);
311 EXPECT_EQ(config_.get(), DHCPProvider::GetInstance()->GetConfig(kPID2).get());
312 EXPECT_EQ(kTag2, config_->child_watch_tag_);
313 DHCPProvider::GetInstance()->UnbindPID(kPID2);
314 config_->pid_ = 0;
315 config_->child_watch_tag_ = 0;
316}
317
318TEST_F(DHCPConfigTest, RestartNoClient) {
319 const int kPID = 777;
320 const unsigned int kTag = 66;
Chris Masone2176a882011-09-14 22:29:15 -0700321 EXPECT_CALL(*glib(), SourceRemove(_)).Times(0);
322 EXPECT_CALL(*glib(), SpawnClosePID(_)).Times(0);
323 EXPECT_CALL(*glib(), SpawnAsync(_, _, _, _, _, _, _, _))
Darin Petkov98dd6a02011-06-10 15:12:57 -0700324 .WillOnce(DoAll(SetArgumentPointee<6>(kPID), Return(true)));
Chris Masone2176a882011-09-14 22:29:15 -0700325 EXPECT_CALL(*glib(), ChildWatchAdd(kPID, _, _)).WillOnce(Return(kTag));
Darin Petkov98dd6a02011-06-10 15:12:57 -0700326 EXPECT_TRUE(config_->Restart());
327 EXPECT_EQ(kPID, config_->pid_);
328 EXPECT_EQ(config_.get(), DHCPProvider::GetInstance()->GetConfig(kPID).get());
329 EXPECT_EQ(kTag, config_->child_watch_tag_);
330 DHCPProvider::GetInstance()->UnbindPID(kPID);
331 config_->pid_ = 0;
332 config_->child_watch_tag_ = 0;
333}
334
Darin Petkov92c43902011-06-09 20:46:06 -0700335TEST_F(DHCPConfigTest, StartSuccess) {
336 const int kPID = 123456;
337 const unsigned int kTag = 55;
Chris Masone2176a882011-09-14 22:29:15 -0700338 EXPECT_CALL(*glib(), SpawnAsync(_, _, _, _, _, _, _, _))
Darin Petkovf7897bc2011-06-08 17:13:36 -0700339 .WillOnce(DoAll(SetArgumentPointee<6>(kPID), Return(true)));
Chris Masone2176a882011-09-14 22:29:15 -0700340 EXPECT_CALL(*glib(), ChildWatchAdd(kPID, _, _)).WillOnce(Return(kTag));
Darin Petkovf7897bc2011-06-08 17:13:36 -0700341 EXPECT_TRUE(config_->Start());
342 EXPECT_EQ(kPID, config_->pid_);
Darin Petkov98dd6a02011-06-10 15:12:57 -0700343 EXPECT_EQ(config_.get(), DHCPProvider::GetInstance()->GetConfig(kPID).get());
344 EXPECT_EQ(kTag, config_->child_watch_tag_);
Darin Petkov92c43902011-06-09 20:46:06 -0700345
346 ScopedTempDir temp_dir;
347 config_->root_ = temp_dir.path();
348 FilePath varrun = temp_dir.path().Append("var/run");
349 EXPECT_TRUE(file_util::CreateDirectory(varrun));
350 FilePath pid_file =
351 varrun.Append(base::StringPrintf("dhcpcd-%s.pid", kDeviceName));
352 FilePath lease_file =
353 varrun.Append(base::StringPrintf("dhcpcd-%s.lease", kDeviceName));
354 EXPECT_EQ(0, file_util::WriteFile(pid_file, "", 0));
355 EXPECT_EQ(0, file_util::WriteFile(lease_file, "", 0));
356 ASSERT_TRUE(file_util::PathExists(pid_file));
357 ASSERT_TRUE(file_util::PathExists(lease_file));
358
Chris Masone2176a882011-09-14 22:29:15 -0700359 EXPECT_CALL(*glib(), SpawnClosePID(kPID)).Times(1);
Darin Petkov92c43902011-06-09 20:46:06 -0700360 DHCPConfig::ChildWatchCallback(kPID, 0, config_.get());
Darin Petkov98dd6a02011-06-10 15:12:57 -0700361 EXPECT_EQ(NULL, DHCPProvider::GetInstance()->GetConfig(kPID).get());
Darin Petkov92c43902011-06-09 20:46:06 -0700362 EXPECT_FALSE(file_util::PathExists(pid_file));
363 EXPECT_FALSE(file_util::PathExists(lease_file));
Darin Petkovf7897bc2011-06-08 17:13:36 -0700364}
365
Darin Petkov98dd6a02011-06-10 15:12:57 -0700366TEST_F(DHCPConfigTest, Stop) {
367 // Ensure no crashes.
368 const int kPID = 1 << 17; // Ensure unknown positive PID.
369 config_->Stop();
370 config_->pid_ = kPID;
371 config_->Stop();
Chris Masone2176a882011-09-14 22:29:15 -0700372 EXPECT_CALL(*glib(), SpawnClosePID(kPID)).Times(1); // Invoked by destructor.
Darin Petkov98dd6a02011-06-10 15:12:57 -0700373}
374
mukesh agrawal6bb9e7c2012-01-30 14:57:54 -0800375TEST_F(DHCPConfigTest, SetProperty) {
Chris Masone43b48a12011-07-01 13:37:07 -0700376 ::DBus::Error error;
377 // Ensure that an attempt to write a R/O property returns InvalidArgs error.
mukesh agrawal6bb9e7c2012-01-30 14:57:54 -0800378 EXPECT_FALSE(DBusAdaptor::SetProperty(config_->mutable_store(),
379 flimflam::kAddressProperty,
380 PropertyStoreTest::kStringV,
381 &error));
Chris Masone9d779932011-08-25 16:33:41 -0700382 EXPECT_EQ(invalid_args(), error.name());
Chris Masone43b48a12011-07-01 13:37:07 -0700383}
384
Darin Petkove7cb7f82011-06-03 13:21:51 -0700385} // namespace shill