Skip to content

Commit d29fed6

Browse files
mitsuhikoashwoods
authored andcommitted
bugfix: Make DSN secret optional
1 parent 9a4eaaa commit d29fed6

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

raven/conf/remote.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def from_string(cls, value, transport=None, transport_registry=None):
111111
path = ''
112112
project = path_bits[-1]
113113

114-
if not all([netloc, project, url.username, url.password]):
114+
if not all([netloc, project, url.username]):
115115
raise InvalidDsn('Invalid Sentry DSN: %r' % url.geturl())
116116

117117
base_url = '%s://%s%s' % (url.scheme.rsplit('+', 1)[-1], netloc, path)

tests/conf/tests.py

+17-4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from raven.conf import setup_logging
77
from raven.conf.remote import RemoteConfig
88
from raven.exceptions import InvalidDsn
9+
from raven.utils import get_auth_header
910
from raven.utils.testutils import TestCase
1011

1112

@@ -80,6 +81,22 @@ def test_options(self):
8081
assert res.secret_key == 'bar'
8182
assert res.options == {'timeout': '1'}
8283

84+
def test_no_secret_key(self):
85+
dsn = 'https://[email protected]/1'
86+
res = RemoteConfig.from_string(dsn)
87+
assert res.project == '1'
88+
assert res.base_url == 'https://sentry.local'
89+
assert res.store_endpoint == 'https://sentry.local/api/1/store/'
90+
assert res.public_key == 'foo'
91+
assert res.secret_key is None
92+
assert res.options == {}
93+
94+
assert get_auth_header(protocol=7, timestamp=42,
95+
client='raven-python/1.0',
96+
api_key=res.public_key) == (
97+
'Sentry sentry_timestamp=42, sentry_client=raven-python/1.0, '
98+
'sentry_version=7, sentry_key=foo')
99+
83100
def test_missing_netloc(self):
84101
dsn = 'https://foo:bar@/1'
85102
self.assertRaises(InvalidDsn, RemoteConfig.from_string, dsn)
@@ -92,10 +109,6 @@ def test_missing_public_key(self):
92109
dsn = 'https://:[email protected]'
93110
self.assertRaises(InvalidDsn, RemoteConfig.from_string, dsn)
94111

95-
def test_missing_secret_key(self):
96-
dsn = 'https://[email protected]'
97-
self.assertRaises(InvalidDsn, RemoteConfig.from_string, dsn)
98-
99112
def test_invalid_scheme(self):
100113
dsn = 'ftp://foo:[email protected]/1'
101114
self.assertRaises(InvalidDsn, RemoteConfig.from_string, dsn)

0 commit comments

Comments
 (0)