From de6d833559f89f452e30fc27e4b7bffc704c6134 Mon Sep 17 00:00:00 2001 From: sklump Date: Fri, 8 May 2020 10:36:06 +0000 Subject: [PATCH 1/2] do not crash on connection request/response creation if no endpoints at all in config Signed-off-by: sklump --- aries_cloudagent/protocols/connections/v1_0/manager.py | 6 ++++-- .../protocols/connections/v1_0/tests/test_manager.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/aries_cloudagent/protocols/connections/v1_0/manager.py b/aries_cloudagent/protocols/connections/v1_0/manager.py index f5e21e3210..196706b41b 100644 --- a/aries_cloudagent/protocols/connections/v1_0/manager.py +++ b/aries_cloudagent/protocols/connections/v1_0/manager.py @@ -296,7 +296,8 @@ async def create_request( # Create connection request message if not my_endpoint: - my_endpoints = [self.context.settings.get("default_endpoint")] + my_endpoints = [] + my_endpoints.extend(self.context.settings.get("default_endpoint", [])) my_endpoints.extend(self.context.settings.get("additional_endpoints", [])) else: my_endpoints = [my_endpoint] @@ -478,7 +479,8 @@ async def create_response( # Create connection response message if not my_endpoint: - my_endpoints = [self.context.settings.get("default_endpoint")] + my_endpoints = [] + my_endpoints.extend(self.context.settings.get("default_endpoint", [])) my_endpoints.extend(self.context.settings.get("additional_endpoints", [])) did_doc = await self.create_did_document( my_info, connection.inbound_connection_id, my_endpoints diff --git a/aries_cloudagent/protocols/connections/v1_0/tests/test_manager.py b/aries_cloudagent/protocols/connections/v1_0/tests/test_manager.py index 354d2eaaff..28f22cb4a8 100644 --- a/aries_cloudagent/protocols/connections/v1_0/tests/test_manager.py +++ b/aries_cloudagent/protocols/connections/v1_0/tests/test_manager.py @@ -77,7 +77,7 @@ def setUp(self): { "default_endpoint": "http://aries.ca/endpoint", "default_label": "This guy", - "additional_endpoints": [], + "additional_endpoints": ["http://aries.ca/another-endpoint"], "debug.auto_accept_invites": True, "debug.auto_accept_requests": True, } From 21b2dd19ba47a8d8247a04739c0e205c4cc03144 Mon Sep 17 00:00:00 2001 From: sklump Date: Fri, 8 May 2020 15:57:55 +0000 Subject: [PATCH 2/2] default endpoint is a string Signed-off-by: sklump --- aries_cloudagent/protocols/connections/v1_0/manager.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/aries_cloudagent/protocols/connections/v1_0/manager.py b/aries_cloudagent/protocols/connections/v1_0/manager.py index 196706b41b..70f683363f 100644 --- a/aries_cloudagent/protocols/connections/v1_0/manager.py +++ b/aries_cloudagent/protocols/connections/v1_0/manager.py @@ -297,7 +297,9 @@ async def create_request( # Create connection request message if not my_endpoint: my_endpoints = [] - my_endpoints.extend(self.context.settings.get("default_endpoint", [])) + default_endpoint = self.context.settings.get("default_endpoint") + if default_endpoint: + my_endpoints.append(default_endpoint) my_endpoints.extend(self.context.settings.get("additional_endpoints", [])) else: my_endpoints = [my_endpoint] @@ -480,7 +482,9 @@ async def create_response( # Create connection response message if not my_endpoint: my_endpoints = [] - my_endpoints.extend(self.context.settings.get("default_endpoint", [])) + default_endpoint = self.context.settings.get("default_endpoint") + if default_endpoint: + my_endpoints.append(default_endpoint) my_endpoints.extend(self.context.settings.get("additional_endpoints", [])) did_doc = await self.create_did_document( my_info, connection.inbound_connection_id, my_endpoints