aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Teichmann <daniel.teichmann@das-netzwerkteam.de>2023-02-21 12:12:53 +0100
committerDaniel Teichmann <daniel.teichmann@das-netzwerkteam.de>2023-02-21 12:47:52 +0100
commit7d4ef7c8d59406705696d03cc3b3c192bdef5afa (patch)
tree781753fe43356c88187c812103ad8557370e87b9
parenta38ec64a718917bd0998f7be6ce38e37a4af6b10 (diff)
downloadRWA.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
-rwxr-xr-xrwa/support/sessionservice/service.py19
-rwxr-xr-xtest_client.py11
2 files changed, 16 insertions, 14 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)
diff --git a/test_client.py b/test_client.py
index b646c4f..a7cb648 100755
--- a/test_client.py
+++ b/test_client.py
@@ -51,11 +51,12 @@ def get_web_app_hosts():
@cli.command()
-@click.argument("host", type=str)
-def add_web_app_host(host: str):
- """Add a RWA.Support.WebApp host. Requires <url>"""
- click.echo(f"Sending D-Bus request 'add_web_app_host': {host}")
- response = req.add_web_app_host(host)
+@click.argument("host_url", type=str)
+@click.argument("host_alias", type=str)
+def add_web_app_host(host_url: str, host_alias: str):
+ """Add a RWA.Support.WebApp host. Requires <url> <alias>"""
+ click.echo(f"Sending D-Bus request 'add_web_app_host': '{host_url}', '{host_alias}'")
+ response = req.add_web_app_host(host_url, host_alias)
click.echo(f"Your response is: {response}")