Ignore UserWarning for scope checks during test runs

Placement API policy rules are defaulting to system scope.
Scope checks are disabled by default in oslo.policy, but
if you hit the API with a token that doesn't match the scope,
it generates a UserWarning, for every policy check on that
request. This is pretty annoying, so just filter those warnings
during our test runs.

Change-Id: I30ed00a96390d2c76cfc2a40c5a47c16eb51711c
This commit is contained in:
Matt Riedemann 2018-06-13 17:18:44 -04:00
parent 343c2bee23
commit 7b6fb27452
2 changed files with 8 additions and 0 deletions

View File

@ -756,6 +756,10 @@ class WarningsFixture(fixtures.Fixture):
# about any deprecations coming from it
warnings.filterwarnings('ignore',
module='mox3.mox')
# NOTE(mriedem): Ignore scope check UserWarnings from oslo.policy.
warnings.filterwarnings('ignore',
message="Policy .* failed scope check",
category=UserWarning)
self.addCleanup(warnings.resetwarnings)

View File

@ -50,6 +50,9 @@ class APIFixture(fixture.GabbiFixture):
self.standard_logging_fixture.setUp()
self.output_stream_fixture = fixtures.OutputStreamCapture()
self.output_stream_fixture.setUp()
# Filter ignorable warnings during test runs.
self.warnings_fixture = fixtures.WarningsFixture()
self.warnings_fixture.setUp()
self.conf = CONF
self.conf.set_override('auth_strategy', 'noauth2', group='api')
@ -102,6 +105,7 @@ class APIFixture(fixture.GabbiFixture):
# are flushed.
self._reset_db_flags()
self.warnings_fixture.cleanUp()
self.output_stream_fixture.cleanUp()
self.standard_logging_fixture.cleanUp()
if self.conf: