Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/ipahealthcheck/ipa/trust.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ class IPATrustAgentCheck(IPAPlugin):
def check(self):
if not self.registry.trust_agent:
logger.debug('Not a trust agent, skipping')
yield Result(self, constants.SUCCESS,
msg="Skipped. Not a trust agent")
return

try:
Expand Down Expand Up @@ -123,6 +125,8 @@ class IPATrustDomainsCheck(IPAPlugin):
def check(self):
if not self.registry.trust_agent:
logger.debug('Not a trust agent, skipping')
yield Result(self, constants.SUCCESS,
msg="Skipped. Not a trust agent")
return

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

try:
Expand Down Expand Up @@ -360,6 +366,8 @@ class IPAsidgenpluginCheck(IPAPlugin):
def check(self):
if not self.registry.trust_agent:
logger.debug('Not a trust agent, skipping')
yield Result(self, constants.SUCCESS,
msg="Skipped. Not a trust agent")
return

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

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

agent_dn = DN(('krbprincipalname',
Expand Down Expand Up @@ -483,6 +495,8 @@ class IPATrustControllerServiceCheck(IPAPlugin):
def check(self):
if not self.registry.trust_controller:
logger.debug('Not a trust controller, skipping')
yield Result(self, constants.SUCCESS,
msg="Skipped. Not a trust controller")
return

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

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

admins_dn = DN(('cn', 'admins'),
Expand Down Expand Up @@ -624,6 +642,8 @@ class IPATrustControllerAdminSIDCheck(IPAPlugin):
def check(self):
if not self.registry.trust_controller:
logger.debug('Not a trust controller, skipping')
yield Result(self, constants.SUCCESS,
msg="Skipped. Not a trust controller")
return

admin_dn = DN(('uid', 'admin'),
Expand Down Expand Up @@ -667,9 +687,13 @@ class IPATrustPackageCheck(IPAPlugin):
def check(self):
if self.registry.trust_controller:
logger.debug('Trust controller, skipping')
yield Result(self, constants.SUCCESS,
msg="Skipped. Not a trust controller")
return
if not self.registry.trust_agent:
logger.debug('Not a trust agent, skipping')
yield Result(self, constants.SUCCESS,
msg="Skipped. Not a trust agent")
return

# The trust-ad package provides this import
Expand Down
50 changes: 30 additions & 20 deletions tests/test_ipa_trust.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,9 @@ def test_no_trust_agent(self):

self.results = capture_results(f)

# Zero because the call was skipped altogether
assert len(self.results) == 0
assert len(self.results) == 1
result = self.results.results[0]
assert result.result == constants.SUCCESS

@patch('SSSDConfig.SSSDConfig')
def test_trust_agent_ok(self, mock_sssd):
Expand Down Expand Up @@ -316,8 +317,9 @@ def test_no_trust_agent(self):

self.results = capture_results(f)

# Zero because the call was skipped altogether
assert len(self.results) == 0
assert len(self.results) == 1
result = self.results.results[0]
assert result.result == constants.SUCCESS

@patch('ipapython.ipautil.run')
def test_trust_domain_list_fail(self, mock_run):
Expand Down Expand Up @@ -519,8 +521,9 @@ def test_no_trust_agent(self):

self.results = capture_results(f)

# Zero because the call was skipped altogether
assert len(self.results) == 0
assert len(self.results) == 1
result = self.results.results[0]
assert result.result == constants.SUCCESS

@patch('pysss_nss_idmap.getnamebysid')
@patch('ipapython.ipautil.run')
Expand Down Expand Up @@ -779,8 +782,9 @@ def test_no_trust_agent(self):

self.results = capture_results(f)

# Zero because the call was skipped altogether
assert len(self.results) == 0
assert len(self.results) == 1
result = self.results.results[0]
assert result.result == constants.SUCCESS

def test_sidgen_ok(self):
attrs = {
Expand Down Expand Up @@ -859,8 +863,9 @@ def test_no_trust_agent(self):

self.results = capture_results(f)

# Zero because the call was skipped altogether
assert len(self.results) == 0
assert len(self.results) == 1
result = self.results.results[0]
assert result.result == constants.SUCCESS

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

self.results = capture_results(f)

# Zero because the call was skipped altogether
assert len(self.results) == 0
assert len(self.results) == 1
result = self.results.results[0]
assert result.result == constants.SUCCESS

def test_principal_ok(self):
agent_dn = DN(('krbprincipalname',
Expand Down Expand Up @@ -1011,8 +1017,9 @@ def test_not_trust_controller(self):

self.results = capture_results(f)

# Zero because the call was skipped altogether
assert len(self.results) == 0
assert len(self.results) == 1
result = self.results.results[0]
assert result.result == constants.SUCCESS

def test_service_enabled(self):
service_dn = DN(('cn', 'ADTRUST'))
Expand Down Expand Up @@ -1081,8 +1088,9 @@ def test_not_trust_controller(self):

self.results = capture_results(f)

# Zero because the call was skipped altogether
assert len(self.results) == 0
assert len(self.results) == 1
result = self.results.results[0]
assert result.result == constants.SUCCESS

def test_principal_ok(self):
admins_dn = DN(('cn', 'admins'))
Expand Down Expand Up @@ -1155,8 +1163,9 @@ def test_not_trust_controller(self):

self.results = capture_results(f)

# Zero because the call was skipped altogether
assert len(self.results) == 0
assert len(self.results) == 1
result = self.results.results[0]
assert result.result == constants.SUCCESS

def test_principal_ok(self):
admin_dn = DN(('uid', 'admin'))
Expand Down Expand Up @@ -1229,8 +1238,9 @@ def test_not_trust_controller(self):

self.results = capture_results(f)

# Zero because the call was skipped altogether
assert len(self.results) == 0
assert len(self.results) == 1
result = self.results.results[0]
assert result.result == constants.SUCCESS

@patch('ipapython.ipautil.run')
def test_ldapi_ok(self, mock_run):
Expand Down