diff options
author | Daniel Teichmann <daniel.teichmann@das-netzwerkteam.de> | 2023-02-21 12:12:53 +0100 |
---|---|---|
committer | Daniel Teichmann <daniel.teichmann@das-netzwerkteam.de> | 2023-02-21 12:47:52 +0100 |
commit | 7d4ef7c8d59406705696d03cc3b3c192bdef5afa (patch) | |
tree | 781753fe43356c88187c812103ad8557370e87b9 /rwa/support/sessionservice | |
parent | a38ec64a718917bd0998f7be6ce38e37a4af6b10 (diff) | |
download | RWA.Support.SessionService-mr/stuff.tar.gz RWA.Support.SessionService-mr/stuff.tar.bz2 RWA.Support.SessionService-mr/stuff.zip |
test_client.py, (...)/service.py: Add host_alias field to 'add_web_app_host'.mr/stuff
Diffstat (limited to 'rwa/support/sessionservice')
-rwxr-xr-x | rwa/support/sessionservice/service.py | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/rwa/support/sessionservice/service.py b/rwa/support/sessionservice/service.py index 0d7ade1..40e65cb 100755 --- a/rwa/support/sessionservice/service.py +++ b/rwa/support/sessionservice/service.py @@ -185,9 +185,9 @@ class RWASupportSessionService(dbus.service.Object): return {"status": "success", "type": "valid_host"} @dbus.service.method( - "org.ArcticaProject.RWASupportSessionService", in_signature="s", out_signature="s" + "org.ArcticaProject.RWASupportSessionService", in_signature="ss", out_signature="s" ) - def add_web_app_host(self, host_url: str) -> str: + def add_web_app_host(self, host_url: str, host_alias: str) -> str: """Add a RWA.Support.WebApp host. :param host_url: Exact hostname of the RWA.Support.WebApp host (D-Bus string) @@ -197,7 +197,7 @@ class RWASupportSessionService(dbus.service.Object): :: - {"status": "success", "host": {"url": "https://example.org", "uuid": <host_uuid>}} + {"status": "success", "host": {"url": "https://example.org", "alias": "<host_alias>", "uuid": <host_uuid>}} **Structure of returned JSON (error):** @@ -214,12 +214,13 @@ class RWASupportSessionService(dbus.service.Object): * ``duplicate`` """ host_url = str(host_url).rstrip("/") + host_alias = str(host_alias) - logging.info('D-Bus method call: %s("%s")', "add_web_app_host", host_url) + logging.info('D-Bus method call: %s("%s", "%s")', "add_web_app_host", host_url, host_alias) if not self._is_url(host_url): logging.warning("Given URL is not valid!") - logging.debug('Did not add "%s" to "web_app_hosts" in user_settings', host_url) + logging.debug('Did not add "%s":"%s" to "web_app_hosts" in user_settings', host_alias, host_url) response = json.dumps({"status": "error", "type": "invalid_url"}) logging.info('The response to D-Bus caller: "%s"', response) @@ -229,7 +230,7 @@ class RWASupportSessionService(dbus.service.Object): for uuid, host in self.settings.web_app_hosts.items(): if host_url == host['url']: logging.warning("Given URL is already present!") - logging.debug('Did not add "%s" to "web_app_hosts" in user_settings', host_url) + logging.debug('Did not add "%s":"%s" to "web_app_hosts" in user_settings', host_alias, host_url) response = json.dumps({"status": "error", "type": "duplicate"}) logging.info('The response to D-Bus caller: "%s"', response) @@ -242,19 +243,19 @@ class RWASupportSessionService(dbus.service.Object): res = self._do_api_handshake(host_url) if res["status"] == "error": - logging.debug('Did not add "%s" to "web_app_hosts" in user_settings', host_url) + logging.debug('Did not add "%s":"%s" to "web_app_hosts" in user_settings', host_alias, host_url) response = json.dumps(res) logging.info('The response to D-Bus caller: "%s"', response) return response host_uuid = str(uuid4()) - host_object = {"url": host_url} + host_object = {"url": host_url, "alias": host_alias} self.settings.web_app_hosts[host_uuid] = host_object self.settings.save_settings() - logging.info('Added "%s" to "web_app_hosts" in user_settings', host_url) + logging.info('Added "%s":"%s" to "web_app_hosts" in user_settings', host_alias, host_url) response = {"status": "success", "host": self._build_host_dict(host_uuid, host_object)} response = json.dumps(response) |