summary refs log tree commit diff
diff options
context:
space:
mode:
authorJorik Schellekens <joriks@matrix.org>2019-08-27 14:33:28 +0100
committerJorik Schellekens <joriks@matrix.org>2019-08-28 15:59:54 +0100
commit2d56f81d0541cda2b40b08754752672e66f6fd60 (patch)
tree2aa3ae3db57f21c7e1652b534a466f1af8fa64a4
parentNot importing that from there (diff)
downloadsynapse-2d56f81d0541cda2b40b08754752672e66f6fd60.tar.xz
We need to check that the pasth is abs and we don't need to validate
-rw-r--r--synapse_topology/server/server.py14
-rw-r--r--synapse_topology/server/utils.py5
2 files changed, 10 insertions, 9 deletions
diff --git a/synapse_topology/server/server.py b/synapse_topology/server/server.py
index 02ca013b24..b39d6c8b8d 100644
--- a/synapse_topology/server/server.py
+++ b/synapse_topology/server/server.py
@@ -1,4 +1,4 @@
-from os.path import abspath, dirname, join
+from os.path import abspath, dirname, join, isabs
 
 from canonicaljson import json
 
@@ -62,13 +62,13 @@ class Server:
         self.model.set_config(body)
 
     @app.route("/testcertpaths", methods=["POST"])
-    @log_body_if_fail
-    @validate_schema(CERT_PATHS_SCHEMA)
-    def test_cert_paths(self, request, body):
+    def test_cert_paths(self, request):
+        body = json.loads(request.content.read())
         result = {}
-        config_path = self.model.get_config_dir()
+        config_path = self.model.config_dir
         for name, path in body.items():
-            path = abspath(join(config_path, path))
+            if not isabs(path):
+                path = abspath(join(config_path, path))
             try:
                 with open(path, "r"):
                     result[name] = {"invalid": False, "absolute_path": path}
@@ -92,7 +92,7 @@ class Server:
     @app.route("/start", methods=["POST"])
     def start_synapse(self, request):
         print("Starting synapse")
-        subprocess.Popen(["synctl", "start", self.model.get_config_dir()])
+        subprocess.Popen(["synctl", "start", self.model.config_dir])
         sys.exit()
 
     @app.route("/favicon.ico")
diff --git a/synapse_topology/server/utils.py b/synapse_topology/server/utils.py
index c42ed66923..aab851aa1b 100644
--- a/synapse_topology/server/utils.py
+++ b/synapse_topology/server/utils.py
@@ -12,6 +12,7 @@ def validate_schema(schema):
         @wraps(func)
         def _do_validate(self, request):
             body = json.loads(request.content.read())
+            print(body)
             validate(instance=body, schema=schema)
             return func(self, request, body)
 
@@ -36,9 +37,9 @@ def port_checker(port):
 
 def log_body_if_fail(func):
     @wraps(func)
-    def _log_wrapper(request):
+    def _log_wrapper(self, request):
         try:
-            return func(request)
+            return func(self, request)
         except Exception:
             body = json.loads(request.content.read())
             print(body)