]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
Add more test coverage for config file parsing
authorSimon McVittie <smcv@collabora.com>
Fri, 17 Aug 2018 16:02:45 +0000 (17:02 +0100)
committerSimon McVittie <smcv@collabora.com>
Thu, 30 Aug 2018 16:39:41 +0000 (17:39 +0100)
minimal.conf is a valid config file added to make it obvious why
the new invalid config files are invalid.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=107739

24 files changed:
test/Makefile.am
test/data/invalid-config-files/apparmor-bad-attribute.conf [new file with mode: 0644]
test/data/invalid-config-files/apparmor-bad-mode.conf [new file with mode: 0644]
test/data/invalid-config-files/bad-attribute-2.conf [new file with mode: 0644]
test/data/invalid-config-files/bad-attribute.conf [new file with mode: 0644]
test/data/invalid-config-files/bad-element.conf [new file with mode: 0644]
test/data/invalid-config-files/bad-limit.conf [new file with mode: 0644]
test/data/invalid-config-files/double-attribute.conf [new file with mode: 0644]
test/data/invalid-config-files/limit-no-name.conf [new file with mode: 0644]
test/data/invalid-config-files/ludicrous-limit.conf [new file with mode: 0644]
test/data/invalid-config-files/negative-limit.conf [new file with mode: 0644]
test/data/invalid-config-files/non-numeric-limit.conf [new file with mode: 0644]
test/data/invalid-config-files/policy-bad-at-console.conf [new file with mode: 0644]
test/data/invalid-config-files/policy-bad-attribute.conf [new file with mode: 0644]
test/data/invalid-config-files/policy-bad-context.conf [new file with mode: 0644]
test/data/invalid-config-files/policy-bad-rule-attribute.conf [new file with mode: 0644]
test/data/invalid-config-files/policy-contradiction.conf [new file with mode: 0644]
test/data/invalid-config-files/policy-member-no-path.conf [new file with mode: 0644]
test/data/invalid-config-files/policy-mixed.conf [new file with mode: 0644]
test/data/invalid-config-files/policy-no-attributes.conf [new file with mode: 0644]
test/data/invalid-config-files/policy-no-rule-attribute.conf [new file with mode: 0644]
test/data/invalid-config-files/unknown-limit.conf [new file with mode: 0644]
test/data/valid-config-files-system/many-rules.conf
test/data/valid-config-files/minimal.conf [new file with mode: 0644]

index 2f338913028497fee84cfa2536b1b8e465c69816..f373585c5e843d94fe8386dc60553c92237f648d 100644 (file)
@@ -500,15 +500,36 @@ static_data = \
        data/equiv-config-files/entities/basic.d/basic.conf \
        data/equiv-config-files/entities/entities-1.conf \
        data/equiv-config-files/entities/entities-2.conf \
+       data/invalid-config-files/apparmor-bad-attribute.conf \
+       data/invalid-config-files/apparmor-bad-mode.conf \
+       data/invalid-config-files/bad-attribute.conf \
+       data/invalid-config-files/bad-attribute-2.conf \
+       data/invalid-config-files/bad-element.conf \
+       data/invalid-config-files/bad-limit.conf \
        data/invalid-config-files/badselinux-1.conf \
        data/invalid-config-files/badselinux-2.conf \
        data/invalid-config-files/circular-1.conf \
        data/invalid-config-files/circular-2.conf \
        data/invalid-config-files/circular-3.conf \
+       data/invalid-config-files/double-attribute.conf \
        data/invalid-config-files/impossible-send.conf \
+       data/invalid-config-files/limit-no-name.conf \
+       data/invalid-config-files/ludicrous-limit.conf \
+       data/invalid-config-files/negative-limit.conf \
+       data/invalid-config-files/non-numeric-limit.conf \
        data/invalid-config-files/not-well-formed.conf \
+       data/invalid-config-files/policy-bad-at-console.conf \
+       data/invalid-config-files/policy-bad-attribute.conf \
+       data/invalid-config-files/policy-bad-context.conf \
+       data/invalid-config-files/policy-bad-rule-attribute.conf \
+       data/invalid-config-files/policy-contradiction.conf \
+       data/invalid-config-files/policy-member-no-path.conf \
+       data/invalid-config-files/policy-mixed.conf \
+       data/invalid-config-files/policy-no-attributes.conf \
+       data/invalid-config-files/policy-no-rule-attribute.conf \
        data/invalid-config-files/truncated-file.conf \
        data/invalid-config-files/send-and-receive.conf \
+       data/invalid-config-files/unknown-limit.conf \
        data/invalid-messages/boolean-has-no-value.message-raw \
        data/sha-1/Readme.txt \
        data/sha-1/bit-hashes.sha1 \
@@ -527,6 +548,7 @@ static_data = \
        data/valid-config-files/entities.conf \
        data/valid-config-files/listen-unix-runtime.conf \
        data/valid-config-files/many-rules.conf \
