Skip to content

Commit

Permalink
Merge pull request #109 from plone/maurits-fix-tests-again
Browse files Browse the repository at this point in the history
Revert changes to tests to work with the Zope security fix. [master]
  • Loading branch information
mauritsvanrees committed Jan 9, 2023
2 parents 3965878 + da84b9d commit c3ee243
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 10 deletions.
4 changes: 4 additions & 0 deletions news/1089.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Revert changes to tests to work with the Zope security fix.
We must have an empty byte, not text, otherwise it is an indication that we get a possibly wrong Content-Type in a 304 status.
See `Zope issue 1089 <https://github.com/zopefoundation/Zope/issues/1089>`_.
[maurits]
18 changes: 13 additions & 5 deletions plone/app/caching/tests/test_profile_with_caching_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,11 @@ def test_composite_viewsxx(self):
browser.open(self.portal["f1"]["d1"].absolute_url())
# This should be a 304 response
self.assertEqual("304 Not Modified", browser.headers["Status"])
self.assertEqual("", browser.contents)
# We MUST have an empty byte, not text, otherwise it is an indication that we
# get a possibly wrong Content-Type in a 304 status.
# See https://github.com/zopefoundation/Zope/issues/1089.
self.assertEqual(b"", browser.contents)
self.assertFalse(browser.headers["Content-Type"])

# Request the anonymous folder
now = stable_now()
Expand Down Expand Up @@ -274,7 +278,8 @@ def test_composite_viewsxx(self):
)
# This should be a 304 response
self.assertEqual("304 Not Modified", browser.headers["Status"])
self.assertEqual("", browser.contents)
self.assertEqual(b"", browser.contents)
self.assertFalse(browser.headers["Content-Type"])

# Edit the page to update the etag
testText2 = "Testing... body two"
Expand Down Expand Up @@ -369,7 +374,8 @@ def test_content_feeds(self):
)
# This should be a 304 response
self.assertEqual("304 Not Modified", browser.headers["Status"])
self.assertEqual("", browser.contents)
self.assertEqual(b"", browser.contents)
self.assertFalse(browser.headers["Content-Type"])

# Request the authenticated rss feed
now = stable_now()
Expand Down Expand Up @@ -504,7 +510,8 @@ def test_content_files(self):
)
# This should be a 304 response
self.assertEqual("304 Not Modified", browser.headers["Status"])
self.assertEqual("", browser.contents)
self.assertEqual(b"", browser.contents)
self.assertFalse(browser.headers["Content-Type"])

# Request an image scale
now = stable_now()
Expand Down Expand Up @@ -560,7 +567,8 @@ def test_resources(self):
)
# This should be a 304 response
self.assertEqual("304 Not Modified", browser.headers["Status"])
self.assertEqual("", browser.contents)
self.assertEqual(b"", browser.contents)
self.assertFalse(browser.headers["Content-Type"])

# Request a large datafile (over 64K) to test files that use
# the "response.write()" function to initiate a streamed response.
Expand Down
18 changes: 13 additions & 5 deletions plone/app/caching/tests/test_profile_without_caching_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,11 @@ def test_composite_views(self):
browser.open(self.portal["f1"]["d1"].absolute_url())
# This should be a 304 response
self.assertEqual("304 Not Modified", browser.headers["Status"])
self.assertEqual("", browser.contents)
# We MUST have an empty byte, not text, otherwise it is an indication that we
# get a possibly wrong Content-Type in a 304 status.
# See https://github.com/zopefoundation/Zope/issues/1089.
self.assertEqual(b"", browser.contents)
self.assertFalse(browser.headers["Content-Type"])

# Request the anonymous folder
now = stable_now()
Expand Down Expand Up @@ -245,7 +249,8 @@ def test_composite_views(self):
)
# This should be a 304 response
self.assertEqual("304 Not Modified", browser.headers["Status"])
self.assertEqual("", browser.contents)
self.assertEqual(b"", browser.contents)
self.assertFalse(browser.headers["Content-Type"])

# Edit the page to update the etag
testText2 = "Testing... body two"
Expand Down Expand Up @@ -334,7 +339,8 @@ def test_content_feeds(self):
)
# This should be a 304 response
self.assertEqual("304 Not Modified", browser.headers["Status"])
self.assertEqual("", browser.contents)
self.assertEqual(b"", browser.contents)
self.assertFalse(browser.headers["Content-Type"])

# Request the authenticated rss feed
now = stable_now()
Expand Down Expand Up @@ -421,7 +427,8 @@ def test_content_files(self):
)
# This should be a 304 response
self.assertEqual("304 Not Modified", browser.headers["Status"])
self.assertEqual("", browser.contents)
self.assertEqual(b"", browser.contents)
self.assertFalse(browser.headers["Content-Type"])

# Request an image scale
now = stable_now()
Expand Down Expand Up @@ -471,7 +478,8 @@ def test_resources(self):
)
# This should be a 304 response
self.assertEqual("304 Not Modified", browser.headers["Status"])
self.assertEqual("", browser.contents)
self.assertEqual(b"", browser.contents)
self.assertFalse(browser.headers["Content-Type"])

# Request a large datafile (over 64K) to test files that use
# the "response.write()" function to initiate a streamed response.
Expand Down

0 comments on commit c3ee243

Please sign in to comment.