|
|
d6181b |
From 4c77f1d5172b427aad0124d7970fb6905fb0a14a Mon Sep 17 00:00:00 2001
|
|
|
d6181b |
From: =?UTF-8?q?Michal=20=C5=BDidek?= <mzidek@redhat.com>
|
|
|
d6181b |
Date: Mon, 2 Sep 2019 02:01:54 +0200
|
|
|
d6181b |
Subject: [PATCH] TESTS: Sync. multihost kcm tests with master
|
|
|
d6181b |
|
|
|
d6181b |
---
|
|
|
d6181b |
src/tests/multihost/basic/conftest.py | 8 ++
|
|
|
d6181b |
src/tests/multihost/basic/test_kcm.py | 138 ++++++++++++++++++++++++++
|
|
|
d6181b |
2 files changed, 146 insertions(+)
|
|
|
d6181b |
|
|
|
d6181b |
diff --git a/src/tests/multihost/basic/conftest.py b/src/tests/multihost/basic/conftest.py
|
|
|
d6181b |
index 87f74031c..dd3c6f001 100644
|
|
|
d6181b |
--- a/src/tests/multihost/basic/conftest.py
|
|
|
d6181b |
+++ b/src/tests/multihost/basic/conftest.py
|
|
|
d6181b |
@@ -397,6 +397,14 @@ def create_posix_usersgroups(session_multihost):
|
|
|
d6181b |
assert ret == 'Success'
|
|
|
d6181b |
|
|
|
d6181b |
|
|
|
d6181b |
+@pytest.fixture(scope='session')
|
|
|
d6181b |
+def create_many_user_principals(session_multihost):
|
|
|
d6181b |
+ krb = krb5srv(session_multihost.master[0], 'EXAMPLE.TEST')
|
|
|
d6181b |
+ for i in range(1, 65):
|
|
|
d6181b |
+ username = "user%04d" % i
|
|
|
d6181b |
+ krb.add_principal(username, 'user', 'Secret123')
|
|
|
d6181b |
+
|
|
|
d6181b |
+
|
|
|
d6181b |
@pytest.fixture(scope="session", autouse=True)
|
|
|
d6181b |
def setup_session(request, session_multihost,
|
|
|
d6181b |
package_install,
|
|
|
d6181b |
diff --git a/src/tests/multihost/basic/test_kcm.py b/src/tests/multihost/basic/test_kcm.py
|
|
|
d6181b |
index 54b3f7ecd..f18748af7 100644
|
|
|
d6181b |
--- a/src/tests/multihost/basic/test_kcm.py
|
|
|
d6181b |
+++ b/src/tests/multihost/basic/test_kcm.py
|
|
|
d6181b |
@@ -3,6 +3,7 @@ from sssd.testlib.common.utils import SSHClient
|
|
|
d6181b |
import paramiko
|
|
|
d6181b |
import pytest
|
|
|
d6181b |
import os
|
|
|
d6181b |
+import re
|
|
|
d6181b |
from utils_config import set_param, remove_section
|
|
|
d6181b |
|
|
|
d6181b |
|
|
|
d6181b |
@@ -38,6 +39,11 @@ class TestSanityKCM(object):
|
|
|
d6181b |
os.remove(local_kcm_log_file)
|
|
|
d6181b |
return nlines
|
|
|
d6181b |
|
|
|
d6181b |
+ def _remove_secret_db(self, multihost):
|
|
|
d6181b |
+ multihost.master[0].run_command(
|
|
|
d6181b |
+ 'rm -f /var/lib/sss/secrets/secrets.ldb')
|
|
|
d6181b |
+ self._restart_kcm(multihost)
|
|
|
d6181b |
+
|
|
|
d6181b |
def test_kinit_kcm(self, multihost, enable_kcm):
|
|
|
d6181b |
"""
|
|
|
d6181b |
@Title: kcm: Run kinit with KRB5CCNAME=KCM
|
|
|
d6181b |
@@ -175,3 +181,135 @@ class TestSanityKCM(object):
|
|
|
d6181b |
if 'KCM:14583109' in line:
|
|
|
d6181b |
has_cache = True
|
|
|
d6181b |
assert has_cache is True
|
|
|
d6181b |
+
|
|
|
d6181b |
+ def test_kvno_display(self, multihost, enable_kcm):
|
|
|
d6181b |
+ """
|
|
|
d6181b |
+ @Title: kcm: Test kvno correctly displays vesion numbers of principals
|
|
|
d6181b |
+ #https://pagure.io/SSSD/sssd/issue/3757
|
|
|
d6181b |
+ """
|
|
|
d6181b |
+ ssh = SSHClient(multihost.master[0].sys_hostname,
|
|
|
d6181b |
+ username='foo4', password='Secret123')
|
|
|
d6181b |
+ host_princ = 'host/%s@%s' % (multihost.master[0].sys_hostname,
|
|
|
d6181b |
+ 'EXAMPLE.TEST')
|
|
|
d6181b |
+ kvno_cmd = 'kvno %s' % (host_princ)
|
|
|
d6181b |
+ (stdout, _, exit_status) = ssh.execute_cmd(kvno_cmd)
|
|
|
d6181b |
+ for line in stdout.readlines():
|
|
|
d6181b |
+ kvno_check = re.search(r'%s: kvno = (\d+)' % host_princ, line)
|
|
|
d6181b |
+ if kvno_check:
|
|
|
d6181b |
+ print(kvno_check.group())
|
|
|
d6181b |
+ else:
|
|
|
d6181b |
+ pytest.fail("kvno display was improper")
|
|
|
d6181b |
+ ssh.close()
|
|
|
d6181b |
+
|
|
|
d6181b |
+ def test_kcm_peruid_quota(self,
|
|
|
d6181b |
+ multihost,
|
|
|
d6181b |
+ enable_kcm,
|
|
|
d6181b |
+ create_many_user_principals):
|
|
|
d6181b |
+ """
|
|
|
d6181b |
+ @Title: kcm: Make sure the quota limits a client, but only that client
|
|
|
d6181b |
+ """
|
|
|
d6181b |
+ # It is easier to keep these tests stable and independent from others
|
|
|
d6181b |
+ # if they start from a clean slate
|
|
|
d6181b |
+ self._remove_secret_db(multihost)
|
|
|
d6181b |
+
|
|
|
d6181b |
+ ssh_foo2 = SSHClient(multihost.master[0].sys_hostname,
|
|
|
d6181b |
+ username='foo2', password='Secret123')
|
|
|
d6181b |
+ ssh_foo3 = SSHClient(multihost.master[0].sys_hostname,
|
|
|
d6181b |
+ username='foo3', password='Secret123')
|
|
|
d6181b |
+
|
|
|
d6181b |
+ # The loop would request 63 users, plus there is foo3 we authenticated
|
|
|
d6181b |
+ # earlier, so this should exactly deplete the quota, but should succeed
|
|
|
d6181b |
+ for i in range(1, 64):
|
|
|
d6181b |
+ username = "user%04d" % i
|
|
|
d6181b |
+ (_, _, exit_status) = ssh_foo3.execute_cmd('kinit %s' % username,
|
|
|
d6181b |
+ stdin='Secret123')
|
|
|
d6181b |
+ assert exit_status == 0
|
|
|
d6181b |
+
|
|
|
d6181b |
+ # this kinit should be exactly one over the peruid limit
|
|
|
d6181b |
+ (_, _, exit_status) = ssh_foo3.execute_cmd('kinit user0064',
|
|
|
d6181b |
+ stdin='Secret123')
|
|
|
d6181b |
+ assert exit_status != 0
|
|
|
d6181b |
+
|
|
|
d6181b |
+ # Since this is a per-uid limit, another user should be able to kinit
|
|
|
d6181b |
+ # just fine
|
|
|
d6181b |
+ (_, _, exit_status) = ssh_foo2.execute_cmd('kinit user0064',
|
|
|
d6181b |
+ stdin='Secret123')
|
|
|
d6181b |
+ assert exit_status == 0
|
|
|
d6181b |
+
|
|
|
d6181b |
+ # kdestroy as the original user, the quota should allow a subsequent
|
|
|
d6181b |
+ # kinit
|
|
|
d6181b |
+ ssh_foo3.execute_cmd('kdestroy -A')
|
|
|
d6181b |
+ (_, _, exit_status) = ssh_foo3.execute_cmd('kinit user0064',
|
|
|
d6181b |
+ stdin='Secret123')
|
|
|
d6181b |
+ assert exit_status == 0
|
|
|
d6181b |
+
|
|
|
d6181b |
+ ssh_foo2.execute_cmd('kdestroy -A')
|
|
|
d6181b |
+ ssh_foo2.close()
|
|
|
d6181b |
+ ssh_foo3.execute_cmd('kdestroy -A')
|
|
|
d6181b |
+ ssh_foo3.close()
|
|
|
d6181b |
+
|
|
|
d6181b |
+ def test_kcm_peruid_quota_increase(self,
|
|
|
d6181b |
+ multihost,
|
|
|
d6181b |
+ enable_kcm,
|
|
|
d6181b |
+ create_many_user_principals):
|
|
|
d6181b |
+ """
|
|
|
d6181b |
+ @Title: kcm: Quota increase
|
|
|
d6181b |
+
|
|
|
d6181b |
+ Increasing the peruid quota allows a client to store more
|
|
|
d6181b |
+ data
|
|
|
d6181b |
+ """
|
|
|
d6181b |
+ # It is easier to keep these tests stable and independent from others
|
|
|
d6181b |
+ # if they start from a clean slate
|
|
|
d6181b |
+ self._remove_secret_db(multihost)
|
|
|
d6181b |
+
|
|
|
d6181b |
+ ssh_foo3 = SSHClient(multihost.master[0].sys_hostname,
|
|
|
d6181b |
+ username='foo3', password='Secret123')
|
|
|
d6181b |
+
|
|
|
d6181b |
+ # The loop would request 63 users, plus there is foo3 we authenticated
|
|
|
d6181b |
+ # earlier, so this should exactly deplete the quota, but should succeed
|
|
|
d6181b |
+ for i in range(1, 64):
|
|
|
d6181b |
+ username = "user%04d" % i
|
|
|
d6181b |
+ (_, _, exit_status) = ssh_foo3.execute_cmd('kinit %s' % username,
|
|
|
d6181b |
+ stdin='Secret123')
|
|
|
d6181b |
+ assert exit_status == 0
|
|
|
d6181b |
+
|
|
|
d6181b |
+ # this kinit should be exactly one over the peruid limit
|
|
|
d6181b |
+ (_, _, exit_status) = ssh_foo3.execute_cmd('kinit user0064',
|
|
|
d6181b |
+ stdin='Secret123')
|
|
|
d6181b |
+ assert exit_status != 0
|
|
|
d6181b |
+
|
|
|
d6181b |
+ set_param(multihost, 'kcm', 'max_uid_ccaches', '65')
|
|
|
d6181b |
+ self._restart_kcm(multihost)
|
|
|
d6181b |
+
|
|
|
d6181b |
+ # Now the kinit should work as we increased the limit
|
|
|
d6181b |
+ (_, _, exit_status) = ssh_foo3.execute_cmd('kinit user0064',
|
|
|
d6181b |
+ stdin='Secret123')
|
|
|
d6181b |
+ assert exit_status == 0
|
|
|
d6181b |
+
|
|
|
d6181b |
+ ssh_foo3.execute_cmd('kdestroy -A')
|
|
|
d6181b |
+ ssh_foo3.close()
|
|
|
d6181b |
+
|
|
|
d6181b |
+ def test_kcm_payload_low_quota(self,
|
|
|
d6181b |
+ multihost,
|
|
|
d6181b |
+ enable_kcm):
|
|
|
d6181b |
+ """
|
|
|
d6181b |
+ @Title: kcm: Quota enforcement
|
|
|
d6181b |
+
|
|
|
d6181b |
+ Set a prohibitive quota for the per-ccache payload limit and
|
|
|
d6181b |
+ make sure it gets enforced
|
|
|
d6181b |
+ """
|
|
|
d6181b |
+ # It is easier to keep these tests stable and independent from others
|
|
|
d6181b |
+ # if they start from a clean slate
|
|
|
d6181b |
+ self._remove_secret_db(multihost)
|
|
|
d6181b |
+
|
|
|
d6181b |
+ ssh_foo3 = SSHClient(multihost.master[0].sys_hostname,
|
|
|
d6181b |
+ username='foo3', password='Secret123')
|
|
|
d6181b |
+ ssh_foo3.execute_cmd('kdestroy -A')
|
|
|
d6181b |
+ ssh_foo3.close()
|
|
|
d6181b |
+
|
|
|
d6181b |
+ set_param(multihost, 'kcm', 'max_ccache_size', '1')
|
|
|
d6181b |
+ self._restart_kcm(multihost)
|
|
|
d6181b |
+
|
|
|
d6181b |
+ with pytest.raises(paramiko.ssh_exception.AuthenticationException):
|
|
|
d6181b |
+ ssh_foo3 = SSHClient(multihost.master[0].sys_hostname,
|
|
|
d6181b |
+ username='foo3', password='Secret123')
|
|
|
d6181b |
--
|
|
|
d6181b |
2.20.1
|
|
|
d6181b |
|