tests: Disable policy deprecation warnings

Change-Id: I8d2710ac7275916bedf186131e5b0f88743c37c1
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane 2023-04-19 12:17:06 +01:00
parent 34979553e7
commit 92fb44ce72
2 changed files with 18 additions and 2 deletions

View File

@ -37,12 +37,28 @@ def reset():
ENFORCER = None
def init():
def init(suppress_deprecation_warnings=False):
"""Init an Enforcer class.
:param suppress_deprecation_warnings: Whether to suppress the deprecation
warnings.
"""
global ENFORCER
global saved_file_rules
if not ENFORCER:
ENFORCER = policy.Enforcer(CONF)
# NOTE(gmann): Explictly disable the warnings for policies
# changing their default check_str. During policy-defaults-refresh
# work, all the policy defaults have been changed and warning for
# each policy started filling the logs limit for various tool.
# Once we move to new defaults only world then we can enable these
# warning again.
ENFORCER.suppress_default_change_warnings = True
if suppress_deprecation_warnings:
ENFORCER.suppress_deprecation_warnings = True
register_rules(ENFORCER)
ENFORCER.load_rules()

View File

@ -42,7 +42,7 @@ TEST_VAR_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__),
CONF = config.new_config()
policy.init()
policy.init(suppress_deprecation_warnings=True)
ENFORCER = policy.ENFORCER