Skip to content
This repository was archived by the owner on Jan 13, 2021. It is now read-only.

Issue 249: Don't rely on the bundled certificate file being available. #255

Merged
merged 12 commits into from
Jun 13, 2016

Conversation

JasonGowthorpe
Copy link
Contributor

No description provided.

…lly specified when creating the connection. Fixes exceptions if the cert.pem file included with the hyper package isn't included in a distribution (such as a generated exe)
…ng Py2Exe) without manually specifying a certificate.
# if an SSLContext is provided then use it instead of default context
_ssl_context = ssl_context
else:
global _context
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I...don't think you can do this. global _context, however, is just a statement that makes it clear to Python that I want to be able to assign to the global variable, so it shouldn't be needed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or, more specifically, it should be hoisted to the top of the function block.

@Lukasa
Copy link
Member

Lukasa commented Jun 9, 2016

Thanks for this! I have a few small notes, and then we need a test to deal with the new code branch you've introduced. =) Are you happy to deal with that?

@JasonGowthorpe
Copy link
Contributor Author

Making the suggested changes now.
Out of interest, what is the issue with only declaring the global _context in the necessary code path?
Is it just a stylistic point or something that's changed in newer versions of Python (I have never used 3+)?
Where would you like a test adding, just in test_hyper.py?

@Lukasa
Copy link
Member

Lukasa commented Jun 9, 2016

It's stylistic. =)

As for tests, maybe in test_SSLContext.py?

Hoisted global _context declaration.
Added test cases.
Backup & restore the global context to hopefully fix subsequent test failures.

assert conn.ssl_context.check_hostname
assert conn.ssl_context.verify_mode == ssl.CERT_REQUIRED
assert conn.ssl_context.options & ssl.OP_NO_COMPRESSION != 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this instance, while I like the extremely thorough testing you've done here, I think we can safely just test _init_context directly. That's the only place where we're concerned.

If you want a slightly more thorough test, you can actually wrap a socket but not bother to connect it. In both of these cases we drastically reduce the amount of system access needed to test the software, which is good.

@Lukasa
Copy link
Member

Lukasa commented Jun 10, 2016

Thanks for the work! I have one tiny style note and one thing about the testing. As always, I appreciate your spending time here, and if you get sick of the code review just say so and I can make whatever changes are still required myself.

@JasonGowthorpe
Copy link
Contributor Author

I'll get there eventually, hopefully it's up to your exacting standards now :)

On 10 Jun 2016, at 14:47, Cory Benfield notifications@github.com wrote:

Thanks for the work! I have one tiny style note and one thing about the testing. As always, I appreciate your spending time here, and if you get sick of the code review just say so and I can make whatever changes are still required myself.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.

@Lukasa
Copy link
Member

Lukasa commented Jun 10, 2016

Cool, this looks good to me. I'm not going to merge it just this second because I want to be in front of a laptop so I can make some associated docs changes.. But this looks really good, thank you so much for the work! ✨ 🍰 ✨

@Lukasa Lukasa merged commit 806aff7 into python-hyper:development Jun 13, 2016
@Lukasa
Copy link
Member

Lukasa commented Jun 13, 2016

Thanks @JasonGowthorpe! ✨ 🍰 ✨

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants