def test_principal_fail(self):
        service_dn = DN(('cn', 'ADTRUST'))
        attrs = {
            'ipaconfigstring': ['disabledService'],
        }
        fake_conn = LDAPClient('ldap://localhost', no_schema=True)
        ldapentry = LDAPEntry(fake_conn, service_dn)
        for attr, values in attrs.items():
            ldapentry[attr] = values

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

        f.conn = mock_ldap(ldapentry)
        f.config = config.Config()
        self.results = capture_results(f)

        assert len(self.results) == 1

        result = self.results.results[0]
        assert result.result == constants.ERROR
        assert result.source == 'ipahealthcheck.ipa.trust'
        assert result.kw.get('key') == 'ADTRUST'
Пример #2
0
    def test_service_enabled(self):
        service_dn = DN(('cn', 'ADTRUST'))
        for type in [ENABLED_SERVICE, HIDDEN_SERVICE]:
            attrs = {
                'ipaconfigstring': [type],
            }
            fake_conn = LDAPClient('ldap://localhost', no_schema=True)
            ldapentry = LDAPEntry(fake_conn, service_dn)
            for attr, values in attrs.items():
                ldapentry[attr] = values

            framework = object()
            registry.initialize(framework, config.Config)
            registry.trust_controller = True
            f = IPATrustControllerServiceCheck(registry)

            f.conn = mock_ldap(ldapentry)
            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 == 'IPATrustControllerServiceCheck'
            assert result.kw.get('key') == 'ADTRUST'
    def test_not_trust_controller(self):
        framework = object()
        registry.initialize(framework)
        registry.trust_controller = False
        f = IPATrustControllerServiceCheck(registry)

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

        # Zero because the call was skipped altogether
        assert len(self.results) == 0