diff --git a/src/keria/app/agenting.py b/src/keria/app/agenting.py index a4219c12..8972243c 100644 --- a/src/keria/app/agenting.py +++ b/src/keria/app/agenting.py @@ -110,7 +110,7 @@ def setup(name, bran, adminPort, bootPort, base='', httpPort=None, configFile=No return doers -def createHttpServer(port, app, keypath, certpath, cafilepath): +def createHttpServer(port, app, keypath=None, certpath=None, cafilepath=None): """ Create an HTTP or HTTPS server depending on whether TLS key material is present diff --git a/tests/app/test_agenting.py b/tests/app/test_agenting.py index 0aee1142..cefbb3b4 100644 --- a/tests/app/test_agenting.py +++ b/tests/app/test_agenting.py @@ -10,8 +10,10 @@ import shutil import falcon +import hio from falcon import testing from hio.base import doing +from hio.core import http, tcp from hio.help import decking from keri import kering from keri.app import habbing, configing, oobiing @@ -347,3 +349,29 @@ def test_oobi_ends(seeder, helpers): assert result.json == {'oobis': ['http://127.0.0.1:3902/oobi/EHgwVwQT15OJvilVvW57HE4w0-GPs_Stj2OFoAHZSysY/agent' '/EI7AkI40M11MS7lkTCb10JC9-nDt-tXwQh44OHAFlv_9'], 'role': 'agent'} + + +class MockServerTls: + def __init__(self, certify, keypath, certpath, cafilepath, port): + pass + + +class MockHttpServer: + def __init__(self, port, app, servant=None): + self.servant = servant + + +def test_createHttpServer(monkeypatch): + port = 5632 + app = falcon.App() + server = agenting.createHttpServer(port, app) + assert isinstance(server, http.Server) + + monkeypatch.setattr(hio.core.tcp, 'ServerTls', MockServerTls) + monkeypatch.setattr(hio.core.http, 'Server', MockHttpServer) + + server = agenting.createHttpServer(port, app, keypath='keypath', certpath='certpath', + cafilepath='cafilepath') + + assert isinstance(server, MockHttpServer) + assert isinstance(server.servant, MockServerTls)