mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-27 14:57:41 +00:00
HTTP E-Tags without quotes are invalid.
http://gsnedders.com/http-entity-tags-confusion#comment-384
This commit is contained in:
parent
736b7359a6
commit
fa5112126f
2 changed files with 7 additions and 5 deletions
|
|
@ -71,23 +71,23 @@ class StorageTests(object):
|
||||||
s = self._get_storage()
|
s = self._get_storage()
|
||||||
item = self._create_bogus_item(1)
|
item = self._create_bogus_item(1)
|
||||||
with pytest.raises(exceptions.PreconditionFailed):
|
with pytest.raises(exceptions.PreconditionFailed):
|
||||||
s.update(s._get_href('1'), item, 123)
|
s.update(s._get_href('1'), item, '"123"')
|
||||||
with pytest.raises(exceptions.PreconditionFailed):
|
with pytest.raises(exceptions.PreconditionFailed):
|
||||||
s.update('huehue', item, 123)
|
s.update('huehue', item, '"123"')
|
||||||
|
|
||||||
def test_wrong_etag(self):
|
def test_wrong_etag(self):
|
||||||
s = self._get_storage()
|
s = self._get_storage()
|
||||||
obj = self._create_bogus_item(1)
|
obj = self._create_bogus_item(1)
|
||||||
href, etag = s.upload(obj)
|
href, etag = s.upload(obj)
|
||||||
with pytest.raises(exceptions.PreconditionFailed):
|
with pytest.raises(exceptions.PreconditionFailed):
|
||||||
s.update(href, obj, 'lolnope')
|
s.update(href, obj, '"lolnope"')
|
||||||
with pytest.raises(exceptions.PreconditionFailed):
|
with pytest.raises(exceptions.PreconditionFailed):
|
||||||
s.delete(href, 'lolnope')
|
s.delete(href, '"lolnope"')
|
||||||
|
|
||||||
def test_delete_nonexisting(self):
|
def test_delete_nonexisting(self):
|
||||||
s = self._get_storage()
|
s = self._get_storage()
|
||||||
with pytest.raises(exceptions.PreconditionFailed):
|
with pytest.raises(exceptions.PreconditionFailed):
|
||||||
s.delete('1', 123)
|
s.delete('1', '"123"')
|
||||||
|
|
||||||
def test_list(self):
|
def test_list(self):
|
||||||
s = self._get_storage()
|
s = self._get_storage()
|
||||||
|
|
|
||||||
|
|
@ -193,6 +193,7 @@ class DavStorage(Storage):
|
||||||
if etag is None:
|
if etag is None:
|
||||||
headers['If-None-Match'] = '*'
|
headers['If-None-Match'] = '*'
|
||||||
else:
|
else:
|
||||||
|
assert etag[0] == etag[-1] == '"'
|
||||||
headers['If-Match'] = etag
|
headers['If-Match'] = etag
|
||||||
|
|
||||||
response = self._request(
|
response = self._request(
|
||||||
|
|
@ -221,6 +222,7 @@ class DavStorage(Storage):
|
||||||
def delete(self, href, etag):
|
def delete(self, href, etag):
|
||||||
href = self._normalize_href(href)
|
href = self._normalize_href(href)
|
||||||
headers = self._default_headers()
|
headers = self._default_headers()
|
||||||
|
assert etag[0] == etag[-1] == '"'
|
||||||
headers.update({
|
headers.update({
|
||||||
'If-Match': etag
|
'If-Match': etag
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue