|
|
ca1eb8 |
From 4bff9d92a51bff2fabb6168f8ae69c8a8d17ba2a Mon Sep 17 00:00:00 2001
|
|
|
96eb28 |
From: Jakub Hrozek <jhrozek@redhat.com>
|
|
|
96eb28 |
Date: Sun, 17 Jun 2018 22:06:22 +0200
|
|
|
96eb28 |
Subject: [PATCH] TESTS: Allow adding sshPublicKey for users
|
|
|
96eb28 |
MIME-Version: 1.0
|
|
|
96eb28 |
Content-Type: text/plain; charset=UTF-8
|
|
|
96eb28 |
Content-Transfer-Encoding: 8bit
|
|
|
96eb28 |
|
|
|
96eb28 |
Adds the objectclass and allows storing a list of sshPublicKey
|
|
|
96eb28 |
attributes for users. Since there is no harm in adding the extra
|
|
|
96eb28 |
objectclass, we can do it unconditionally.
|
|
|
96eb28 |
|
|
|
96eb28 |
Related to:
|
|
|
96eb28 |
https://pagure.io/SSSD/sssd/issue/3747
|
|
|
96eb28 |
|
|
|
96eb28 |
Reviewed-by: Fabiano FidĂȘncio <fidencio@redhat.com>
|
|
|
96eb28 |
(cherry picked from commit 56cda832e9f61c52e9cfde1f0864507de718ffbb)
|
|
|
96eb28 |
---
|
|
|
96eb28 |
src/tests/intg/ldap_ent.py | 15 +++++++++++----
|
|
|
96eb28 |
1 file changed, 11 insertions(+), 4 deletions(-)
|
|
|
96eb28 |
|
|
|
96eb28 |
diff --git a/src/tests/intg/ldap_ent.py b/src/tests/intg/ldap_ent.py
|
|
|
96eb28 |
index 6b6d8f903cbcc277d892c3212ca382f4aaadc671..a4c987969d3dcefba2af69e095b220180e0fa54c 100644
|
|
|
96eb28 |
--- a/src/tests/intg/ldap_ent.py
|
|
|
96eb28 |
+++ b/src/tests/intg/ldap_ent.py
|
|
|
96eb28 |
@@ -24,7 +24,8 @@ def user(base_dn, uid, uidNumber, gidNumber,
|
|
|
96eb28 |
homeDirectory=None,
|
|
|
96eb28 |
loginShell=None,
|
|
|
96eb28 |
cn=None,
|
|
|
96eb28 |
- sn=None):
|
|
|
96eb28 |
+ sn=None,
|
|
|
96eb28 |
+ sshPubKey=()):
|
|
|
96eb28 |
"""
|
|
|
96eb28 |
Generate an RFC2307(bis) user add-modlist for passing to ldap.add*
|
|
|
96eb28 |
"""
|
|
|
96eb28 |
@@ -33,7 +34,8 @@ def user(base_dn, uid, uidNumber, gidNumber,
|
|
|
96eb28 |
user = (
|
|
|
96eb28 |
"uid=" + uid + ",ou=Users," + base_dn,
|
|
|
96eb28 |
[
|
|
|
96eb28 |
- ('objectClass', [b'top', b'inetOrgPerson', b'posixAccount']),
|
|
|
96eb28 |
+ ('objectClass', [b'top', b'inetOrgPerson',
|
|
|
96eb28 |
+ b'posixAccount', b'ldapPublicKey']),
|
|
|
96eb28 |
('cn', [uidNumber if cn is None else cn.encode('utf-8')]),
|
|
|
96eb28 |
('sn', [b'User' if sn is None else sn.encode('utf-8')]),
|
|
|
96eb28 |
('uidNumber', [uidNumber]),
|
|
|
96eb28 |
@@ -51,6 +53,9 @@ def user(base_dn, uid, uidNumber, gidNumber,
|
|
|
96eb28 |
)
|
|
|
96eb28 |
if gecos is not None:
|
|
|
96eb28 |
user[1].append(('gecos', [gecos.encode('utf-8')]))
|
|
|
96eb28 |
+ if len(sshPubKey) > 0:
|
|
|
96eb28 |
+ pubkeys = [key.encode('utf-8') for key in sshPubKey]
|
|
|
96eb28 |
+ user[1].append(('sshPublicKey', pubkeys))
|
|
|
96eb28 |
return user
|
|
|
96eb28 |
|
|
|
96eb28 |
|
|
|
96eb28 |
@@ -118,7 +123,8 @@ class List(list):
|
|
|
96eb28 |
homeDirectory=None,
|
|
|
96eb28 |
loginShell=None,
|
|
|
96eb28 |
cn=None,
|
|
|
96eb28 |
- sn=None):
|
|
|
96eb28 |
+ sn=None,
|
|
|
96eb28 |
+ sshPubKey=()):
|
|
|
96eb28 |
"""Add an RFC2307(bis) user add-modlist."""
|
|
|
96eb28 |
self.append(user(base_dn or self.base_dn,
|
|
|
96eb28 |
uid, uidNumber, gidNumber,
|
|
|
96eb28 |
@@ -127,7 +133,8 @@ class List(list):
|
|
|
96eb28 |
homeDirectory=homeDirectory,
|
|
|
96eb28 |
loginShell=loginShell,
|
|
|
96eb28 |
cn=cn,
|
|
|
96eb28 |
- sn=sn))
|
|
|
96eb28 |
+ sn=sn,
|
|
|
96eb28 |
+ sshPubKey=sshPubKey))
|
|
|
96eb28 |
|
|
|
96eb28 |
def add_group(self, cn, gidNumber, member_uids=[],
|
|
|
96eb28 |
base_dn=None):
|
|
|
96eb28 |
--
|
|
|
ca1eb8 |
2.17.1
|
|
|
96eb28 |
|