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

Add condition to check for secret key and return correct uri #1501

Merged
merged 1 commit into from
Nov 14, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 0 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ jobs:
TOXENV: py36-ethpm
# Please don't use this key for any shenanigans
WEB3_INFURA_PROJECT_ID: 7707850c2fb7465ebe6f150d67182e22
WEB3_INFURA_API_SECRET: 1955838f22ac4d858434f41498557130

py36-integration-goethereum-ipc-1.7.2:
<<: *geth_steps
Expand Down Expand Up @@ -290,7 +289,6 @@ jobs:
TOXENV: py37-ethpm
# Please don't use this key for any shenanigans
WEB3_INFURA_PROJECT_ID: 7707850c2fb7465ebe6f150d67182e22
WEB3_INFURA_API_SECRET: 1955838f22ac4d858434f41498557130

py37-integration-goethereum-ipc-1.7.2:
<<: *geth_steps
Expand Down Expand Up @@ -399,7 +397,6 @@ jobs:
TOXENV: py38-ethpm
# Please don't use this key for any shenanigans
WEB3_INFURA_PROJECT_ID: 7707850c2fb7465ebe6f150d67182e22
WEB3_INFURA_API_SECRET: 1955838f22ac4d858434f41498557130

py38-integration-goethereum-ipc-1.7.2:
<<: *geth_steps
Expand Down
1 change: 1 addition & 0 deletions newsfragments/1501.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Infura websocket provider works when no secret key is present
2 changes: 1 addition & 1 deletion tests/core/providers/test_auto_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def test_web3_auto_infura_websocket_default(monkeypatch, caplog, environ_name):
monkeypatch.setenv('WEB3_INFURA_SCHEME', 'wss')
API_KEY = 'aoeuhtns'
monkeypatch.setenv(environ_name, API_KEY)
expected_url = 'wss://:@%s/ws/v3/%s' % (infura.INFURA_MAINNET_DOMAIN, API_KEY)
expected_url = 'wss://%s/ws/v3/%s' % (infura.INFURA_MAINNET_DOMAIN, API_KEY)

importlib.reload(infura)
assert len(caplog.record_tuples) == 0
Expand Down
4 changes: 3 additions & 1 deletion web3/auto/infura/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ def build_infura_url(domain):
key = load_api_key()
secret = load_secret()

if scheme == WEBSOCKET_SCHEME:
if scheme == WEBSOCKET_SCHEME and secret != '':
return "%s://:%s@%s/ws/v3/%s" % (scheme, secret, domain, key)
elif scheme == WEBSOCKET_SCHEME and secret == '':
return "%s://%s/ws/v3/%s" % (scheme, domain, key)
elif scheme == HTTP_SCHEME:
return "%s://%s/v3/%s" % (scheme, domain, key)
else:
Expand Down