#50820 Issue: 50690 - Port Password Storage test cases from TET to python3 part 2
Closed 3 years ago by spichugi. Opened 4 years ago by aborah.
aborah/389-ds-base pwp_storage2  into  master

@@ -0,0 +1,104 @@ 

+ # --- BEGIN COPYRIGHT BLOCK ---

+ # Copyright (C) 2020 Red Hat, Inc.

+ # All rights reserved.

+ #

+ # License: GPL (version 3 or any later version).

+ # See LICENSE for details.

+ # --- END COPYRIGHT BLOCK ----

+ 

+ 

+ """

+ This file contains the test for password storage scheme

+ """

+ 

+ import os

+ import pytest

+ import ldap

+ 

+ from lib389.topologies import topology_st as topo

+ from lib389.idm.user import UserAccounts

+ from lib389._constants import DEFAULT_SUFFIX

+ from lib389.config import Config

+ from password_plugins import SHAPlugin

+ 

+ pytestmark = pytest.mark.tier1

+ 

+ 

+ def change_config_create_user(topo, field_value):

+     """

+     Will change passwordStorageScheme

+     """

+     Config(topo.standalone).replace("passwordStorageScheme", field_value)

+     user = UserAccounts(topo.standalone, DEFAULT_SUFFIX).create_test_user()

+     user.set('userpassword', 'HayItsMEAnuj')

+     return user

+ 

+ 

+ def test_clear_text(topo):

+     """Check clear Scheme

+ 

+     :id: 66219b92-33c1-11ea-ac46-8c16451d917b

+     :setup: Standalone

+     :steps:

+         1. Create a user without password

+         2. Update the user with a password

+         3. Check user can be bind

+     :expected results:

+         1. Pass

+         2. Pass

+         3. Pass

+     """

+     user = change_config_create_user(topo, "CLEAR")

+     conn = user.bind("HayItsMEAnuj")

+     user.delete()

+ 

+ 

+ def test_sha(topo):

+     """Check SHA Scheme

+ 

+     :id: 5c514112-33c1-11ea-a298-8c16451d917b

+     :setup: Standalone

+     :steps:

+         1. Disable SHA Plugin

+         2. Activate SHA Plugin

+         3. Enable SHA Plugin

+     :expected results:

+         1. Pass

+         2. Pass

+         3. Pass

+     """

+     sha = SHAPlugin(topo.standalone)

+     assert sha.status()

+     sha.disable()

+     assert not sha.status()

+     topo.standalone.restart()

+     with pytest.raises(ldap.OPERATIONS_ERROR):

+         Config(topo.standalone).replace("passwordStorageScheme", "SHA")

+     Config(topo.standalone).replace("passwordStorageScheme", "CLEAR")

+     sha.enable()

+     assert sha.status()

+ 

+ 

+ def test_crypt(topo):

+     """Check CRYPT scheme

+ 

+     :id: 618207fc-33c1-11ea-93ce-8c16451d917b

+     :setup: Standalone

+     :steps:

+         1. Create a user without password

+         2. Update the user with a password

+         3. Check the encryption of the pwd

+     :expected results:

+         1. Pass

+         2. Pass

+         3. Pass

+     """

+     user = change_config_create_user(topo, "CRYPT")

+     assert '{' + "crypt" + '}' in user.get_attr_val_utf8('userpassword').lower()

+     user.set("userpassword", "AnujBorah")

+     assert '{' + "crypt" + '}' in user.get_attr_val_utf8('userpassword').lower()

+ 

+ 

+ if __name__ == "__main__":

+     CURRENT_FILE = os.path.realpath(__file__)

+     pytest.main("-s -v %s" % CURRENT_FILE)

Port Password Storage test cases from TET to python3 part 2

Relates: https://pagure.io/389-ds-base/issue/50690

Author: aborah

Reviewed by: ???

Pull-Request has been closed by aborah

4 years ago

389-ds-base is moving from Pagure to Github. This means that new issues and pull requests
will be accepted only in 389-ds-base's github repository.

This pull request has been cloned to Github as issue and is available here:
- https://github.com/389ds/389-ds-base/issues/3874

If you want to continue to work on the PR, please navigate to the github issue,
download the patch from the attachments and file a new pull request.

Thank you for understanding. We apologize for all inconvenience.

Pull-Request has been closed by spichugi

3 years ago
Metadata