Files
swift/test/unit/common/middleware/test_versioned_writes.py
Alistair Coles a740591883 Tighten up encrypter tests re. request footers
The encrypter middleware uses an update_footers callback to send
request footers. Previously, FakeSwift combined footers with captured
request headers in a single dict. Tests could not therefore
specifically assert that *footers* had been captured rather than
headers.

This patch modifies FakeSwift to capture footers separately for each
request. Footers are still merged with the request headers in order to
synthesise GET or HEAD response headers when a previously uploaded
object is returned.

Unfortunately the change cannot be as simple as adding another
attribute to the FakeSwiftCall namedtuple. A list of these namedtuples
is returned by FakeSwift.calls_with_headers. Some tests cast the
namedtuples to 3-tuples and will break if the length of the namedtuple
changes.  Other tests access the attributes of the namedtuples by name
and will break if the list values are changed to plain 3-tuples.

Some test churn is therefore inevitable:

* FakeSwiftCall is changed from a namedtuple to a class. This prevents
  future tests assuming it is a fixed length tuple. It also supports a
  headers_and_footers property to return the combination of uploaded
  headers and footer that was previously (confusingly) returned by
  FakeSwiftCall.headers.

* A new property FakeSwift.call_list has been added which returns a
  list of FakeSwiftCalls.

* FakeSwift.calls_with_headers now returns a 3-tuple. Tests that
  previously assumed this was a namedtuple have been changed to use
  FakeSwift.call_list instead, which gives them objects with the same
  named attributes as the previous namedtuple. Tests that previously
  treated the namedtuple as a 3-tuple do not need to be changed.

* Tests that access the 'private' FakeSwift._calls have been changed
  to use FakeSwift.call_list.

Change-Id: If24b6fa50f1d67a7bbbf9a1794c70d37c41971f7
2025-02-11 10:30:52 +00:00

65 KiB