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

HTTPS/TLS support? #127

Open
WasabiFan opened this issue Aug 16, 2020 · 2 comments
Open

HTTPS/TLS support? #127

WasabiFan opened this issue Aug 16, 2020 · 2 comments

Comments

@WasabiFan
Copy link

I have an HTTP client library that I test with mockito. One of the recent additions is support for trusting custom TLS root certificates, and it would be nice to include this in my unit test coverage. However, as far as I can tell, there's no built-in support for HTTPS within mockito, nor general solution that I've seen.

Firstly, are there existing solutions or workarounds here? Perhaps something I've missed? I could see integration within mockito itself, or an HTTPS-to-HTTP proxy which facilitates communication with the former.

If not, is there interest in adding support for this? It seems to me like an optional TLS feature via native-tls or rustls wouldn't be too intrusive (it would presumably be exposed via a separate mock server URL) and I would be interested in working on such a feature if it's helpful. Alternately, this could be developed as a separate crate; I'd appreciate any thoughts on what would make sense there!

@lipanski
Copy link
Owner

@WasabiFan thanks for raising the issue. I feel like your feature is a bit too specific for this crate, though we could revisit after #92 (which touches the server part) and only if we can make those tls dependencies optional. for now I would recommend to test the custom TLS root certificates in isolation, if you can.

@WasabiFan
Copy link
Author

👍 got it, thanks for the context!

I think TLS support can be done as purely a wrapper around existing functionality, so while it might be convenient as a built-in feature, it could also be done as a separate crate (which acts as an HTTPS->HTTP proxy) without too much trouble. Either way, definitely agreed on the dependencies.

I did some cursory testing with rust-native-tls to see how such a proxy would look, and had trouble getting it to behave like I'd expect. That project's documentation is largely nonexistent too, which is unfortunate. There are other TLS options around but that was the only one I saw which had a convenient server built-in. Moral of the story is: it'd need more investigation.

As for my particular case, I've opted to get coverage over this functionality via integration tests; it'd be ideal to do it alongside the equivalent non-TLS version in my unit tests, but this is entirely sufficient for now.

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

No branches or pull requests

2 participants