[yast-commit] r58012 - in /branches/tmp/mvidner/core-dbus-values: dbus/namespace_service/testsuite/t4-bad-params.py liby2dbus/src/DBusMsg.cc
Author: mvidner Date: Fri Jul 10 13:56:35 2009 New Revision: 58012 URL: http://svn.opensuse.org/viewcvs/yast?rev=58012&view=rev Log: Report errors for malformed BSVs. Modified: branches/tmp/mvidner/core-dbus-values/dbus/namespace_service/testsuite/t4-bad-params.py branches/tmp/mvidner/core-dbus-values/liby2dbus/src/DBusMsg.cc Modified: branches/tmp/mvidner/core-dbus-values/dbus/namespace_service/testsuite/t4-bad-params.py URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/mvidner/core-dbus-values/dbus/namespace_service/testsuite/t4-bad-params.py?rev=58012&r1=58011&r2=58012&view=diff ============================================================================== --- branches/tmp/mvidner/core-dbus-values/dbus/namespace_service/testsuite/t4-bad-params.py (original) +++ branches/tmp/mvidner/core-dbus-values/dbus/namespace_service/testsuite/t4-bad-params.py Fri Jul 10 13:56:35 2009 @@ -46,6 +46,24 @@ def testBsvTypeMismatch(self): self.assertRaises(Exception, self.YT.ParamMap, (False, "string", 42)) + def testBsvBadNilFlag(self): + badBsv = (42,) # (42) is a plain number + # wrap it otherwise the method sig would refuse it + self.assertRaisesDBus("InvalidArgs", + self.YT.ParamAny, (False, "list", [badBsv])) + + def testBsvBadTypeField(self): + badBsv = (False, 42, 42) + # wrap it otherwise the method sig would refuse it + self.assertRaisesDBus("InvalidArgs", + self.YT.ParamAny, (False, "list", [badBsv])) + + def testBsvBadPayload(self): + badBsv = (False, "", "Not A Variant") + # wrap it otherwise the method sig would refuse it + self.assertRaisesDBus("InvalidArgs", + self.YT.ParamAny, (False, "list", [badBsv])) + def testUnhandledDBusType(self): struct = ("a", "struct") # actually we could convert structs to ycp lists (or terms) Modified: branches/tmp/mvidner/core-dbus-values/liby2dbus/src/DBusMsg.cc URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/mvidner/core-dbus-values/liby2dbus/src/DBusMsg.cc?rev=58012&r1=58011&r2=58012&view=diff ============================================================================== --- branches/tmp/mvidner/core-dbus-values/liby2dbus/src/DBusMsg.cc (original) +++ branches/tmp/mvidner/core-dbus-values/liby2dbus/src/DBusMsg.cc Fri Jul 10 13:56:35 2009 @@ -1097,10 +1097,8 @@ } else { - // FIXME "response" is wrong, can go both ways. - // for params, should throw param dbus error - y2error("Missing nil flag in the response"); - return YCPVoid(); + string e = form("1st field in BSV must be a boolean nil flag (seen '%c')", (char) type); + throw DBusException(DBUS_ERROR_INVALID_ARGS, e); } // read the data type in the header @@ -1129,14 +1127,13 @@ vycptype = Type::Block; else { string e = form("Dunno how to translate BSV type '%s' to YCP type", str); - y2error("%s", e.c_str()); throw DBusException(DBUS_ERROR_INVALID_SIGNATURE, e); } } else { - y2error("Missing datatype flag in the response"); - return YCPVoid(); + string e = form("2nd field in BSV must be a string YCP type name (seen %d, '%c')", type, (char) type); + throw DBusException(DBUS_ERROR_INVALID_ARGS, e); } // read the YCP value in the variant container @@ -1146,8 +1143,8 @@ if (type != DBUS_TYPE_VARIANT) { - y2error("Expecting VARIANT type in the response"); - return YCPVoid(); + string e = form("3rd field in BSV must be a variant payload (seen %d, '%c')", type, (char) type); + throw DBusException(DBUS_ERROR_INVALID_ARGS, e); } DBusMessageIter variant_iter; -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
mvidner@svn.opensuse.org