1# Copyright (C) 2019 Armin Kuster <akuster808@gmail.com>
2#
3import re
4
5from oeqa.runtime.case import OERuntimeTestCase
6from oeqa.core.decorator.depends import OETestDepends
7from oeqa.runtime.decorator.package import OEHasPackage
8
9
10class SSSDTest(OERuntimeTestCase):
11
12    @OEHasPackage(['sssd'])
13    @OETestDepends(['ssh.SSHTest.test_ssh'])
14    def test_sssd_help(self):
15        status, output = self.target.run('sssctl --help')
16        msg = ('sssctl command does not work as expected. '
17               'Status and output:%s and %s' % (status, output))
18        self.assertEqual(status, 1, msg = msg)
19
20    @OETestDepends(['sssd.SSSDTest.test_sssd_help'])
21    def test_sssd_sssctl_conf_perms_chk(self):
22        status, output = self.target.run('sssctl domain-status')
23        match = re.search('ConfDB initialization has failed', output)
24        if match:
25            msg = ('sssctl domain-status failed, check sssd.conf perms. '
26               'Status and output:%s and %s' % (status, output))
27            self.assertEqual(status, 0, msg = msg)
28
29    @OETestDepends(['sssd.SSSDTest.test_sssd_sssctl_conf_perms_chk'])
30    def test_sssd_sssctl_deamon(self):
31        status, output = self.target.run('sssctl domain-list')
32        match = re.search('No domains configured, fatal error!', output)
33        if match:
34            msg = ('sssctl domain-list failed, sssd.conf not setup correctly. '
35               'Status and output:%s and %s' % (status, output))
36            self.assertEqual(status, 0, msg = msg)
37
38