Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add witness TLS support #570

Merged
merged 2 commits into from
Sep 12, 2023
Merged

Conversation

kentbull
Copy link
Contributor

@kentbull kentbull commented Sep 7, 2023

Adds the same args from kli agent start to kli witness start.

If the base function createHttpServer is accepted into KERIpy then we can change my PR to KERIA to use that function rather than duplicate it.

This is missing a positive test for creating a tcp.ServerTls instance. I just need to figure out how to generate self-signed TLS certs on the fly or add a test set of TLS certs+key to the test fixtures.

@m00sey
Copy link
Member

m00sey commented Sep 7, 2023

@kentbull generating certs could work, maybe someone like lets encrypt has a python lib.

Another option would be to use a mock library (like https://pypi.org/project/mockito/).

I'm happy to try put together a sample for you.

@kentbull
Copy link
Contributor Author

kentbull commented Sep 8, 2023

Sam has a test in his iofo/hio library I'm going to bring over here: https://github.com/ioflo/hio/blob/master/tests/core/tcp/test_tcp.py#L657

@m00sey
Copy link
Member

m00sey commented Sep 8, 2023

@kentbull you don't want to copy this test over, that would just mean we're retesting HIO in keripy.

You want to mock the tcp.ServerTls calls in keripy, as they're already tested in HIO

@m00sey
Copy link
Member

m00sey commented Sep 8, 2023

You might be able to get away with just monkey patching the tcp lib for this test

Using monkeypatch mocks
@kentbull
Copy link
Contributor Author

You might be able to get away with just monkey patching the tcp lib for this test

I did just that:

def test_createHttpServer(monkeypatch):
    port = 5632
    app = falcon.App()
    server = indirecting.createHttpServer(port, app)
    assert isinstance(server, http.Server)

    monkeypatch.setattr(hio.core.tcp, 'ServerTls', MockServerTls)
    monkeypatch.setattr(hio.core.http, 'Server', MockHttpServer)

    server = indirecting.createHttpServer(port, app, keypath='keypath', certpath='certpath', cafilepath='cafilepath')

    assert isinstance(server, MockHttpServer)
    assert isinstance(server.servant, MockServerTls)

@pfeairheller pfeairheller merged commit 9b96299 into WebOfTrust:development Sep 12, 2023
@kentbull kentbull deleted the witness-tls branch May 15, 2024 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants