Skip to content

Commit

Permalink
Tests:port rfc2307 username begin with a space
Browse files Browse the repository at this point in the history
Porting and rewriting of a rfc2307 testcase which tests
a username having a space char at it's beginning
  • Loading branch information
Shridhar Gadekar committed Apr 13, 2022
1 parent 42d3e28 commit 3e4ba40
Showing 1 changed file with 93 additions and 0 deletions.
93 changes: 93 additions & 0 deletions src/tests/multihost/alltests/test_rfc2307.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
""" Automation of rfc2307
:requirement: rfc2307
:casecomponent: sssd
:subsystemteam: sst_idm_sssd
:upstream: yes
"""
from __future__ import print_function
import pytest
import random
from sssd.testlib.common.utils import sssdTools
from sssd.testlib.common.libkrb5 import krb5srv
from sssd.testlib.common.utils import SSHClient
from sssd.testlib.common.utils import sssdTools, LdapOperations
from constants import ds_instance_name, ds_suffix, ds_rootdn, ds_rootpw
from sssd.testlib.common.exceptions import SSHLoginException
from sssd.testlib.common.expect import pexpect_ssh


def usr_grp(multihost, user_info, type):
ldap_uri = f'ldap://{multihost.master[0].sys_hostname}'
ds_rootdn = 'cn=Directory Manager'
ds_rootpw = 'Secret123'
ldap_inst = LdapOperations(ldap_uri, ds_rootdn, ds_rootpw)
krb = krb5srv(multihost.master[0], 'EXAMPLE.TEST')
unq_num = random.randint(9999, 999999)
if type == 'user':
usr = user_info.get('uid')
if ldap_inst.posix_user("ou=People", ds_suffix, user_info):
krb.add_principal(usr, 'user', 'Secret123')
return True
else:
print(f"Unable to add ldap User {user_info}")
assert False
if type == 'group':
try:
ldap_inst.posix_group("ou=Groups", ds_suffix, user_info,
memberUid=user_info.get('memberUid'))
except LdapException:
print(f"Unable to add ldap group {user_info}")
assert False


@pytest.mark.usefixtures('setup_sssd', 'create_posix_usersgroups')
@pytest.mark.rfc2307
class Testrfc2307(object):
"""
This is test case class for ldap rfc2307
:setup:
1. Configure SSSD to authenticate against directory server
2. Enable debug_level to 9 in the 'nss', 'pam' and domain section
"""
@pytest.mark.tier2
def test_0001_bz1362023(self, multihost, backupsssdconf):
"""
:title: IDM-SSSD-TC: rfc2307: user with spaces at beginning
:id: 6923436c-d4e4-4a0d-a8f3-1e94ecb1dee3
:description: user with a white space at the beginning in it's name
should be able to log in
:bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1362023
:steps:
1. Create user with a white space at beginning in their name
2. Restart SSSD with cleared cache
3. Fetch user information using 'id'
4. Confirm user is able to log in via ssh
:expectedresults:
1. Should succeed
2. Should succeed
3. Should succeed
4. Should succeed
"""
usr = f' tuser'
usr_info = {'cn': usr, 'uid': usr,
'uidNumber': '34583100',
'gidNumber': '34564100'}
assert usr_grp(multihost, usr_info, 'user')
tools = sssdTools(multihost.client[0])
domain_name = tools.get_domain_section_name()
start = multihost.client[0].service_sssd('start')
tools.clear_sssd_cache()
user = f'\ tuser@{domain_name}'
client = pexpect_ssh(multihost.client[0].sys_hostname, user,
'Secret123', debug=False)
try:
client.login()
except SSHLoginException:
pytest.fail("%s failed to login" % user)
else:
id_cmd = f'id {user}'
(_, ret) = client.command(id_cmd)
assert ret == '0'
client.logout()

0 comments on commit 3e4ba40

Please sign in to comment.