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

FDSN client: bug in Client.set_credentials() (not using queryauth endpoint) #2146

Merged
merged 3 commits into from May 16, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions obspy/clients/fdsn/client.py
Expand Up @@ -288,6 +288,7 @@ def set_credentials(self, user, password):
:type password: str
:param password: Password for given user name.
"""
self.user = user
self._set_opener(user, password)

def set_eida_token(self, token):
Expand Down
21 changes: 21 additions & 0 deletions obspy/clients/fdsn/tests/test_client.py
Expand Up @@ -282,6 +282,27 @@ def test_url_building_with_auth(self):
"queryauth?net=BW")
self.assertEqual(got, expected)

def test_set_credentials(self):
"""
Test for issue #2146

When setting credentials not during `__init__` but using
`set_credentials`, waveform queries should still properly go to
"queryauth" endpoint.
"""
client = Client(base_url="IRIS", user_agent=USER_AGENT)
user = "nobody@iris.edu"
password = "anonymous"
client.set_credentials(user=user, password=password)
got = client._build_url("dataselect", "query", {'net': "BW"})
expected = ("http://service.iris.edu/fdsnws/dataselect/1/"
"queryauth?net=BW")
self.assertEqual(got, expected)
# more basic test: check that set_credentials has set Client.user
# (which is tested when checking which endpoint to use, query or
# queryauth)
self.assertEqual(client.user, user)

def test_service_discovery_iris(self):
"""
Tests the automatic discovery of services with the IRIS endpoint. The
Expand Down