def test_not_trust_controller(self):
        framework = object()
        registry.initialize(framework)
        registry.trust_controller = False
        f = IPATrustControllerConfCheck(registry)

        f.config = config.Config()
        self.results = capture_results(f)

        # Zero because the call was skipped altogether
        assert len(self.results) == 0
    def test_ldapi_ok(self, mock_run):
        ldapi_socket = "ipasam:ldapi://%%2fvar%%2frun%%2fslapd-%s.socket" % \
                       realm_to_serverid(m_api.env.realm)
        run_result = namedtuple('run', ['returncode', 'output'])
        run_result.returncode = 0
        run_result.output = '[global]\n\tpassdb backend=%s' % ldapi_socket
        mock_run.return_value = run_result

        framework = object()
        registry.initialize(framework)
        registry.trust_controller = True
        f = IPATrustControllerConfCheck(registry)

        f.config = config.Config()
        self.results = capture_results(f)

        assert len(self.results) == 1

        result = self.results.results[0]
        assert result.result == constants.SUCCESS
        assert result.source == 'ipahealthcheck.ipa.trust'
        assert result.check == 'IPATrustControllerConfCheck'
        assert result.kw.get('key') == 'net conf list'