From 9054dce4b51d41aacf2438bf994b3288165a7c38 Mon Sep 17 00:00:00 2001 From: Amita Sharma Date: Mon, 9 Oct 2017 19:42:44 +0530 Subject: [PATCH] Issue 49381 - Refactor filter test suite docstrings Description: We need to have properly formatted and detailed docstrings in all existing test suites. Filter test suite is modified in this commit. https://pagure.io/389-ds-base/issue/49381 Reviewed by: ? --- dirsrvtests/tests/suites/filter/filter_logic.py | 200 +++++++++++++++++++++ dirsrvtests/tests/suites/filter/filter_test.py | 21 +++ .../suites/filter/rfc3673_all_oper_attrs_test.py | 28 +-- 3 files changed, 239 insertions(+), 10 deletions(-) diff --git a/dirsrvtests/tests/suites/filter/filter_logic.py b/dirsrvtests/tests/suites/filter/filter_logic.py index fda86a5..e448fa9 100644 --- a/dirsrvtests/tests/suites/filter/filter_logic.py +++ b/dirsrvtests/tests/suites/filter/filter_logic.py @@ -93,6 +93,24 @@ def test_filter_logic_not_eq(topology_st_f): # More not cases? def test_filter_logic_range(topology_st_f): + '''Test filter logic with range + + :id: cc7c25f0-6a6e-465b-8d32-7fcc1aec84ee + :setup: Standalone instance with 20 test users added + from uid=user0 to uid=user20 + :steps: + 1. Search for test users with filter (uid>=user5) + 2. Search for test users with filter (uid<=user4) + 3. Search for test users with filter (uid>=ZZZZ) + 4. Search for test users with filter (uid<=aaaa) + :expectedresults: + 1. There should be 5 users listed from USER5_DN to USER9_DN + 2. There should be 15 users listed from USER0_DN to USER4_DN + and from USER10_DN to USER19_DN + 3. There should not be any user listed + 4. There should not be any user listed + ''' + ### REMEMBER: user10 is less than user5 because it's strcmp!!! _check_filter(topology_st_f, '(uid>=user5)', 5, [ USER5_DN, USER6_DN, USER7_DN, USER8_DN, USER9_DN, @@ -106,6 +124,24 @@ def test_filter_logic_range(topology_st_f): _check_filter(topology_st_f, '(uid<=aaaa)', 0, []) def test_filter_logic_and_eq(topology_st_f): + '''Test filter logic with & operator + + :id: 4721fd7c-8d0b-43e6-b2e8-a5bac7674f99 + :setup: Standalone instance with 20 test users added + from uid=user0 to uid=user20 + :steps: + 1. Search for test users with filter (&(uid=user0)(cn=user0)) + 2. Search for test users with filter (&(uid=user0)(cn=user1)) + 3. Search for test users with filter (&(uid=user0)(cn=user0)(sn=0)) + 4. Search for test users with filter (&(uid=user0)(cn=user1)(sn=0)) + 5. Search for test users with filter (&(uid=user0)(cn=user0)(sn=1)) + :expectedresults: + 1. There should be 1 user listed i.e. USER0_DN + 2. There should not be any user listed + 3. There should be 1 user listed i.e. USER0_DN + 4. There should not be any user listed + 5. There should not be any user listed + ''' _check_filter(topology_st_f, '(&(uid=user0)(cn=user0))', 1, [USER0_DN]) _check_filter(topology_st_f, '(&(uid=user0)(cn=user1))', 0, []) _check_filter(topology_st_f, '(&(uid=user0)(cn=user0)(sn=0))', 1, [USER0_DN]) @@ -113,15 +149,55 @@ def test_filter_logic_and_eq(topology_st_f): _check_filter(topology_st_f, '(&(uid=user0)(cn=user0)(sn=1))', 0, []) def test_filter_logic_and_range(topology_st_f): + '''Test filter logic with range + + :id: 617e6290-866e-4b5d-a300-d8f1715ad052 + :setup: Standalone instance with 20 test users added + from uid=user0 to uid=user20 + :steps: + 1. Search for test users with filter (&(uid>=user5)(cn<=user7)) + :expectedresults: + 1. There should be 3 users listed i.e. USER5_DN to USER7_DN + ''' _check_filter(topology_st_f, '(&(uid>=user5)(cn<=user7))', 3, [ USER5_DN, USER6_DN, USER7_DN ]) def test_filter_logic_and_allid_shortcut(topology_st_f): + '''Test filter logic with & operators and shortcuts + + :id: f4784752-d269-4ceb-aada-fafe0a5fc14c + :setup: Standalone instance with 20 test users added + from uid=user0 to uid=user20 + :steps: + 1. Search for test users with filter (&(objectClass=*)(uid=user0)(cn=user0)) + 2. Search for test users with filter (&(uid=user0)(cn=user0)(objectClass=*)) + :expectedresults: + 1. There should be 1 user listed i.e. USER0_DN + 2. There should be 1 user listed i.e. USER0_DN + ''' _check_filter(topology_st_f, '(&(objectClass=*)(uid=user0)(cn=user0))', 1, [USER0_DN]) _check_filter(topology_st_f, '(&(uid=user0)(cn=user0)(objectClass=*))', 1, [USER0_DN]) def test_filter_logic_or_eq(topology_st_f): + '''Test filter logic + + :id: a23a4fc9-0f5c-49ce-b1f7-6ac10bcd7763 + :setup: Standalone instance with 20 test users added + from uid=user0 to uid=user20 + :steps: + 1. Search for test users with filter (|(uid=user0)(cn=user0)) + 2. Search for test users with filter (|(uid=user0)(uid=user1)) + 3. Search for test users with filter (|(uid=user0)(cn=user0)(sn=0)) + 4. Search for test users with filter (|(uid=user0)(uid=user1)(sn=0)) + 5. Search for test users with filter (|(uid=user0)(uid=user1)(uid=user2)) + :expectedresults: + 1. There should be 1 user listed i.e. USER0_DN + 2. There should be 2 users listed i.e. USER0_DN and USER1_DN + 3. There should be 1 user listed i.e. USER0_DN + 4. There should be 2 users listed i.e. USER0_DN and USER1_DN + 5. There should be 3 users listed i.e. USER0_DN to USER2_DN + ''' _check_filter(topology_st_f, '(|(uid=user0)(cn=user0))', 1, [USER0_DN]) _check_filter(topology_st_f, '(|(uid=user0)(uid=user1))', 2, [USER0_DN, USER1_DN]) _check_filter(topology_st_f, '(|(uid=user0)(cn=user0)(sn=0))', 1, [USER0_DN]) @@ -129,6 +205,18 @@ def test_filter_logic_or_eq(topology_st_f): _check_filter(topology_st_f, '(|(uid=user0)(uid=user1)(uid=user2))', 3, [USER0_DN, USER1_DN, USER2_DN]) def test_filter_logic_and_not_eq(topology_st_f): + '''Test filter logic with not equal to operator + + :id: bd00cb2b-35bb-49c0-8387-f60a6ada7c87 + :setup: Standalone instance with 20 test users added + from uid=user0 to uid=user20 + :steps: + 1. Search for test users with filter (&(uid=user0)(!(cn=user0))) + 2. Search for test users with filter (&(uid=*)(!(uid=user0))) + :expectedresults: + 1. There should be no users listed + 2. There should be 19 users listed i.e. USER1_DN to USER19_DN + ''' _check_filter(topology_st_f, '(&(uid=user0)(!(cn=user0)))', 0, []) _check_filter(topology_st_f, '(&(uid=*)(!(uid=user0)))', 19, [ USER1_DN, USER2_DN, USER3_DN, USER4_DN, USER5_DN, @@ -138,6 +226,16 @@ def test_filter_logic_and_not_eq(topology_st_f): ]) def test_filter_logic_or_not_eq(topology_st_f): + '''Test filter logic with OR and NOT operators + + :id: 8f62f339-72c9-49e4-8126-b2a14e61b9c0 + :setup: Standalone instance with 20 test users added + from uid=user0 to uid=user20 + :steps: + 1. Search for test users with filter (|(!(uid=user0))(!(uid=user1))) + :expectedresults: + 1. There should be 20 users listed i.e. USER0_DN to USER19_DN + ''' _check_filter(topology_st_f, '(|(!(uid=user0))(!(uid=user1)))', 20, [ USER0_DN, USER1_DN, USER2_DN, USER3_DN, USER4_DN, USER5_DN, USER6_DN, USER7_DN, USER8_DN, USER9_DN, @@ -146,6 +244,28 @@ def test_filter_logic_or_not_eq(topology_st_f): ]) def test_filter_logic_and_range(topology_st_f): + '''Test filter logic with range + + :id: 8e5a0e2a-4ee1-4cd7-b5ec-90ad4d3ace64 + :setup: Standalone instance with 20 test users added + from uid=user0 to uid=user20 + :steps: + 1. Search for test users with filter (&(uid>=user5)(uid=user6)) + 2. Search for test users with filter (&(uid>=user5)(uid=user0)) + 3. Search for test users with filter (&(uid>=user5)(uid=user6)(sn=6)) + 4. Search for test users with filter (&(uid>=user5)(uid=user0)(sn=0)) + 5. Search for test users with filter (&(uid>=user5)(uid=user0)(sn=1)) + 6. Search for test users with filter (&(uid>=user5)(uid>=user6)) + 7. Search for test users with filter (&(uid>=user5)(uid>=user6)(uid>=user7)) + :expectedresults: + 1. There should be 1 user listed i.e. USER6_DN + 2. There should be no users listed + 3. There should be 1 user listed i.e. USER6_DN + 4. There should be no users listed + 5. There should be no users listed + 6. There should be 4 users listed i.e. USER6_DN to USER9_DN + 7. There should be 3 users listed i.e. USER7_DN to USER9_DN + ''' # These all hit shortcut cases. _check_filter(topology_st_f, '(&(uid>=user5)(uid=user6))', 1, [USER6_DN]) _check_filter(topology_st_f, '(&(uid>=user5)(uid=user0))', 0, []) @@ -162,6 +282,18 @@ def test_filter_logic_and_range(topology_st_f): def test_filter_logic_or_range(topology_st_f): + '''Test filter logic with range + + :id: bc413e74-667a-48b0-8fbd-e9b7d18a01e4 + :setup: Standalone instance with 20 test users added + from uid=user0 to uid=user20 + :steps: + 1. Search for test users with filter (|(uid>=user5)(uid=user6)) + 2. Search for test users with filter (|(uid>=user5)(uid=user0)) + :expectedresults: + 1. There should be 5 users listed i.e. USER5_DN to USER9_DN + 2. There should be 6 users listed i.e. USER5_DN to USER9_DN and USER0_DN + ''' _check_filter(topology_st_f, '(|(uid>=user5)(uid=user6))', 5, [ USER5_DN, USER6_DN, USER7_DN, USER8_DN, USER9_DN, ]) @@ -171,12 +303,46 @@ def test_filter_logic_or_range(topology_st_f): ]) def test_filter_logic_and_and_eq(topology_st_f): + '''Test filter logic with AND and eq operators + + :id: 5c66eb38-d01f-459e-81e4-d335f97211c7 + :setup: Standalone instance with 20 test users added + from uid=user0 to uid=user20 + :steps: + 1. Search for test users with filter (&(&(uid=user0)(sn=0))(cn=user0)) + 2. Search for test users with filter (&(&(uid=user1)(sn=0))(cn=user0)) + 3. Search for test users with filter (&(&(uid=user0)(sn=1))(cn=user0)) + 4. Search for test users with filter (&(&(uid=user0)(sn=0))(cn=user1)) + :expectedresults: + 1. There should be 1 user listed i.e. USER0_DN + 2. There should be no users listed + 3. There should be no users listed + 4. There should be no users listed + ''' _check_filter(topology_st_f, '(&(&(uid=user0)(sn=0))(cn=user0))', 1, [USER0_DN]) _check_filter(topology_st_f, '(&(&(uid=user1)(sn=0))(cn=user0))', 0, []) _check_filter(topology_st_f, '(&(&(uid=user0)(sn=1))(cn=user0))', 0, []) _check_filter(topology_st_f, '(&(&(uid=user0)(sn=0))(cn=user1))', 0, []) def test_filter_logic_or_or_eq(topology_st_f): + '''Test filter logic with AND and eq operators + + :id: 0cab4bbd-637c-419d-8069-ad5463ecaa75 + :setup: Standalone instance with 20 test users added + from uid=user0 to uid=user20 + :steps: + 1. Search for test users with filter (|(|(uid=user0)(sn=0))(cn=user0)) + 2. Search for test users with filter (|(|(uid=user1)(sn=0))(cn=user0)) + 3. Search for test users with filter (|(|(uid=user0)(sn=1))(cn=user0)) + 4. Search for test users with filter (|(|(uid=user0)(sn=0))(cn=user1)) + 5. Search for test users with filter (|(|(uid=user0)(sn=1))(cn=user2)) + :expectedresults: + 1. There should be 1 user listed i.e. USER0_DN + 2. There should be 2 users listed i.e. USER0_DN, USER1_DN + 3. There should be 2 users listed i.e. USER0_DN, USER1_DN + 4. There should be 2 users listed i.e. USER0_DN, USER1_DN + 5. There should be 3 users listed i.e. USER0_DN, USER1_DN and USER2_DN + ''' _check_filter(topology_st_f, '(|(|(uid=user0)(sn=0))(cn=user0))', 1, [USER0_DN]) _check_filter(topology_st_f, '(|(|(uid=user1)(sn=0))(cn=user0))', 2, [USER0_DN, USER1_DN]) _check_filter(topology_st_f, '(|(|(uid=user0)(sn=1))(cn=user0))', 2, [USER0_DN, USER1_DN]) @@ -184,6 +350,24 @@ def test_filter_logic_or_or_eq(topology_st_f): _check_filter(topology_st_f, '(|(|(uid=user0)(sn=1))(cn=user2))', 3, [USER0_DN, USER1_DN, USER2_DN]) def test_filter_logic_and_or_eq(topology_st_f): + '''Test filter logic with AND and eq operators + + :id: 2ce7cc2e-6058-422d-ac3e-e678decf1cc4 + :setup: Standalone instance with 20 test users added + from uid=user0 to uid=user20 + :steps: + 1. Search for test users with filter (&(|(uid=user0)(sn=0))(cn=user0)) + 2. Search for test users with filter (&(|(uid=user1)(sn=0))(cn=user0)) + 3. Search for test users with filter (&(|(uid=user0)(sn=1))(cn=user0)) + 4. Search for test users with filter (&(|(uid=user0)(sn=0))(cn=user1)) + 5. Search for test users with filter (&(|(uid=user0)(sn=1))(cn=*)) + :expectedresults: + 1. There should be 1 user listed i.e. USER0_DN + 2. There should be 1 user listed i.e. USER0_DN + 3. There should be 1 user listed i.e. USER0_DN + 4. There should be no users listed + 5. There should be 2 users listed i.e. USER0_DN and USER1_DN + ''' _check_filter(topology_st_f, '(&(|(uid=user0)(sn=0))(cn=user0))', 1, [USER0_DN]) _check_filter(topology_st_f, '(&(|(uid=user1)(sn=0))(cn=user0))', 1, [USER0_DN]) _check_filter(topology_st_f, '(&(|(uid=user0)(sn=1))(cn=user0))', 1, [USER0_DN]) @@ -191,6 +375,22 @@ def test_filter_logic_and_or_eq(topology_st_f): _check_filter(topology_st_f, '(&(|(uid=user0)(sn=1))(cn=*))', 2, [USER0_DN, USER1_DN]) def test_filter_logic_or_and_eq(topology_st_f): + '''Test filter logic with AND and eq operators + + :id: ee9fb400-451a-479e-852c-f59b4c937a8d + :setup: Standalone instance with 20 test users added + from uid=user0 to uid=user20 + :steps: + 1. Search for test users with filter (|(&(uid=user0)(sn=0))(uid=user0)) + 2. Search for test users with filter (|(&(uid=user1)(sn=2))(uid=user0)) + 3. Search for test users with filter (|(&(uid=user0)(sn=1))(uid=user0)) + 4. Search for test users with filter (|(&(uid=user1)(sn=1))(uid=user0)) + :expectedresults: + 1. There should be 1 user listed i.e. USER0_DN + 2. There should be 1 user listed i.e. USER0_DN + 3. There should be 1 user listed i.e. USER0_DN + 4. There should be 2 user listed i.e. USER0_DN and USER1_DN + ''' _check_filter(topology_st_f, '(|(&(uid=user0)(sn=0))(uid=user0))', 1, [USER0_DN]) _check_filter(topology_st_f, '(|(&(uid=user1)(sn=2))(uid=user0))', 1, [USER0_DN]) _check_filter(topology_st_f, '(|(&(uid=user0)(sn=1))(uid=user0))', 1, [USER0_DN]) diff --git a/dirsrvtests/tests/suites/filter/filter_test.py b/dirsrvtests/tests/suites/filter/filter_test.py index 280db68..3469ff5 100644 --- a/dirsrvtests/tests/suites/filter/filter_test.py +++ b/dirsrvtests/tests/suites/filter/filter_test.py @@ -20,6 +20,18 @@ log = logging.getLogger(__name__) def test_filter_escaped(topology_st): ''' Test we can search for an '*' in a attribute value. + + :id: 5c9aa40c-c641-4603-bce3-b19f4c1f2031 + :setup: Standalone instance + :steps: + 1. Add a test user with an '*' in its attribute value + i.e. 'cn=test * me' + 2. Add another similar test user without '*' in its attribute value + 3. Search test user using search filter "cn=*\**" + :expectedresults: + 1. This should pass + 2. This should pass + 3. Test user with 'cn=test * me' only, should be listed ''' log.info('Running test_filter_escaped...') @@ -65,6 +77,15 @@ def test_filter_search_original_attrs(topology_st): ''' Search and request attributes with extra characters. The returned entry should not have these extra characters: "objectclass EXTRA" + + :id: d30d8a1c-84ac-47ba-95f9-41e3453fbf3a + :setup: Standalone instance + :steps: + 1. Execute a search operation for attributes with extra characters + 2. Check the search result have these extra characters or not + :expectedresults: + 1. Search should pass + 2. Search result should not have these extra characters attribute ''' log.info('Running test_filter_search_original_attrs...') diff --git a/dirsrvtests/tests/suites/filter/rfc3673_all_oper_attrs_test.py b/dirsrvtests/tests/suites/filter/rfc3673_all_oper_attrs_test.py index 571e31d..425a109 100644 --- a/dirsrvtests/tests/suites/filter/rfc3673_all_oper_attrs_test.py +++ b/dirsrvtests/tests/suites/filter/rfc3673_all_oper_attrs_test.py @@ -98,11 +98,12 @@ def test_supported_features(topology_st): """Verify that OID 1.3.6.1.4.1.4203.1.5.1 is published in the supportedFeatures [RFC3674] attribute in the rootDSE. - :ID: 441b3f1f-a24b-4943-aa65-7edce460abbf - :feature: Filter + :id: 441b3f1f-a24b-4943-aa65-7edce460abbf :setup: Standalone instance - :steps: 1. Search for 'supportedFeatures' at rootDSE - :expectedresults: Value 1.3.6.1.4.1.4203.1.5.1 is presented + :steps: + 1. Search for 'supportedFeatures' at rootDSE + :expectedresults: + 1. Value 1.3.6.1.4.1.4203.1.5.1 is presented """ entries = topology_st.standalone.search_s('', ldap.SCOPE_BASE, @@ -122,14 +123,21 @@ def test_search_basic(topology_st, test_user, user_aci, add_attr, by a Search Request [RFC2251] with '+' (ASCII 43) filter. Please see: https://tools.ietf.org/html/rfc3673 - :ID: 14c66bc2-28e1-4f5f-893e-508e0f720f8c - :feature: Filter + :id: 14c66bc2-28e1-4f5f-893e-508e0f720f8c :setup: Standalone instance, test user for binding, deny one attribute aci for that user - :steps: 1. Bind as regular user or Directory Manager - 2. Search with '+' filter and with additionaly - 'objectClass' and '*' attrs too - :expectedresults: All expected values were returned, not more + :steps: + 1. Bind as regular user or Directory Manager + 2. Search with '+' filter and with additionally + 'objectClass' and '*' attributes too + 3. Check attributes listed contain both operational + and non-operational attributes for '*' attributes + search + :expectedresults: + 1. Bind should be successful + 2. All expected values of attributes should be returned + as per the parametrization done + 3. It should pass """ if regular_user: -- 2.9.4