|
|
23f808 |
From 0727c05df8e2b9cd6977bf076e88e5da0fd573a6 Mon Sep 17 00:00:00 2001
|
|
|
23f808 |
From: Rob Crittenden <rcritten@redhat.com>
|
|
|
23f808 |
Date: Tue, 6 Aug 2019 16:04:40 -0400
|
|
|
23f808 |
Subject: [PATCH 5/8] Mock the AD trust roles
|
|
|
23f808 |
|
|
|
23f808 |
The actual values are set directly in the registry but these classes
|
|
|
23f808 |
provide just enough implementation to allow the code to initialize.
|
|
|
23f808 |
---
|
|
|
23f808 |
src/ipahealthcheck/ipa/plugin.py | 4 +++-
|
|
|
23f808 |
tests/base.py | 5 +++++
|
|
|
23f808 |
tests/util.py | 27 +++++++++++++++++++++++++++
|
|
|
23f808 |
3 files changed, 35 insertions(+), 1 deletion(-)
|
|
|
23f808 |
|
|
|
23f808 |
diff --git a/src/ipahealthcheck/ipa/plugin.py b/src/ipahealthcheck/ipa/plugin.py
|
|
|
23f808 |
index c4cef9b..bd95c16 100644
|
|
|
23f808 |
--- a/src/ipahealthcheck/ipa/plugin.py
|
|
|
23f808 |
+++ b/src/ipahealthcheck/ipa/plugin.py
|
|
|
23f808 |
@@ -12,7 +12,6 @@ from ipaserver.install import cainstance
|
|
|
23f808 |
from ipaserver.install import dsinstance
|
|
|
23f808 |
from ipaserver.install import httpinstance
|
|
|
23f808 |
from ipaserver.install import installutils
|
|
|
23f808 |
-from ipaserver.servroles import ADtrustBasedRole, ServiceBasedRole
|
|
|
23f808 |
|
|
|
23f808 |
from ipahealthcheck.core.plugin import Plugin, Registry
|
|
|
23f808 |
|
|
|
23f808 |
@@ -38,6 +37,9 @@ class IPARegistry(Registry):
|
|
|
23f808 |
self.trust_controller = False
|
|
|
23f808 |
|
|
|
23f808 |
def initialize(self, framework):
|
|
|
23f808 |
+ # deferred import for mock
|
|
|
23f808 |
+ from ipaserver.servroles import ADtrustBasedRole, ServiceBasedRole
|
|
|
23f808 |
+
|
|
|
23f808 |
installutils.check_server_configuration()
|
|
|
23f808 |
|
|
|
23f808 |
if not api.isdone('finalize'):
|
|
|
23f808 |
diff --git a/tests/base.py b/tests/base.py
|
|
|
23f808 |
index 8b9e37c..d1d2442 100644
|
|
|
23f808 |
--- a/tests/base.py
|
|
|
23f808 |
+++ b/tests/base.py
|
|
|
23f808 |
@@ -3,6 +3,7 @@
|
|
|
23f808 |
#
|
|
|
23f808 |
from unittest import mock, TestCase
|
|
|
23f808 |
from util import no_exceptions
|
|
|
23f808 |
+from util import ADtrustBasedRole, ServiceBasedRole
|
|
|
23f808 |
|
|
|
23f808 |
|
|
|
23f808 |
class BaseTest(TestCase):
|
|
|
23f808 |
@@ -24,6 +25,10 @@ class BaseTest(TestCase):
|
|
|
23f808 |
default_patches = {
|
|
|
23f808 |
'ipaserver.install.installutils.check_server_configuration':
|
|
|
23f808 |
mock.Mock(return_value=None),
|
|
|
23f808 |
+ 'ipaserver.servroles.ServiceBasedRole':
|
|
|
23f808 |
+ mock.Mock(return_value=ServiceBasedRole()),
|
|
|
23f808 |
+ 'ipaserver.servroles.ADtrustBasedRole':
|
|
|
23f808 |
+ mock.Mock(return_value=ADtrustBasedRole()),
|
|
|
23f808 |
}
|
|
|
23f808 |
patches = {}
|
|
|
23f808 |
|
|
|
23f808 |
diff --git a/tests/util.py b/tests/util.py
|
|
|
23f808 |
index 603185f..5bd592e 100644
|
|
|
23f808 |
--- a/tests/util.py
|
|
|
23f808 |
+++ b/tests/util.py
|
|
|
23f808 |
@@ -76,6 +76,33 @@ class KRAInstance:
|
|
|
23f808 |
return self.installed
|
|
|
23f808 |
|
|
|
23f808 |
|
|
|
23f808 |
+class ServiceBasedRole:
|
|
|
23f808 |
+ """A bare-bones role override
|
|
|
23f808 |
+
|
|
|
23f808 |
+ This is just enough to satisfy the initialization code so
|
|
|
23f808 |
+ the AD Trust status can be determined. It will always default
|
|
|
23f808 |
+ to false and the registry should be overridden directly in the
|
|
|
23f808 |
+ test cases.
|
|
|
23f808 |
+ """
|
|
|
23f808 |
+ def __init__(self, attr_name=None, name=None, component_services=None):
|
|
|
23f808 |
+ pass
|
|
|
23f808 |
+
|
|
|
23f808 |
+ def status(self, api_instance, server=None, attrs_list=("*",)):
|
|
|
23f808 |
+ return [dict()]
|
|
|
23f808 |
+
|
|
|
23f808 |
+
|
|
|
23f808 |
+class ADtrustBasedRole(ServiceBasedRole):
|
|
|
23f808 |
+ """A bare-bones role override
|
|
|
23f808 |
+
|
|
|
23f808 |
+ This is just enough to satisfy the initialization code so
|
|
|
23f808 |
+ the AD Trust status can be determined. It will always default
|
|
|
23f808 |
+ to false and the registry should be overridden directly in the
|
|
|
23f808 |
+ test cases.
|
|
|
23f808 |
+ """
|
|
|
23f808 |
+ def __init__(self, attr_name=None, name=None):
|
|
|
23f808 |
+ pass
|
|
|
23f808 |
+
|
|
|
23f808 |
+
|
|
|
23f808 |
# Mock api. This file needs to be imported before anything that would
|
|
|
23f808 |
# import ipalib.api in order for it to be replaced properly.
|
|
|
23f808 |
|
|
|
23f808 |
--
|
|
|
23f808 |
2.20.1
|
|
|
23f808 |
|