Ensure django.contrib.auth.middleware monkey patching for APIMockTestCase

This patch is directly proposed to stable/rocky.

A cherry-pick of I6b2be31568e4aa4273990f9cfa76ca139620c84b
to stable/rocky is insufficient. The cherry-pick forgot to
handle APIMockTestCase as the corresponding code is different
between the master branch and stable/rocky branches and
as a result APIMockTestCase in stable/rocky branch does not
monkey-patch django.contrib.auth.middleware.

Related-Bug: #1806053
Change-Id: I4993ff5006b6366df64b6d96acddf15be0cc331c
This commit is contained in:
Akihiro Motoki 2019-01-29 23:51:37 +09:00
parent 63ae48d1a9
commit 527553752a
1 changed files with 5 additions and 4 deletions

View File

@ -616,10 +616,11 @@ class APITestCase(TestCase):
return self.swiftclient
# NOTE(adriant): APIMockTestCase was only needed for some openstack_auth
# monkeypatching. With the new monkeypatch middleware from openstack_auth this
# is not needed. This class is used by horizon plugins, so we cannot drop it.
APIMockTestCase = TestCase
class APIMockTestCase(TestCase):
def setUp(self):
super(APIMockTestCase, self).setUp()
utils.patch_middleware_get_user()
# Need this to test both Glance API V1 and V2 versions