horizon/openstack_auth/tests
Stephen Finucane 757bb20871 Fix system-scope test
keystoneauth 5.2.0 adds typing and corrects a number of bugs as part of
this. One of the fixes included is that the 'system_scoped' property of
the 'keystoneauth1.access.access.AccessInfoV3' class now returns True or
False, rather than True or None as was the case previously [1].

This necessitates a fix for a unit test that was asserting the previous
behavior. However, the process of fixing this test highlights the fact
that these tests are pretty broken. The test is question appears to be
asserting that the value of the 'system_scoped' attribute of the User
changes from False to None, however, the value never actually changes:
'unittest.TestCase.assertFalse' asserts that a value is Falsey, not
False [1], and the value is always None because we are using a (fake)
unscoped token rather than a (fake) system-scoped token. We are also
mocking the auth calls with a consistent value, which affects both the
attempt to rescope (intended) and the initial auth (unintended).
Finally, we appear to be check that a project-list call uses the new
token, but this call happens before our attempt to rescope so it
actually uses the old token. We simply didn't notice because we were
using the same token in both cases.

Correct this by returning different tokens for the initial auth request
and the rescope test, then update the assertion to check for True as
expected. This necessitates moving and updating the assertion for the
project list call to reflect reality. We also add a missing test case.

[1] https://docs.python.org/3/library/unittest.html#unittest.TestCase.assertFalse

Change-Id: I13873300bf789a6112b7b22567b258cba50e4373
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2024-12-17 21:49:46 +00:00
..
conf Replace all mentions of get_identity_providers with get_identity_provider 2018-04-25 11:37:05 +02:00
templates/auth Add TOTP support 2023-08-18 12:02:25 +00:00
unit Fix system-scope test 2024-12-17 21:49:46 +00:00
__init__.py Add Django OpenStack Auth to Horizon 2017-09-27 12:06:57 +01:00
data_v3.py Fix system-scope test 2024-12-17 21:49:46 +00:00
settings.py Define default settings explicitly (openstack_auth) 2019-09-12 15:05:56 +09:00
urls.py Add TOTP support 2023-08-18 12:02:25 +00:00