shill: Make EapPassword and EapPrivateKeyPassword write-only
In the same vein as the Passphrase property in WiFiService,
make these properties unavailable for read-back.
BUG=chromium-os:25690
TEST=New unit test
Change-Id: Ic2e61c0110d593d22c447206a35a0e9982e46aae
Reviewed-on: https://gerrit.chromium.org/gerrit/15078
Commit-Ready: Paul Stewart <pstew@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
Tested-by: Paul Stewart <pstew@chromium.org>
diff --git a/service_unittest.cc b/service_unittest.cc
index 8f2daab..24cd06c 100644
--- a/service_unittest.cc
+++ b/service_unittest.cc
@@ -35,6 +35,7 @@
using testing::StrictMock;
using testing::SetArgumentPointee;
using testing::Test;
+using testing::Values;
namespace shill {
@@ -330,4 +331,25 @@
EXPECT_FALSE(service_->IsAutoConnectable());
}
+// Make sure a property is registered as a write only property
+// by reading and comparing all string properties returned on the store.
+// Subtle: We need to convert the test argument back and forth between
+// string and ::DBus::Variant because this is the parameter type that
+// our supeclass (PropertyStoreTest) is declared with.
+class ReadOnlyServicePropertyTest : public ServiceTest {};
+TEST_P(ReadOnlyServicePropertyTest, PropertyWriteOnly) {
+ ReadablePropertyConstIterator<string> it =
+ (service_->store()).GetStringPropertiesIter();
+ string property(GetParam().reader().get_string());
+ for( ; !it.AtEnd(); it.Advance())
+ EXPECT_NE(it.Key(), property);
+}
+
+INSTANTIATE_TEST_CASE_P(
+ ReadOnlyServicePropertyTestInstance,
+ ReadOnlyServicePropertyTest,
+ Values(
+ DBusAdaptor::StringToVariant(flimflam::kEapPrivateKeyPasswordProperty),
+ DBusAdaptor::StringToVariant(flimflam::kEapPasswordProperty)));
+
} // namespace shill