def test_get_public_dsn(self): res = RemoteConfig( base_url='http://example.com', project='1', public_key='public', secret_key='secret', ) public_dsn = res.get_public_dsn() assert public_dsn == '//[email protected]/1'
def set_dsn(self, dsn = None, transport = None): if not dsn and os.environ.get('SENTRY_DSN'): msg = "Configuring Raven from environment variable 'SENTRY_DSN'" self.logger.debug(msg) dsn = os.environ['SENTRY_DSN'] if dsn not in self._transport_cache: if not dsn: result = RemoteConfig(transport=transport) else: result = RemoteConfig.from_string(dsn, transport=transport, transport_registry=self._registry) self._transport_cache[dsn] = result self.remote = result else: self.remote = self._transport_cache[dsn] self.logger.debug('Configuring Raven for host: {0}'.format(self.remote))
def test_options(self): dsn = "http://*****:*****@sentry.local/1?timeout=1" res = RemoteConfig.from_string(dsn) assert res.project == "1" assert res.base_url == "http://sentry.local" assert res.store_endpoint == "http://sentry.local/api/1/store/" assert res.public_key == "foo" assert res.secret_key == "bar" assert res.options == {"timeout": "1"}
def test_https_with_port(self): dsn = "https://*****:*****@sentry.local:9000/app/1" res = RemoteConfig.from_string(dsn) assert res.project == "1" assert res.base_url == "https://sentry.local:9000/app" assert res.store_endpoint == "https://sentry.local:9000/app/api/1/store/" assert res.public_key == "foo" assert res.secret_key == "bar" assert res.options == {}
def test_options(self): dsn = 'http://*****:*****@sentry.local/1?timeout=1' res = RemoteConfig.from_string(dsn) assert res.project == '1' assert res.base_url == 'http://sentry.local' assert res.store_endpoint == 'http://sentry.local/api/1/store/' assert res.public_key == 'foo' assert res.secret_key == 'bar' assert res.options == {'timeout': '1'}
def test_https_with_port(self): dsn = 'https://*****:*****@sentry.local:9000/app/1' res = RemoteConfig.from_string(dsn) assert res.project == '1' assert res.base_url == 'https://sentry.local:9000/app' assert res.store_endpoint == 'https://sentry.local:9000/app/api/1/store/' assert res.public_key == 'foo' assert res.secret_key == 'bar' assert res.options == {}
def test_no_secret_key(self): dsn = 'https://[email protected]/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 res.is_active() 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_no_secret_key(self): dsn = 'https://[email protected]/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 set_dsn(self, dsn=None, transport=None): if dsn is None and os.environ.get("SENTRY_DSN"): msg = "Configuring Raven from environment variable 'SENTRY_DSN'" self.logger.debug(msg) dsn = os.environ["SENTRY_DSN"] if dsn not in self._transport_cache: if dsn is None: result = RemoteConfig(transport=transport) else: result = RemoteConfig.from_string(dsn, transport=transport, transport_registry=self._registry) self._transport_cache[dsn] = result self.remote = result else: self.remote = self._transport_cache[dsn] self.logger.debug("Configuring Raven for host: {0}".format(self.remote))
def test_get_public_dsn(self): res = RemoteConfig(base_url="http://example.com", project="1", public_key="public", secret_key="secret") public_dsn = res.get_public_dsn() assert public_dsn == "//[email protected]/1"