| |
@@ -16,6 +16,7 @@
|
| |
from lib389.idm.user import UserAccounts, TEST_USER_PROPERTIES
|
| |
from lib389.backend import Backends
|
| |
from lib389.idm.domain import Domain
|
| |
+ from lib389.encrypted_attributes import EncryptedAttrs
|
| |
|
| |
pytestmark = pytest.mark.tier1
|
| |
|
| |
@@ -37,8 +38,7 @@
|
| |
log.info("Enables attribute encryption")
|
| |
backends = Backends(topo.standalone)
|
| |
backend = backends.list()[0]
|
| |
- encrypt_attrs = backend.get_encrypted_attrs()
|
| |
-
|
| |
+ encrypt_attrs = EncryptedAttrs(topo.standalone, basedn='cn=encrypted attributes,{}'.format(backend.dn))
|
| |
log.info("Enables attribute encryption for employeeNumber and telephoneNumber")
|
| |
emp_num_encrypt = encrypt_attrs.create(properties={'cn': 'employeeNumber', 'nsEncryptionAlgorithm': 'AES'})
|
| |
telephone_encrypt = encrypt_attrs.create(properties={'cn': 'telephoneNumber', 'nsEncryptionAlgorithm': '3DES'})
|
| |
@@ -86,7 +86,7 @@
|
| |
log.info("Extracting values of cn from the list of objects in encrypt_attrs")
|
| |
log.info("And appending the cn values in a list")
|
| |
enc_attrs_cns = []
|
| |
- for enc_attr in encrypt_attrs.list():
|
| |
+ for enc_attr in encrypt_attrs:
|
| |
enc_attrs_cns.append(enc_attr.rdn)
|
| |
|
| |
log.info("Check employeenumber encryption is enabled")
|
| |
@@ -149,7 +149,7 @@
|
| |
# Offline export
|
| |
topo.standalone.stop()
|
| |
if not topo.standalone.ldif2db(bename=DEFAULT_BENAME, suffixes=(DEFAULT_SUFFIX,),
|
| |
- excludeSuffixes=None, encrypt=False, import_file=import_ldif):
|
| |
+ excludeSuffixes=None, encrypt=False, import_file=import_ldif):
|
| |
log.fatal('Failed to run offline ldif2db')
|
| |
assert False
|
| |
topo.standalone.start()
|
| |
@@ -160,7 +160,6 @@
|
| |
assert user.present("telephoneNumber")
|
| |
|
| |
|
| |
-
|
| |
def test_export_import_plaintext(topo, enable_user_attr_encryption):
|
| |
"""Configure attribute encryption, store some data, check that we can export the plain text
|
| |
:id: b171e215-0456-48a5-245f-c21abc40fc2d
|
| |
@@ -209,7 +208,7 @@
|
| |
# Offline export
|
| |
topo.standalone.stop()
|
| |
if not topo.standalone.ldif2db(bename=DEFAULT_BENAME, suffixes=(DEFAULT_SUFFIX,),
|
| |
- excludeSuffixes=None, encrypt=True, import_file=import_ldif):
|
| |
+ excludeSuffixes=None, encrypt=True, import_file=import_ldif):
|
| |
log.fatal('Failed to run offline ldif2db')
|
| |
assert False
|
| |
topo.standalone.start()
|
| |
@@ -288,8 +287,9 @@
|
| |
|
| |
# Create backends
|
| |
backends = Backends(topo.standalone)
|
| |
+ backend = backends.list()[0]
|
| |
test_backend1 = backends.create(properties={'cn': test_db1,
|
| |
- 'nsslapd-suffix': test_suffix1})
|
| |
+ 'nsslapd-suffix': test_suffix1})
|
| |
test_backend2 = backends.create(properties={'cn': test_db2,
|
| |
'nsslapd-suffix': test_suffix2})
|
| |
|
| |
@@ -300,14 +300,14 @@
|
| |
test2 = suffix2.create(properties={'dc': 'test2'})
|
| |
|
| |
log.info("Enables attribute encryption for telephoneNumber in test_backend1")
|
| |
- backend1_encrypt_attrs = test_backend1.get_encrypted_attrs()
|
| |
+ backend1_encrypt_attrs = EncryptedAttrs(topo.standalone, basedn='cn=encrypted attributes,{}'.format(test_backend1.dn))
|
| |
b1_encrypt = backend1_encrypt_attrs.create(properties={'cn': 'telephoneNumber',
|
| |
'nsEncryptionAlgorithm': 'AES'})
|
| |
|
| |
log.info("Enables attribute encryption for employeeNumber in test_backend2")
|
| |
- backend2_encrypt_attrs = test_backend2.get_encrypted_attrs()
|
| |
+ backend2_encrypt_attrs = EncryptedAttrs(topo.standalone, basedn='cn=encrypted attributes,{}'.format(test_backend2.dn))
|
| |
b2_encrypt = backend2_encrypt_attrs.create(properties={'cn': 'employeeNumber',
|
| |
- 'nsEncryptionAlgorithm': 'AES'})
|
| |
+ 'nsEncryptionAlgorithm': 'AES'})
|
| |
|
| |
log.info("Add a test user with encrypted attributes in both backends")
|
| |
users = UserAccounts(topo.standalone, test1.dn, None)
|
| |
@@ -386,7 +386,7 @@
|
| |
# Create backends
|
| |
backends = Backends(topo.standalone)
|
| |
test_backend1 = backends.create(properties={'cn': test_db1,
|
| |
- 'nsslapd-suffix': test_suffix1})
|
| |
+ 'nsslapd-suffix': test_suffix1})
|
| |
test_backend2 = backends.create(properties={'cn': test_db2,
|
| |
'nsslapd-suffix': test_suffix2})
|
| |
|
| |
@@ -397,7 +397,7 @@
|
| |
test2 = suffix2.create(properties={'dc': 'test2'})
|
| |
|
| |
log.info("Enables attribute encryption for telephoneNumber in test_backend1")
|
| |
- backend1_encrypt_attrs = test_backend1.get_encrypted_attrs()
|
| |
+ backend1_encrypt_attrs = EncryptedAttrs(topo.standalone, basedn='cn=encrypted attributes,{}'.format(test_backend1.dn))
|
| |
b1_encrypt = backend1_encrypt_attrs.create(properties={'cn': 'telephoneNumber',
|
| |
'nsEncryptionAlgorithm': 'AES'})
|
| |
|
| |
@@ -451,5 +451,3 @@
|
| |
# -s for DEBUG mode
|
| |
CURRENT_FILE = os.path.realpath(__file__)
|
| |
pytest.main("-s %s" % CURRENT_FILE)
|
| |
-
|
| |
-
|
| |
Description: Fixed the issue by removing the old function of creating an encrypted attribute
with a new one.
https://pagure.io/389-ds-base/issue/50220
Reviewed by: ??