|
|
8a3219 |
From 99ecd06f1f6028bcf9bd7d4ece7f3ce8df39077b Mon Sep 17 00:00:00 2001
|
|
|
8a3219 |
From: Eric Garver <eric@garver.life>
|
|
|
8a3219 |
Date: Tue, 25 Jun 2019 18:19:08 -0400
|
|
|
8a3219 |
Subject: [PATCH 17/20] test: dbus: coverage for new service APIs
|
|
|
8a3219 |
|
|
|
8a3219 |
(cherry picked from commit 335f238481401e97f3a9bc6773295fe34c89962c)
|
|
|
8a3219 |
---
|
|
|
8a3219 |
src/tests/dbus/service.at | 165 +++++++++++++++++++++++++++++++++++++-
|
|
|
8a3219 |
1 file changed, 164 insertions(+), 1 deletion(-)
|
|
|
8a3219 |
|
|
|
8a3219 |
diff --git a/src/tests/dbus/service.at b/src/tests/dbus/service.at
|
|
|
8a3219 |
index 579548d66509..8ad9334aaa56 100644
|
|
|
8a3219 |
--- a/src/tests/dbus/service.at
|
|
|
8a3219 |
+++ b/src/tests/dbus/service.at
|
|
|
8a3219 |
@@ -287,4 +287,167 @@ DBUS_CHECK([], [getServiceSettings], ["foobar"], 0, [dnl
|
|
|
8a3219 |
[(('1.1', 'foobar new', 'foobar new service is for foobar', [('12345', 'udp'), ('2222', 'tcp')], ['ftp'], @a{ss} {}, ['icmp'], [('4321', 'tcp')]),)]
|
|
|
8a3219 |
])
|
|
|
8a3219 |
|
|
|
8a3219 |
-FWD_END_TEST
|
|
|
8a3219 |
+
|
|
|
8a3219 |
+dnl ===============
|
|
|
8a3219 |
+dnl New APIs tests
|
|
|
8a3219 |
+dnl ===============
|
|
|
8a3219 |
+
|
|
|
8a3219 |
+dnl modify service with new API that was created with old API
|
|
|
8a3219 |
+dnl Verify old APIs also reflect the change.
|
|
|
8a3219 |
+DBUS_CHECK([config], [config.addService],
|
|
|
8a3219 |
+ ["foobar-old" dnl name
|
|
|
8a3219 |
+ '("1.0", dnl version
|
|
|
8a3219 |
+ "foobar-old", dnl short
|
|
|
8a3219 |
+ "foobar-old service is for foobar-old", dnl description
|
|
|
8a3219 |
+ @<:@("1234", "udp"), ("22", "tcp"), ("1234", "udp")@:>@, dnl ports, deliberate duplicate
|
|
|
8a3219 |
+ @<:@"ftp"@:>@, dnl modules
|
|
|
8a3219 |
+ {}, dnl destination
|
|
|
8a3219 |
+ @<:@@:>@, dnl protocols
|
|
|
8a3219 |
+ @<:@("4321", "tcp"), ("4321", "udp")@:>@ dnl source ports
|
|
|
8a3219 |
+ )'dnl
|
|
|
8a3219 |
+ ], 0, [stdout])
|
|
|
8a3219 |
+SERVICE_OBJ=[$(sed -e "s/.*config\/service\/\([^']\+\)['].*/\1/" ./stdout)]
|
|
|
8a3219 |
+export SERVICE_OBJ
|
|
|
8a3219 |
+DBUS_CHECK([config/service/${SERVICE_OBJ}], [config.service.update2],
|
|
|
8a3219 |
+ ['{"version": <"1.1">,
|
|
|
8a3219 |
+ "includes": <@<:@"https"@:>@>,
|
|
|
8a3219 |
+ "protocols": <@<:@"icmp"@:>@>
|
|
|
8a3219 |
+ }'dnl
|
|
|
8a3219 |
+ ], 0, [ignore])
|
|
|
8a3219 |
+
|
|
|
8a3219 |
+DBUS_CHECK([config/service/${SERVICE_OBJ}], [config.service.getSettings], [], 0, [dnl
|
|
|
8a3219 |
+ [(('1.1', 'foobar-old', 'foobar-old service is for foobar-old', [('1234', 'udp'), ('22', 'tcp')], ['ftp'], @a{ss} {}, ['icmp'], [('4321', 'tcp'), ('4321', 'udp')]),)]
|
|
|
8a3219 |
+])
|
|
|
8a3219 |
+DBUS_CHECK([config/service/${SERVICE_OBJ}], [config.service.getSettings2], [], 0, [dnl
|
|
|
8a3219 |
+ ['description': <'foobar-old service is for foobar-old'>
|
|
|
8a3219 |
+ 'includes': <['https']>
|
|
|
8a3219 |
+ 'modules': <['ftp']>
|
|
|
8a3219 |
+ 'ports': <[('1234', 'udp'), ('22', 'tcp')]>
|
|
|
8a3219 |
+ 'protocols': <['icmp']>
|
|
|
8a3219 |
+ 'short': <'foobar-old'>
|
|
|
8a3219 |
+ 'source_ports': <[('4321', 'tcp'), ('4321', 'udp')]>
|
|
|
8a3219 |
+ 'version': <'1.1'>]
|
|
|
8a3219 |
+])
|
|
|
8a3219 |
+
|
|
|
8a3219 |
+FWD_RELOAD
|
|
|
8a3219 |
+DBUS_CHECK([], [getServiceSettings], ["foobar-old"], 0, [dnl
|
|
|
8a3219 |
+ [(('1.1', 'foobar-old', 'foobar-old service is for foobar-old', [('1234', 'udp'), ('22', 'tcp')], ['ftp'], @a{ss} {}, ['icmp'], [('4321', 'tcp'), ('4321', 'udp')]),)]
|
|
|
8a3219 |
+])
|
|
|
8a3219 |
+DBUS_CHECK([], [getServiceSettings2], ["foobar-old"], 0, [dnl
|
|
|
8a3219 |
+ ['description': <'foobar-old service is for foobar-old'>
|
|
|
8a3219 |
+ 'includes': <['https']>
|
|
|
8a3219 |
+ 'modules': <['ftp']>
|
|
|
8a3219 |
+ 'ports': <[('1234', 'udp'), ('22', 'tcp')]>
|
|
|
8a3219 |
+ 'protocols': <['icmp']>
|
|
|
8a3219 |
+ 'short': <'foobar-old'>
|
|
|
8a3219 |
+ 'source_ports': <[('4321', 'tcp'), ('4321', 'udp')]>
|
|
|
8a3219 |
+ 'version': <'1.1'>]
|
|
|
8a3219 |
+])
|
|
|
8a3219 |
+
|
|
|
8a3219 |
+dnl add service with new API
|
|
|
8a3219 |
+DBUS_INTROSPECT([config], [[//method[@name="addService2"]]], 0, [dnl
|
|
|
8a3219 |
+ <method name="addService2">
|
|
|
8a3219 |
+ <arg direction="in" name="service" type="s"/>
|
|
|
8a3219 |
+ <arg direction="in" name="settings" type="a{sv}"/>
|
|
|
8a3219 |
+ <arg direction="out" type="o"/>
|
|
|
8a3219 |
+ </method>
|
|
|
8a3219 |
+])
|
|
|
8a3219 |
+DBUS_CHECK([config], [config.addService2],
|
|
|
8a3219 |
+ ["foobar-dict" dnl name
|
|
|
8a3219 |
+ '{"version": <"1.0">,
|
|
|
8a3219 |
+ "short": <"foobar-dict">,
|
|
|
8a3219 |
+ "description": <"foobar-dict service is for foobar-dict">,
|
|
|
8a3219 |
+ "ports": <@<:@("1234", "udp"), ("22", "tcp"), ("1234", "udp")@:>@>,
|
|
|
8a3219 |
+ "modules": <@<:@"ftp"@:>@>,
|
|
|
8a3219 |
+ "destination": <{"ipv6": "1234::4321"}>,
|
|
|
8a3219 |
+ "protocols": <@<:@"icmp", "igmp"@:>@>,
|
|
|
8a3219 |
+ "source_ports": <@<:@("4321", "tcp"), ("4321", "udp")@:>@>,
|
|
|
8a3219 |
+ "includes": <@<:@"https", "samba"@:>@>
|
|
|
8a3219 |
+ }'dnl
|
|
|
8a3219 |
+ ], 0, [stdout])
|
|
|
8a3219 |
+SERVICE_OBJ=[$(sed -e "s/.*config\/service\/\([^']\+\)['].*/\1/" ./stdout)]
|
|
|
8a3219 |
+export SERVICE_OBJ
|
|
|
8a3219 |
+
|
|
|
8a3219 |
+DBUS_INTROSPECT([config/service/${SERVICE_OBJ}], [[//method[@name="getSettings2"]]], 0, [dnl
|
|
|
8a3219 |
+ <method name="getSettings2">
|
|
|
8a3219 |
+ <arg direction="out" type="a{sv}"/>
|
|
|
8a3219 |
+ </method>
|
|
|
8a3219 |
+])
|
|
|
8a3219 |
+DBUS_CHECK([config/service/${SERVICE_OBJ}], [config.service.getSettings2], [], 0, [dnl
|
|
|
8a3219 |
+ ['description': <'foobar-dict service is for foobar-dict'>
|
|
|
8a3219 |
+ 'destination': <{'ipv6': '1234::4321'}>
|
|
|
8a3219 |
+ 'includes': <['https', 'samba']>
|
|
|
8a3219 |
+ 'modules': <['ftp']>
|
|
|
8a3219 |
+ 'ports': <[('1234', 'udp'), ('22', 'tcp')]>
|
|
|
8a3219 |
+ 'protocols': <['icmp', 'igmp']>
|
|
|
8a3219 |
+ 'short': <'foobar-dict'>
|
|
|
8a3219 |
+ 'source_ports': <[('4321', 'tcp'), ('4321', 'udp')]>
|
|
|
8a3219 |
+ 'version': <'1.0'>]
|
|
|
8a3219 |
+])
|
|
|
8a3219 |
+
|
|
|
8a3219 |
+dnl New API allows partial updates to service object
|
|
|
8a3219 |
+DBUS_INTROSPECT([config/service/${SERVICE_OBJ}], [[//method[@name="update2"]]], 0, [dnl
|
|
|
8a3219 |
+ <method name="update2">
|
|
|
8a3219 |
+ <arg direction="in" name="settings" type="a{sv}"/>
|
|
|
8a3219 |
+ </method>
|
|
|
8a3219 |
+])
|
|
|
8a3219 |
+DBUS_CHECK([config/service/${SERVICE_OBJ}], [config.service.update2],
|
|
|
8a3219 |
+ ['{"version": <"1.1">,
|
|
|
8a3219 |
+ "includes": <@<:@"https", "samba", "http"@:>@>
|
|
|
8a3219 |
+ }'dnl
|
|
|
8a3219 |
+ ], 0, [ignore])
|
|
|
8a3219 |
+DBUS_CHECK([config/service/${SERVICE_OBJ}], [config.service.getSettings2], [], 0, [dnl
|
|
|
8a3219 |
+ ['description': <'foobar-dict service is for foobar-dict'>
|
|
|
8a3219 |
+ 'destination': <{'ipv6': '1234::4321'}>
|
|
|
8a3219 |
+ 'includes': <['https', 'samba', 'http']>
|
|
|
8a3219 |
+ 'modules': <['ftp']>
|
|
|
8a3219 |
+ 'ports': <[('1234', 'udp'), ('22', 'tcp')]>
|
|
|
8a3219 |
+ 'protocols': <['icmp', 'igmp']>
|
|
|
8a3219 |
+ 'short': <'foobar-dict'>
|
|
|
8a3219 |
+ 'source_ports': <[('4321', 'tcp'), ('4321', 'udp')]>
|
|
|
8a3219 |
+ 'version': <'1.1'>]
|
|
|
8a3219 |
+])
|
|
|
8a3219 |
+
|
|
|
8a3219 |
+dnl To zero a field you have to set it with an empty value
|
|
|
8a3219 |
+DBUS_CHECK([config/service/${SERVICE_OBJ}], [config.service.update2],
|
|
|
8a3219 |
+ ['{"version": <"1.2">,
|
|
|
8a3219 |
+ "includes": <@as @<:@@:>@>
|
|
|
8a3219 |
+ }'dnl
|
|
|
8a3219 |
+ ], 0, [ignore])
|
|
|
8a3219 |
+DBUS_CHECK([config/service/${SERVICE_OBJ}], [config.service.getSettings2], [], 0, [dnl
|
|
|
8a3219 |
+ ['description': <'foobar-dict service is for foobar-dict'>
|
|
|
8a3219 |
+ 'destination': <{'ipv6': '1234::4321'}>
|
|
|
8a3219 |
+ 'modules': <['ftp']>
|
|
|
8a3219 |
+ 'ports': <[('1234', 'udp'), ('22', 'tcp')]>
|
|
|
8a3219 |
+ 'protocols': <['icmp', 'igmp']>
|
|
|
8a3219 |
+ 'short': <'foobar-dict'>
|
|
|
8a3219 |
+ 'source_ports': <[('4321', 'tcp'), ('4321', 'udp')]>
|
|
|
8a3219 |
+ 'version': <'1.2'>]
|
|
|
8a3219 |
+])
|
|
|
8a3219 |
+
|
|
|
8a3219 |
+FWD_RELOAD
|
|
|
8a3219 |
+DBUS_INTROSPECT([], [[//method[@name="getServiceSettings2"]]], 0, [dnl
|
|
|
8a3219 |
+ <method name="getServiceSettings2">
|
|
|
8a3219 |
+ <arg direction="in" name="service" type="s"/>
|
|
|
8a3219 |
+ <arg direction="out" type="a{sv}"/>
|
|
|
8a3219 |
+ </method>
|
|
|
8a3219 |
+])
|
|
|
8a3219 |
+DBUS_CHECK([], [getServiceSettings2], ["foobar-dict"], 0, [dnl
|
|
|
8a3219 |
+ ['description': <'foobar-dict service is for foobar-dict'>
|
|
|
8a3219 |
+ 'destination': <{'ipv6': '1234::4321'}>
|
|
|
8a3219 |
+ 'modules': <['ftp']>
|
|
|
8a3219 |
+ 'ports': <[('1234', 'udp'), ('22', 'tcp')]>
|
|
|
8a3219 |
+ 'protocols': <['icmp', 'igmp']>
|
|
|
8a3219 |
+ 'short': <'foobar-dict'>
|
|
|
8a3219 |
+ 'source_ports': <[('4321', 'tcp'), ('4321', 'udp')]>
|
|
|
8a3219 |
+ 'version': <'1.2'>]
|
|
|
8a3219 |
+])
|
|
|
8a3219 |
+
|
|
|
8a3219 |
+dnl bogus arguments
|
|
|
8a3219 |
+DBUS_CHECK([config/service/${SERVICE_OBJ}], [config.service.update2],
|
|
|
8a3219 |
+ ['{"version": <"1.3">,
|
|
|
8a3219 |
+ "thisdoesnotexist": <"">
|
|
|
8a3219 |
+ }'dnl
|
|
|
8a3219 |
+ ], 1, [ignore], [ignore])
|
|
|
8a3219 |
+
|
|
|
8a3219 |
+FWD_END_TEST([-e '/ERROR: INVALID_OPTION: service option/d'])
|
|
|
8a3219 |
--
|
|
|
8a3219 |
2.20.1
|
|
|
8a3219 |
|