+       data/valid-config-files/minimal.conf \
        data/valid-config-files/standard-session-dirs.conf \
        data/valid-config-files-system/many-rules.conf \
        data/valid-config-files-system/system.d/test.conf \
diff --git a/test/data/invalid-config-files/apparmor-bad-attribute.conf b/test/data/invalid-config-files/apparmor-bad-attribute.conf
new file mode 100644 (file)
index 0000000..16a10e8
--- /dev/null
@@ -0,0 +1,4 @@
+<busconfig>
+  <listen>tcp:port=1234</listen>
+  <apparmor enforcement_style="Judge Dredd"/>
+</busconfig>
diff --git a/test/data/invalid-config-files/apparmor-bad-mode.conf b/test/data/invalid-config-files/apparmor-bad-mode.conf
new file mode 100644 (file)
index 0000000..2398ee5
--- /dev/null
@@ -0,0 +1,4 @@
+<busconfig>
+  <listen>tcp:port=1234</listen>
+  <apparmor mode="plaintive"/>
+</busconfig>
diff --git a/test/data/invalid-config-files/bad-attribute-2.conf b/test/data/invalid-config-files/bad-attribute-2.conf
new file mode 100644 (file)
index 0000000..cc430f5
--- /dev/null
@@ -0,0 +1,3 @@
+<busconfig>
+  <listen carefully="yes">tcp:port=1234</listen>
+</busconfig>
diff --git a/test/data/invalid-config-files/bad-attribute.conf b/test/data/invalid-config-files/bad-attribute.conf
new file mode 100644 (file)
index 0000000..993dd3c
--- /dev/null
@@ -0,0 +1,4 @@
+<busconfig>
+  <listen>tcp:port=1234</listen>
+  <limit wildebeest="gnu">5000</limit>
+</busconfig>
diff --git a/test/data/invalid-config-files/bad-element.conf b/test/data/invalid-config-files/bad-element.conf
new file mode 100644 (file)
index 0000000..77067eb
--- /dev/null
@@ -0,0 +1,4 @@
+<busconfig>
+  <listen>tcp:port=1234</listen>
+  <bees/>
+</busconfig>
diff --git a/test/data/invalid-config-files/bad-limit.conf b/test/data/invalid-config-files/bad-limit.conf
new file mode 100644 (file)
index 0000000..9b7b317
--- /dev/null
@@ -0,0 +1,4 @@
+<busconfig>
+  <listen>tcp:port=1234</listen>
+  <limit name="max_names_per_connection">as many as you like</limit>
+</busconfig>
diff --git a/test/data/invalid-config-files/double-attribute.conf b/test/data/invalid-config-files/double-attribute.conf
new file mode 100644 (file)
index 0000000..514fda4
--- /dev/null
@@ -0,0 +1,4 @@
+<busconfig>
+  <listen>tcp:port=1234</listen>
+  <limit name="max_incoming_bytes" name="max_incoming_bytes">5000</limit>
+</busconfig>
diff --git a/test/data/invalid-config-files/limit-no-name.conf b/test/data/invalid-config-files/limit-no-name.conf
new file mode 100644 (file)
index 0000000..390a4af
--- /dev/null
@@ -0,0 +1,4 @@
+<busconfig>
+  <listen>tcp:port=1234</listen>
+  <limit/>
+</busconfig>
diff --git a/test/data/invalid-config-files/ludicrous-limit.conf b/test/data/invalid-config-files/ludicrous-limit.conf
new file mode 100644 (file)
index 0000000..d78f0b5
--- /dev/null
@@ -0,0 +1,5 @@
+<busconfig>
+  <listen>tcp:port=1234</listen>
+  <!-- Chosen to be out-of-range for int, but not long (on 64-bit) -->
+  <limit name="max_names_per_connection">3123123123</limit>
+</busconfig>
diff --git a/test/data/invalid-config-files/negative-limit.conf b/test/data/invalid-config-files/negative-limit.conf
new file mode 100644 (file)
index 0000000..de10d1a
--- /dev/null
@@ -0,0 +1,4 @@
+<busconfig>
+  <listen>tcp:port=1234</listen>
+  <limit name="max_names_per_connection">-1</limit>
+</busconfig>
diff --git a/test/data/invalid-config-files/non-numeric-limit.conf b/test/data/invalid-config-files/non-numeric-limit.conf
new file mode 100644 (file)
index 0000000..99b4429
--- /dev/null
@@ -0,0 +1,4 @@
+<busconfig>
+  <listen>tcp:port=1234</listen>
+  <limit name="max_names_per_connection">bees</limit>
+</busconfig>
diff --git a/test/data/invalid-config-files/policy-bad-at-console.conf b/test/data/invalid-config-files/policy-bad-at-console.conf
new file mode 100644 (file)
index 0000000..1994cb9
--- /dev/null
@@ -0,0 +1,4 @@
+<busconfig>
+  <listen>tcp:port=1234</listen>
+  <policy at_console="somewhere in the vicinity"/>
+</busconfig>
diff --git a/test/data/invalid-config-files/policy-bad-attribute.conf b/test/data/invalid-config-files/policy-bad-attribute.conf
new file mode 100644 (file)
index 0000000..03baeb0
--- /dev/null
@@ -0,0 +1,4 @@
+<busconfig>
+  <listen>tcp:port=1234</listen>
+  <policy hat="top"/>
+</busconfig>
diff --git a/test/data/invalid-config-files/policy-bad-context.conf b/test/data/invalid-config-files/policy-bad-context.conf
new file mode 100644 (file)
index 0000000..18ac25e
--- /dev/null
@@ -0,0 +1,4 @@
+<busconfig>
+  <listen>tcp:port=1234</listen>
+  <policy context="apropos of nothing"/>
+</busconfig>
diff --git a/test/data/invalid-config-files/policy-bad-rule-attribute.conf b/test/data/invalid-config-files/policy-bad-rule-attribute.conf
new file mode 100644 (file)
index 0000000..b28a7b3
--- /dev/null
@@ -0,0 +1,6 @@
+<busconfig>
+  <listen>tcp:port=1234</listen>
+  <policy context="default">
+    <allow species="stoat"/>
+  </policy>
+</busconfig>
diff --git a/test/data/invalid-config-files/policy-contradiction.conf b/test/data/invalid-config-files/policy-contradiction.conf
new file mode 100644 (file)
index 0000000..88bd73f
--- /dev/null
@@ -0,0 +1,4 @@
+<busconfig>
+  <listen>tcp:port=1234</listen>
+  <policy user="root" at_console="true"/>
+</busconfig>
diff --git a/test/data/invalid-config-files/policy-member-no-path.conf b/test/data/invalid-config-files/policy-member-no-path.conf
new file mode 100644 (file)
index 0000000..9e6c89f
--- /dev/null
@@ -0,0 +1,6 @@
+<busconfig>
+  <listen>tcp:port=1234</listen>
+  <policy context="default">
+    <deny send_member="Reboot"/>
+  </policy>
+</busconfig>
diff --git a/test/data/invalid-config-files/policy-mixed.conf b/test/data/invalid-config-files/policy-mixed.conf
new file mode 100644 (file)
index 0000000..5549f23
--- /dev/null
@@ -0,0 +1,6 @@
+<busconfig>
+  <listen>tcp:port=1234</listen>
+  <policy context="default">
+    <allow user="*" own="com.example.Bees"/>
+  </policy>
+</busconfig>
diff --git a/test/data/invalid-config-files/policy-no-attributes.conf b/test/data/invalid-config-files/policy-no-attributes.conf
new file mode 100644 (file)
index 0000000..d10c496
--- /dev/null
@@ -0,0 +1,4 @@
+<busconfig>
+  <listen>tcp:port=1234</listen>
+  <policy/>
+</busconfig>
diff --git a/test/data/invalid-config-files/policy-no-rule-attribute.conf b/test/data/invalid-config-files/policy-no-rule-attribute.conf
new file mode 100644 (file)
index 0000000..08ae437
--- /dev/null
@@ -0,0 +1,6 @@
+<busconfig>
+  <listen>tcp:port=1234</listen>
+  <policy context="default">
+    <allow/>
+  </policy>
+</busconfig>
diff --git a/test/data/invalid-config-files/unknown-limit.conf b/test/data/invalid-config-files/unknown-limit.conf
new file mode 100644 (file)
index 0000000..43f8b29
--- /dev/null
@@ -0,0 +1,4 @@
+<busconfig>
+  <listen>tcp:port=1234</listen>
+  <limit name="max_bees">5000</limit>
+</busconfig>
index 8537fd90d9daf23bdf3cecf04db2e2439d1c2e53..8e8930656cdbe0b3c780fbb8420df1d73191e52c 100644 (file)
@@ -26,6 +26,7 @@
     <deny send_destination="org.freedesktop.Bar" send_interface="org.freedesktop.Foo"/>
     <deny send_destination="org.freedesktop.Bar" send_interface="org.freedesktop.Foo" send_type="method_call"/>
   </policy>
+  <apparmor mode="enabled"/>
 
   <policy context="mandatory">
     <allow user="*"/>
     <deny send_destination="org.freedesktop.Bar" send_interface="org.freedesktop.Foo" send_type="method_call"/>
   </policy>
 
+  <policy group="bin"/>
+  <policy at_console="true"/>
+  <policy at_console="false"/>
+
   <limit name="max_incoming_bytes">5000</limit>
   <limit name="max_outgoing_bytes">5000</limit>
   <limit name="max_message_size">300</limit>
diff --git a/test/data/valid-config-files/minimal.conf b/test/data/valid-config-files/minimal.conf
new file mode 100644 (file)
index 0000000..3fd2d34
--- /dev/null
@@ -0,0 +1,3 @@
+<busconfig>
+  <listen>tcp:port=1234</listen>
+</busconfig>