Skip to content

Commit 6a5971b

Browse files
committed
Add a message to Trust checks if not a trust agent/controller
Previously it would return an empty SUCCESS message because if the server is not an agent and/or controller role then there is nothing to do. So return a message that indicates this. Note: this is a change in behavior. The test used to be skipped altogether so returned no result at all. Returning a result will help ensure that all tests were executed. Fixes: #85 Signed-off-by: Rob Crittenden <rcritten@redhat.com>
1 parent 42294f7 commit 6a5971b

2 files changed

Lines changed: 54 additions & 20 deletions

File tree

src/ipahealthcheck/ipa/trust.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ class IPATrustAgentCheck(IPAPlugin):
6767
def check(self):
6868
if not self.registry.trust_agent:
6969
logger.debug('Not a trust agent, skipping')
70+
yield Result(self, constants.SUCCESS,
71+
msg="Skipped. Not a trust agent")
7072
return
7173

7274
try:
@@ -123,6 +125,8 @@ class IPATrustDomainsCheck(IPAPlugin):
123125
def check(self):
124126
if not self.registry.trust_agent:
125127
logger.debug('Not a trust agent, skipping')
128+
yield Result(self, constants.SUCCESS,
129+
msg="Skipped. Not a trust agent")
126130
return
127131

128132
result = ipautil.run([paths.SSSCTL, "domain-list"], raiseonerr=False,
@@ -272,6 +276,8 @@ class IPATrustCatalogCheck(IPAPlugin):
272276
def check(self):
273277
if not self.registry.trust_agent:
274278
logger.debug('Not a trust agent, skipping')
279+
yield Result(self, constants.SUCCESS,
280+
msg="Skipped. Not a trust agent")
275281
return
276282

277283
try:
@@ -360,6 +366,8 @@ class IPAsidgenpluginCheck(IPAPlugin):
360366
def check(self):
361367
if not self.registry.trust_agent:
362368
logger.debug('Not a trust agent, skipping')
369+
yield Result(self, constants.SUCCESS,
370+
msg="Skipped. Not a trust agent")
363371
return
364372

365373
for plugin in ['IPA SIDGEN', 'ipa-sidgen-task']:
@@ -403,6 +411,8 @@ class IPATrustAgentMemberCheck(IPAPlugin):
403411
def check(self):
404412
if not self.registry.trust_agent:
405413
logger.debug('Not a trust agent, skipping')
414+
yield Result(self, constants.SUCCESS,
415+
msg="Skipped. Not a trust agent")
406416
return
407417

408418
agent_dn = DN(('fqdn', api.env.host), api.env.container_host,
@@ -442,6 +452,8 @@ class IPATrustControllerPrincipalCheck(IPAPlugin):
442452
def check(self):
443453
if not self.registry.trust_controller:
444454
logger.debug('Not a trust controller, skipping')
455+
yield Result(self, constants.SUCCESS,
456+
msg="Skipped. Not a trust controller")
445457
return
446458

447459
agent_dn = DN(('krbprincipalname',
@@ -483,6 +495,8 @@ class IPATrustControllerServiceCheck(IPAPlugin):
483495
def check(self):
484496
if not self.registry.trust_controller:
485497
logger.debug('Not a trust controller, skipping')
498+
yield Result(self, constants.SUCCESS,
499+
msg="Skipped. Not a trust controller")
486500
return
487501

488502
service_dn = DN(('cn', 'ADTRUST'), ('cn', api.env.host),
@@ -526,6 +540,8 @@ class IPATrustControllerConfCheck(IPAPlugin):
526540
def check(self):
527541
if not self.registry.trust_controller:
528542
logger.debug('Not a trust controller, skipping')
543+
yield Result(self, constants.SUCCESS,
544+
msg="Skipped. Not a trust controller")
529545
return
530546

531547
ldapi_socket = "ipasam:ldapi://%%2fvar%%2frun%%2fslapd-%s.socket" % \
@@ -586,6 +602,8 @@ class IPATrustControllerGroupSIDCheck(IPAPlugin):
586602
def check(self):
587603
if not self.registry.trust_controller:
588604
logger.debug('Not a trust controller, skipping')
605+
yield Result(self, constants.SUCCESS,
606+
msg="Skipped. Not a trust controller")
589607
return
590608

591609
admins_dn = DN(('cn', 'admins'),
@@ -624,6 +642,8 @@ class IPATrustControllerAdminSIDCheck(IPAPlugin):
624642
def check(self):
625643
if not self.registry.trust_controller:
626644
logger.debug('Not a trust controller, skipping')
645+
yield Result(self, constants.SUCCESS,
646+
msg="Skipped. Not a trust controller")
627647
return
628648

629649
admin_dn = DN(('uid', 'admin'),
@@ -667,9 +687,13 @@ class IPATrustPackageCheck(IPAPlugin):
667687
def check(self):
668688
if self.registry.trust_controller:
669689
logger.debug('Trust controller, skipping')
690+
yield Result(self, constants.SUCCESS,
691+
msg="Skipped. Not a trust controller")
670692
return
671693
if not self.registry.trust_agent:
672694
logger.debug('Not a trust agent, skipping')
695+
yield Result(self, constants.SUCCESS,
696+
msg="Skipped. Not a trust agent")
673697
return
674698

675699
# The trust-ad package provides this import

tests/test_ipa_trust.py

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,9 @@ def test_no_trust_agent(self):
245245

246246
self.results = capture_results(f)
247247

248-
# Zero because the call was skipped altogether
249-
assert len(self.results) == 0
248+
assert len(self.results) == 1
249+
result = self.results.results[0]
250+
assert result.result == constants.SUCCESS
250251

251252
@patch('SSSDConfig.SSSDConfig')
252253
def test_trust_agent_ok(self, mock_sssd):
@@ -316,8 +317,9 @@ def test_no_trust_agent(self):
316317

317318
self.results = capture_results(f)
318319

319-
# Zero because the call was skipped altogether
320-
assert len(self.results) == 0
320+
assert len(self.results) == 1
321+
result = self.results.results[0]
322+
assert result.result == constants.SUCCESS
321323

322324
@patch('ipapython.ipautil.run')
323325
def test_trust_domain_list_fail(self, mock_run):
@@ -519,8 +521,9 @@ def test_no_trust_agent(self):
519521

520522
self.results = capture_results(f)
521523

522-
# Zero because the call was skipped altogether
523-
assert len(self.results) == 0
524+
assert len(self.results) == 1
525+
result = self.results.results[0]
526+
assert result.result == constants.SUCCESS
524527

525528
@patch('pysss_nss_idmap.getnamebysid')
526529
@patch('ipapython.ipautil.run')
@@ -779,8 +782,9 @@ def test_no_trust_agent(self):
779782

780783
self.results = capture_results(f)
781784

782-
# Zero because the call was skipped altogether
783-
assert len(self.results) == 0
785+
assert len(self.results) == 1
786+
result = self.results.results[0]
787+
assert result.result == constants.SUCCESS
784788

785789
def test_sidgen_ok(self):
786790
attrs = {
@@ -859,8 +863,9 @@ def test_no_trust_agent(self):
859863

860864
self.results = capture_results(f)
861865

862-
# Zero because the call was skipped altogether
863-
assert len(self.results) == 0
866+
assert len(self.results) == 1
867+
result = self.results.results[0]
868+
assert result.result == constants.SUCCESS
864869

865870
def test_member_ok(self):
866871
agent_dn = DN(('fqdn', m_api.env.host), m_api.env.container_host,
@@ -934,8 +939,9 @@ def test_not_trust_controller(self):
934939

935940
self.results = capture_results(f)
936941

937-
# Zero because the call was skipped altogether
938-
assert len(self.results) == 0
942+
assert len(self.results) == 1
943+
result = self.results.results[0]
944+
assert result.result == constants.SUCCESS
939945

940946
def test_principal_ok(self):
941947
agent_dn = DN(('krbprincipalname',
@@ -1011,8 +1017,9 @@ def test_not_trust_controller(self):
10111017

10121018
self.results = capture_results(f)
10131019

1014-
# Zero because the call was skipped altogether
1015-
assert len(self.results) == 0
1020+
assert len(self.results) == 1
1021+
result = self.results.results[0]
1022+
assert result.result == constants.SUCCESS
10161023

10171024
def test_service_enabled(self):
10181025
service_dn = DN(('cn', 'ADTRUST'))
@@ -1081,8 +1088,9 @@ def test_not_trust_controller(self):
10811088

10821089
self.results = capture_results(f)
10831090

1084-
# Zero because the call was skipped altogether
1085-
assert len(self.results) == 0
1091+
assert len(self.results) == 1
1092+
result = self.results.results[0]
1093+
assert result.result == constants.SUCCESS
10861094

10871095
def test_principal_ok(self):
10881096
admins_dn = DN(('cn', 'admins'))
@@ -1155,8 +1163,9 @@ def test_not_trust_controller(self):
11551163

11561164
self.results = capture_results(f)
11571165

1158-
# Zero because the call was skipped altogether
1159-
assert len(self.results) == 0
1166+
assert len(self.results) == 1
1167+
result = self.results.results[0]
1168+
assert result.result == constants.SUCCESS
11601169

11611170
def test_principal_ok(self):
11621171
admin_dn = DN(('uid', 'admin'))
@@ -1229,8 +1238,9 @@ def test_not_trust_controller(self):
12291238

12301239
self.results = capture_results(f)
12311240

1232-
# Zero because the call was skipped altogether
1233-
assert len(self.results) == 0
1241+
assert len(self.results) == 1
1242+
result = self.results.results[0]
1243+
assert result.result == constants.SUCCESS
12341244

12351245
@patch('ipapython.ipautil.run')
12361246
def test_ldapi_ok(self, mock_run):

0 commit comments

Comments
 (0)