Skip to content

add ssl_verification_enabled to streaming_specs + tests #495

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

Merged
merged 5 commits into from
Jun 6, 2016
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

## [1.11.0] - 2016-06-06
Copy link
Member

Choose a reason for hiding this comment

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

you'll need to bump this up to 1.11.1 to upgrade it on pip

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh yep - sorry, copy and paste : ) I'll bump it to 1.12.0

### Added
- Added ability to enable/disable SSL certificate verification for streaming. Disabling SSL certification verification requires Python v2.7.9 / v3.4.3 (or above). This feature can be toggled via the `plotly_ssl_verification` configuration setting.

## [1.11.0] - 2016-05-27
### Updated
- Changed the default option for `create_distplot` in the figure factory from `probability` to `probability density` and also added the `histnorm` parameter to allow the user to choose between the two options.
Expand Down
2 changes: 2 additions & 0 deletions plotly/plotly/plotly.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ def get_streaming_specs(self):

"""
streaming_url = get_config()['plotly_streaming_domain']
ssl_verification_enabled = get_config()['plotly_ssl_verification']
ssl_enabled = 'https' in streaming_url
port = self.HTTPS_PORT if ssl_enabled else self.HTTP_PORT

Expand All @@ -476,6 +477,7 @@ def get_streaming_specs(self):
'server': host,
'port': port,
'ssl_enabled': ssl_enabled,
'ssl_verification_enabled': ssl_verification_enabled,
'headers': headers
}

Expand Down
16 changes: 12 additions & 4 deletions plotly/tests/test_core/test_stream/test_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
tk = 'vaia8trjjb'
config = {'plotly_domain': 'https://plot.ly',
'plotly_streaming_domain': 'stream.plot.ly',
'plotly_api_domain': 'https://api.plot.ly'}
'plotly_api_domain': 'https://api.plot.ly',
'plotly_ssl_verification': False}


class TestStreaming(TestCase):
Expand Down Expand Up @@ -127,6 +128,7 @@ def test_stream_no_scheme(self):
'server': 'stream.plot.ly',
'port': 80,
'ssl_enabled': False,
'ssl_verification_enabled': False,
'headers': {
'Host': 'stream.plot.ly',
'plotly-streamtoken': tk
Expand All @@ -147,6 +149,7 @@ def test_stream_http(self):
'server': 'stream.plot.ly',
'port': 80,
'ssl_enabled': False,
'ssl_verification_enabled': False,
'headers': {
'Host': 'stream.plot.ly',
'plotly-streamtoken': tk
Expand All @@ -158,15 +161,20 @@ def test_stream_http(self):
def test_stream_https(self):

# If the https scheme is used in the plotly_streaming_domain, port 443
# should be used for streaming and ssl_enabled should be True
# should be used for streaming, ssl_enabled should be True,
# and ssl_verification_enabled should equal plotly_ssl_verification

py.sign_in(un, ak,
**{'plotly_streaming_domain': 'https://stream.plot.ly'})
ssl_stream_config = {
'plotly_streaming_domain': 'https://stream.plot.ly',
'plotly_ssl_verification': True
}
py.sign_in(un, ak, **ssl_stream_config)
my_stream = py.Stream(tk)
expected_streaming_specs = {
'server': 'stream.plot.ly',
'port': 443,
'ssl_enabled': True,
'ssl_verification_enabled': True,
'headers': {
'Host': 'stream.plot.ly',
'plotly-streamtoken': tk
Expand Down
2 changes: 1 addition & 1 deletion plotly/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.11.0'
__version__ = '1.12.0'