]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
tests: unit test for parsing simple configuration
authorVasek Sraier <git@vakabus.cz>
Tue, 30 Mar 2021 17:51:25 +0000 (19:51 +0200)
committerAleš Mrázek <ales.mrazek@nic.cz>
Fri, 8 Apr 2022 14:17:52 +0000 (16:17 +0200)
manager/tests/test_datamodel.py [new file with mode: 0644]

diff --git a/manager/tests/test_datamodel.py b/manager/tests/test_datamodel.py
new file mode 100644 (file)
index 0000000..29af2b2
--- /dev/null
@@ -0,0 +1,36 @@
+from knot_resolver_manager.datamodel import KresConfig
+
+
+def test_simple():
+    json = """
+    {
+    "server": {
+        "instances": 1
+    },
+    "lua": {
+        "script_list": [
+        "-- SPDX-License-Identifier: CC0-1.0",
+        "-- vim:syntax=lua:set ts=4 sw=4:",
+        "-- Refer to manual: https://knot-resolver.readthedocs.org/en/stable/",
+        "-- Network interface configuration","net.listen('127.0.0.1', 53, { kind = 'dns' })",
+        "net.listen('127.0.0.1', 853, { kind = 'tls' })",
+        "--net.listen('127.0.0.1', 443, { kind = 'doh2' })",
+        "net.listen('::1', 53, { kind = 'dns', freebind = true })",
+        "net.listen('::1', 853, { kind = 'tls', freebind = true })",
+        "--net.listen('::1', 443, { kind = 'doh2' })",
+        "-- Load useful modules","modules = {",
+        "'hints > iterate',  -- Load /etc/hosts and allow custom root hints",
+        "'stats',            -- Track internal statistics",
+        "'predict',          -- Prefetch expiring/frequent records",
+        "}",
+        "-- Cache size",
+        "cache.size = 100 * MB"
+        ]
+    }
+    }
+    """
+
+    config = KresConfig.from_json(json)
+
+    assert config.server.instances == 1
+    assert config.lua.script is not None
\ No newline at end of file