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
Allow to access external server IP via https. #7712
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,22 @@ def test_get_external_ip(self): | |
m.get(net_util._AWS_CHECK_IP, exc=requests.exceptions.ConnectTimeout) | ||
self.assertEqual(None, net_util.get_external_ip()) | ||
|
||
def test_get_external_ip_use_http_by_default(self): | ||
# Test that by default we do call http endpoint | ||
with requests_mock.mock() as m: | ||
m.get(net_util._AWS_CHECK_IP, text="1.2.3.4") | ||
m.get(net_util._AWS_CHECK_IP_HTTPS, text="5.6.7.8") | ||
self.assertEqual("1.2.3.4", net_util.get_external_ip()) | ||
# Test that we do only one http call | ||
self.assertEqual(m.call_count, 1) | ||
|
||
def test_get_external_ip_https(self): | ||
# Test that if http fails, we try https | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: same thing here -- we can probably drop these comments since the test names are descriptive enough + maybe edit the second test name a bit |
||
with requests_mock.mock() as m: | ||
m.get(net_util._AWS_CHECK_IP, exc=requests.exceptions.ConnectTimeout) | ||
m.get(net_util._AWS_CHECK_IP_HTTPS, text="5.6.7.8") | ||
self.assertEqual("5.6.7.8", net_util.get_external_ip()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would be good to also verify that we make two endpoint calls |
||
|
||
def test_get_external_ip_html(self): | ||
# This tests the case where the external URL returns a web page. | ||
# https://github.com/streamlit/streamlit/issues/554#issuecomment-604847244 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I feel like the code here is straightforward enough that the comments aren't needed