diff options
author | Armin Ronacher <armin.ronacher@active-4.com> | 2018-04-18 09:40:12 +0200 |
---|---|---|
committer | Armin Ronacher <armin.ronacher@active-4.com> | 2018-04-18 11:02:50 +0200 |
commit | 0cde5237c2e9ebf5d198e9666fe9cea38d190054 (patch) | |
tree | 8c9e6c2dff0dfccb5dc7c4cf1cfcc59cba71ccde | |
parent | 6869e2d3b5b3a90bcd00322676ab97ab20c90082 (diff) | |
download | raven-bugfix/optional-dsn.tar.gz |
bugfix: Make DSN secret optionalbugfix/optional-dsn
-rw-r--r-- | raven/conf/remote.py | 2 | ||||
-rw-r--r-- | tests/conf/tests.py | 21 |
2 files changed, 18 insertions, 5 deletions
diff --git a/raven/conf/remote.py b/raven/conf/remote.py index 8dd54bf..7d9235e 100644 --- a/raven/conf/remote.py +++ b/raven/conf/remote.py @@ -111,7 +111,7 @@ class RemoteConfig(object): path = '' project = path_bits[-1] - if not all([netloc, project, url.username, url.password]): + if not all([netloc, project, url.username]): raise InvalidDsn('Invalid Sentry DSN: %r' % url.geturl()) base_url = '%s://%s%s' % (url.scheme.rsplit('+', 1)[-1], netloc, path) diff --git a/tests/conf/tests.py b/tests/conf/tests.py index e02a1fb..6a348bb 100644 --- a/tests/conf/tests.py +++ b/tests/conf/tests.py @@ -6,6 +6,7 @@ import mock from raven.conf import setup_logging from raven.conf.remote import RemoteConfig from raven.exceptions import InvalidDsn +from raven.utils import get_auth_header from raven.utils.testutils import TestCase @@ -80,6 +81,22 @@ class RemoteConfigTest(TestCase): assert res.secret_key == 'bar' assert res.options == {'timeout': '1'} + def test_no_secret_key(self): + dsn = 'https://foo@sentry.local/1' + res = RemoteConfig.from_string(dsn) + assert res.project == '1' + assert res.base_url == 'https://sentry.local' + assert res.store_endpoint == 'https://sentry.local/api/1/store/' + assert res.public_key == 'foo' + assert res.secret_key is None + assert res.options == {} + + assert get_auth_header(protocol=7, timestamp=42, + client='raven-python/1.0', + api_key=res.public_key) == ( + 'Sentry sentry_timestamp=42, sentry_client=raven-python/1.0, ' + 'sentry_version=7, sentry_key=foo') + def test_missing_netloc(self): dsn = 'https://foo:bar@/1' self.assertRaises(InvalidDsn, RemoteConfig.from_string, dsn) @@ -92,10 +109,6 @@ class RemoteConfigTest(TestCase): dsn = 'https://:bar@example.com' self.assertRaises(InvalidDsn, RemoteConfig.from_string, dsn) - def test_missing_secret_key(self): - dsn = 'https://bar@example.com' - self.assertRaises(InvalidDsn, RemoteConfig.from_string, dsn) - def test_invalid_scheme(self): dsn = 'ftp://foo:bar@sentry.local/1' self.assertRaises(InvalidDsn, RemoteConfig.from_string, dsn) |