Skip to content

validate plotly_(api)_domain - HTTPS, not HTTP #997

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 11 commits into from
May 4, 2018
14 changes: 13 additions & 1 deletion plotly/tests/test_core/test_tools/test_file_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test_set_config_file_world_readable(self):
kwargs = {'world_readable': 'True'}
self.assertRaises(TypeError, tools.set_config_file, **kwargs)

def test_set_config_expected_error_msg(self):
def test_set_config_expected_warning_msg(self):

# Check that UserWarning is being called with http plotly_domain

Expand All @@ -64,6 +64,18 @@ def test_set_config_expected_error_msg(self):
assert issubclass(w[-1].category, UserWarning)
assert "plotly_domain" in str(w[-1].message)

Copy link
Member

Choose a reason for hiding this comment

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

Nice! Could you also include a test to check that no warning is issued when https is used?


def test_set_config_no_warning_msg_if_plotly_domain_is_https(self):

# Check that no UserWarning is being called with https plotly_domain

with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
kwargs = {'plotly_domain': 'https://www.foo-bar.com'}
tools.set_config_file(**kwargs)
assert len(w) == 0


def test_reset_config_file(self):

# Check reset_config and get_config return the same values
Expand Down
6 changes: 3 additions & 3 deletions plotly/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@

http_msg = (
"The plotly_domain and plotly_api_domain of your config file must start "
"with 'https', 'http'.\n If you are not using On-Prem then run the "
"with 'https', not 'http'.\n If you are not using On-Premise then run the "
Copy link
Member

Choose a reason for hiding this comment

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

I believe the \n If ... spacing still needs to be fixed. I think it would look cleaner without a new line actually.

"following code to ensure your plotly_domain and plotly_api_domain start "
"with 'https':\n\n\n"
"import plotly\n"
"plotly.tools.set_config_file(\n"
" plotly_domain='https://plot.ly',\n"
" plotly_api_domain='https://api.plot.ly'\n"
")\n\n\n"
"If you are using On-Prem then you will need to use your company's "
"If you are using On-Premise then you will need to use your company's "
"domain and api_domain urls:\n\n\n"
"import plotly\n"
"plotly.tools.set_config_file(\n"
Expand All @@ -53,7 +53,7 @@
"Make sure to replace `your-company.com` with the URL of your Plotly "
"On-Premise server.\nSee "
"https://plot.ly/python/getting-started/#special-instructions-for-plotly-onpremise-users "
"for more help with getting started with On-Prem."
"for more help with getting started with On-Premise."
)


Expand Down