Now that we no longer support py27, we can use the standard library
unittest.mock module instead of the third party mock lib.
Change-Id: Idc319f3f8a3ddd57cba91e4cefc66dbb18d5cc22
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
Keystone audit middleware requires to iterate req.context as dict,
but Glance requires to access req.context.read_only.
When glance enabled audit, they are conflict with each other.
This patch fix this issue by store audit context in
req.environ['audit.context']
Change-Id: Ib9a62a4cd0b7b9ffb9fa2d6440e8072d45ee0fee
Closes-Bug: #1809101
Signed-off-by: Leehom Li <feli5@cisco.com>
Audit middleware does a lot of faking up environments and calling
methods instead of just running the middleware. It's a whole bunch
easier to just run the middleware wherever possible.
This means we don't have to stub context from tests as these tests
actually pass through the wsgi layer correctly. Ideally we would do more
of this.
Change-Id: I95377f030b07ffae18698ecc3c82cc6aa1dddbc7
The auth_token tests have a good layout for using create_middleware and
create_simple_middleware that makes it easy for tests to create
middleware for testing as required rather than having a self.middleware
object that gets overriden a lot.
Extract this create_middleware into a base class and implement it in
audit so the patterns are similar.
Change-Id: I2f050eef1684c8046f94dc2b88b4c97a56ea9cd8
Extract the whole class of tests that deals with oslo.messaging
notifications. This matches what we did with logging notifications.
Convert the tests to using mock fixtures rather than mock decorator
directly.
Change-Id: I805be038c1e4e1d2fe16328c44cfa03d793b0136
All the notifier tests end up mocking out the notifier object so lets
just do it once for all tests.
This also splits out the test that tries to use the logging notifier
because it's a different setup.
Change-Id: I159a2d34fe833b0bbac70c41d521bbe1dccbc09c
The API tests don't really use the API, they just test the creation of
an event so focus them on that.
There are two tests that are in the API class that really do test
middleware so they are moved back.
Change-Id: I345fe4f4c2a0d8f98ba1ff10491802002d590fa6
Create a notifier pattern that abstracts the message notification. This
should make it easier to test.
Change-Id: Ifbe3be434c304f1d3d4d570d645937a72c3503c8
This is the start of a cleanup of some of the audit middleware code.
The test changes are because this reorders the test execution order and
some of the global project tests were setting long lasting state.
Change-Id: I7a5576c1f497b9a43420f66c9e511cf6f280b62e