Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _discover_endpoints(self, subpath):
r = http.request(
'GET', 'https://{host}/.well-known/webfinger?resource=acct:{user}'
.format(host=self.host, user=self.user),
**self._settings
)
j = r.json()
for link in j['links']:
if 'remotestorage' in link['rel']:
break
storage = urljoin(_ensure_slash(link['href']),
_ensure_slash(subpath))
props = link['properties']
oauth = props['http://tools.ietf.org/html/rfc6749#section-4.2']
self.endpoints = dict(storage=storage, oauth=oauth)
def test_request_ssl(httpsserver):
httpsserver.serve_content('') # we need to serve something
with pytest.raises(requests.exceptions.ConnectionError) as excinfo:
http.request('GET', httpsserver.url)
assert 'certificate verify failed' in str(excinfo.value)
http.request('GET', httpsserver.url, verify=False)
def test_request_ssl(httpsserver):
httpsserver.serve_content('') # we need to serve something
with pytest.raises(requests.exceptions.ConnectionError) as excinfo:
http.request('GET', httpsserver.url)
assert 'certificate verify failed' in str(excinfo.value)
http.request('GET', httpsserver.url, verify=False)
def test_request_ssl_fingerprints(httpsserver, fingerprint):
httpsserver.serve_content('') # we need to serve something
http.request('GET', httpsserver.url, verify=False,
verify_fingerprint=fingerprint)
with pytest.raises(requests.exceptions.ConnectionError) as excinfo:
http.request('GET', httpsserver.url,
verify_fingerprint=fingerprint)
with pytest.raises(requests.exceptions.ConnectionError) as excinfo:
http.request('GET', httpsserver.url, verify=False,
verify_fingerprint=''.join(reversed(fingerprint)))
assert 'Fingerprints did not match' in str(excinfo.value)
def list(self):
r = request('GET', self.url, headers=self._default_headers(),
**self._settings)
self._items = {}
for item in split_collection(r.text):
item = Item(item)
if self._ignore_uids:
item = item.with_uid(item.hash)
self._items[item.ident] = item, item.hash
return ((href, etag) for href, (item, etag) in self._items.items())
def request(self, method, path, **kwargs):
url = self.url
if path:
url = urlparse.urljoin(self.url, path)
more = dict(self._settings)
more.update(kwargs)
return http.request(method, url, session=self._session, **more)
def request(self, method, path, **kwargs):
url = self.url
if path:
url = urlparse.urljoin(self.url, path)
more = dict(self._settings)
more.update(kwargs)
return http.request(method, url, session=self._session, **more)