Browse Source

Issue 49381 - Add docstrings to ds_logs, gssapi_repl, betxn

Description: Refactor docstrings of ds_logs, gssapi_repl and betxn test
suites. Also change test_betxn_init to fixure function.
And add pytest.mark.bz numbers.

https://pagure.io/389-ds-base/issue/49381

Reviewed by: Simon Pichugin
Amita Sharma 8 years ago
parent
commit
786b00eb68

+ 66 - 15
dirsrvtests/tests/suites/betxns/betxn_test.py

@@ -18,8 +18,9 @@ logging.getLogger(__name__).setLevel(logging.DEBUG)
 log = logging.getLogger(__name__)
 log = logging.getLogger(__name__)
 
 
 
 
-def test_betxn_init(topology_st):
-    # First enable dynamic plugins - makes plugin testing much easier
[email protected](scope='module')
+def dynamic_plugins(topology_st):
+    """Enable dynamic plugins - makes plugin testing much easier"""
     try:
     try:
         topology_st.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, 'nsslapd-dynamic-plugins', 'on')])
         topology_st.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, 'nsslapd-dynamic-plugins', 'on')])
     except ldap.LDAPError as e:
     except ldap.LDAPError as e:
@@ -27,10 +28,26 @@ def test_betxn_init(topology_st):
         assert False
         assert False
 
 
 
 
-def test_betxt_7bit(topology_st):
-    '''
-    Test that the 7-bit plugin correctly rejects an invalid update
-    '''
+def test_betxt_7bit(topology_st, dynamic_plugins):
+    """Test that the 7-bit plugin correctly rejects an invalid update
+
+    :id: 9e2ab27b-eda9-4cd9-9968-a1a8513210fd
+
+    :setup: Standalone instance and enabled dynamic plugins
+
+    :steps: 1. Enable PLUGIN_7_BIT_CHECK to "ON"
+            2. Add test user
+            3. Try to Modify test user's RDN to have 8 bit RDN
+            4. Execute search operation for new 8 bit RDN
+            5. Remove the test user for cleanup
+
+    :expectedresults:
+            1. PLUGIN_7_BIT_CHECK should be ON
+            2. Test users should be added
+            3. Modify RDN for test user should FAIL
+            4. Search operation should FAIL
+            5. Test user should be removed
+    """
 
 
     log.info('Running test_betxt_7bit...')
     log.info('Running test_betxt_7bit...')
 
 
@@ -67,7 +84,7 @@ def test_betxt_7bit(topology_st):
             log.fatal('test_betxt_7bit: Incorrectly found the entry using the invalid RDN')
             log.fatal('test_betxt_7bit: Incorrectly found the entry using the invalid RDN')
             assert False
             assert False
     except ldap.LDAPError as e:
     except ldap.LDAPError as e:
-        log.fatal('Error whiles earching for test entry: ' + e.message['desc'])
+        log.fatal('Error while searching for test entry: ' + e.message['desc'])
         assert False
         assert False
 
 
     #
     #
@@ -82,13 +99,27 @@ def test_betxt_7bit(topology_st):
     log.info('test_betxt_7bit: PASSED')
     log.info('test_betxt_7bit: PASSED')
 
 
 
 
-def test_betxn_attr_uniqueness(topology_st):
-    '''
-    Test that we can not add two entries that have the same attr value that is
-    defined by the plugin.
-    '''
+def test_betxn_attr_uniqueness(topology_st, dynamic_plugins):
+    """Test that we can not add two entries that have the same attr value that is
+    defined by the plugin
+
+    :id: 42aeb41c-fbb5-4bc6-a97b-56274034d29f
+
+    :setup: Standalone instance and enabled dynamic plugins
 
 
-    log.info('Running test_betxn_attr_uniqueness...')
+    :steps: 1. Enable PLUGIN_ATTR_UNIQUENESS plugin as "ON"
+            2. Add a test user
+            3. Add another test user having duplicate uid as previous one
+            4. Cleanup - disable PLUGIN_ATTR_UNIQUENESS plugin as "OFF"
+            5. Cleanup - remove test user entry
+
+    :expectedresults:
+            1. PLUGIN_ATTR_UNIQUENESS plugin should be ON
+            2. Test user should be added
+            3. Add operation should FAIL
+            4. PLUGIN_ATTR_UNIQUENESS plugin should be "OFF"
+            5. Test user entry should be removed
+    """
 
 
     USER1_DN = 'uid=test_entry1,' + DEFAULT_SUFFIX
     USER1_DN = 'uid=test_entry1,' + DEFAULT_SUFFIX
     USER2_DN = 'uid=test_entry2,' + DEFAULT_SUFFIX
     USER2_DN = 'uid=test_entry2,' + DEFAULT_SUFFIX
@@ -107,7 +138,7 @@ def test_betxn_attr_uniqueness(topology_st):
                   USER1_DN + ', error ' + e.message['desc'])
                   USER1_DN + ', error ' + e.message['desc'])
         assert False
         assert False
 
 
-    # Add the second entry with a dupliate uid
+    # Add the second entry with a duplicate uid
     try:
     try:
         topology_st.standalone.add_s(Entry((USER2_DN, {'objectclass': "top extensibleObject".split(),
         topology_st.standalone.add_s(Entry((USER2_DN, {'objectclass': "top extensibleObject".split(),
                                                        'sn': '2',
                                                        'sn': '2',
@@ -136,7 +167,27 @@ def test_betxn_attr_uniqueness(topology_st):
     log.info('test_betxn_attr_uniqueness: PASSED')
     log.info('test_betxn_attr_uniqueness: PASSED')
 
 
 
 
-def test_betxn_memberof(topology_st):
+def test_betxn_memberof(topology_st, dynamic_plugins):
+    """Test PLUGIN_MEMBER_OF plugin
+
+    :id: 70d0b96e-b693-4bf7-bbf5-102a66ac5993
+
+    :setup: Standalone instance and enabled dynamic plugins
+
+    :steps: 1. Enable and configure memberOf plugin
+            2. Set memberofgroupattr="member" and memberofAutoAddOC="referral"
+            3. Add two test groups - group1 and group2
+            4. Add group2 to group1
+            5. Add group1 to group2
+
+    :expectedresults:
+            1. memberOf plugin plugin should be ON
+            2. Set memberofgroupattr="member" and memberofAutoAddOC="referral" should PASS
+            3. Add operation should PASS
+            4. Add operation should FAIL
+            5. Add operation should FAIL
+    """
+
     ENTRY1_DN = 'cn=group1,' + DEFAULT_SUFFIX
     ENTRY1_DN = 'cn=group1,' + DEFAULT_SUFFIX
     ENTRY2_DN = 'cn=group2,' + DEFAULT_SUFFIX
     ENTRY2_DN = 'cn=group2,' + DEFAULT_SUFFIX
     PLUGIN_DN = 'cn=' + PLUGIN_MEMBER_OF + ',cn=plugins,cn=config'
     PLUGIN_DN = 'cn=' + PLUGIN_MEMBER_OF + ',cn=plugins,cn=config'

+ 77 - 15
dirsrvtests/tests/suites/ds_logs/ds_logs_test.py

@@ -58,13 +58,23 @@ def search_users(topology_st):
         log.fatal('Search failed, error: ' + e.message['desc'])
         log.fatal('Search failed, error: ' + e.message['desc'])
         raise e
         raise e
 
 
-
+@pytest.mark.bz1273549
 def test_check_default(topology_st):
 def test_check_default(topology_st):
-    """Bug 1273549 - Check the default value of nsslapd-logging-hr-timestamps-enabled,
-    it should be ON
-    """
+    """Check the default value of nsslapd-logging-hr-timestamps-enabled,
+     it should be ON
+
+    :id: 2d15002e-9ed3-4796-b0bb-bf04e4e59bd3
+
+    :setup: Standalone instance
+
+    :steps:
+         1. Fetch the value of nsslapd-logging-hr-timestamps-enabled attribute
+         2. Test that the attribute value should be "ON" by default
 
 
-    log.info('Check the default value of nsslapd-logging-hr-timestamps-enabled, it should be ON')
+    :expectedresults:
+         1. Value should be fetched successfully
+         2. Value should be "ON" by default
+    """
 
 
     # Get the default value of nsslapd-logging-hr-timestamps-enabled attribute
     # Get the default value of nsslapd-logging-hr-timestamps-enabled attribute
     default = topology_st.standalone.config.get_attr_val(PLUGIN_TIMESTAMP)
     default = topology_st.standalone.config.get_attr_val(PLUGIN_TIMESTAMP)
@@ -73,19 +83,49 @@ def test_check_default(topology_st):
     assert (default == "on")
     assert (default == "on")
     log.debug(default)
     log.debug(default)
 
 
-
+@pytest.mark.bz1273549
 def test_plugin_set_invalid(topology_st):
 def test_plugin_set_invalid(topology_st):
-    """Bug 1273549 - Try to set some invalid values for the newly added attribute"""
+    """Try to set some invalid values for nsslapd-logging-hr-timestamps-enabled
+    attribute
+
+    :id: c60a68d2-703a-42bf-a5c2-4040736d511a
+
+    :setup: Standalone instance
+
+    :steps:
+         1. Set some "JUNK" value of nsslapd-logging-hr-timestamps-enabled attribute
+
+    :expectedresults:
+         1. There should be an operation error
+    """
 
 
     log.info('test_plugin_set_invalid - Expect to fail with junk value')
     log.info('test_plugin_set_invalid - Expect to fail with junk value')
     with pytest.raises(ldap.OPERATIONS_ERROR):
     with pytest.raises(ldap.OPERATIONS_ERROR):
         result = topology_st.standalone.config.set(PLUGIN_TIMESTAMP, 'JUNK')
         result = topology_st.standalone.config.set(PLUGIN_TIMESTAMP, 'JUNK')
 
 
-
+@pytest.mark.bz1273549
 def test_log_plugin_on(topology_st):
 def test_log_plugin_on(topology_st):
-    """Bug 1273549 - Check access logs for milisecond, when attribute is ON"""
+    """Check access logs for millisecond, when
+    nsslapd-logging-hr-timestamps-enabled=ON
+
+    :id: 65ae4e2a-295f-4222-8d69-12124bc7a872
+
+    :setup: Standalone instance
 
 
-    log.info('Bug 1273549 - Check access logs for milisecond, when attribute is ON')
+    :steps:
+         1. To generate big logs, add 100 test users
+         2. Search users to generate more access logs
+         3. Restart server
+         4. Parse the logs to check the milliseconds got recorded in logs
+
+    :expectedresults:
+         1. Add operation should be successful
+         2. Search operation should be successful
+         3. Server should be restarted successfully
+         4. There should be milliseconds added in the access logs
+    """
+
+    log.info('Bug 1273549 - Check access logs for millisecond, when attribute is ON')
     log.info('perform any ldap operation, which will trigger the logs')
     log.info('perform any ldap operation, which will trigger the logs')
     add_users(topology_st, 100)
     add_users(topology_st, 100)
     search_users(topology_st)
     search_users(topology_st)
@@ -98,19 +138,41 @@ def test_log_plugin_on(topology_st):
     assert len(access_log_lines) > 0
     assert len(access_log_lines) > 0
     assert topology_st.standalone.ds_access_log.match('^\[.+\d{9}.+\].+')
     assert topology_st.standalone.ds_access_log.match('^\[.+\d{9}.+\].+')
 
 
-
+@pytest.mark.bz1273549
 def test_log_plugin_off(topology_st):
 def test_log_plugin_off(topology_st):
-    """Bug 1273549 - Check access logs for missing milisecond, when attribute is OFF"""
+    """Milliseconds should be absent from access logs when
+    nsslapd-logging-hr-timestamps-enabled=OFF
+
+    :id: b3400e46-d940-4574-b399-e3f4b49bc4b5
+
+    :setup: Standalone instance
+
+    :steps:
+         1. Set nsslapd-logging-hr-timestamps-enabled=OFF
+         2. Restart the server
+         3. Delete old access logs
+         4. Do search operations to generate fresh access logs
+         5. Restart the server
+         6. Check access logs
+
+    :expectedresults:
+         1. Attribute nsslapd-logging-hr-timestamps-enabled should be set to "OFF"
+         2. Server should restart
+         3. Access logs should be deleted
+         4. Search operation should PASS
+         5. Server should restart
+         6. There should not be any milliseconds added in the access logs
+    """
 
 
-    log.info('Bug 1273549 - Check access logs for missing milisecond, when attribute is OFF')
+    log.info('Bug 1273549 - Check access logs for missing millisecond, when attribute is OFF')
 
 
-    log.info('test_log_plugin_off - set the configuraton attribute to OFF')
+    log.info('test_log_plugin_off - set the configuration attribute to OFF')
     topology_st.standalone.config.set(PLUGIN_TIMESTAMP, 'OFF')
     topology_st.standalone.config.set(PLUGIN_TIMESTAMP, 'OFF')
 
 
     log.info('Restart the server to flush the logs')
     log.info('Restart the server to flush the logs')
     topology_st.standalone.restart(timeout=10)
     topology_st.standalone.restart(timeout=10)
 
 
-    log.info('test_log_plugin_off - delete the privious access logs')
+    log.info('test_log_plugin_off - delete the previous access logs')
     topology_st.standalone.deleteAccessLogs()
     topology_st.standalone.deleteAccessLogs()
 
 
     # Now generate some fresh logs
     # Now generate some fresh logs

+ 9 - 5
dirsrvtests/tests/suites/ds_logs/regression_test.py

@@ -1,5 +1,5 @@
 # --- BEGIN COPYRIGHT BLOCK ---
 # --- BEGIN COPYRIGHT BLOCK ---
-    # Copyright (C) 2017 Red Hat, Inc.
+# Copyright (C) 2017 Red Hat, Inc.
 # All rights reserved.
 # All rights reserved.
 #
 #
 # License: GPL (version 3 or any later version).
 # License: GPL (version 3 or any later version).
@@ -24,13 +24,15 @@ log = logging.getLogger(__name__)
 @pytest.mark.bz1460718
 @pytest.mark.bz1460718
 @pytest.mark.parametrize("log_level", [(LOG_REPLICA + LOG_DEFAULT), (LOG_ACL + LOG_DEFAULT), (LOG_TRACE + LOG_DEFAULT)])
 @pytest.mark.parametrize("log_level", [(LOG_REPLICA + LOG_DEFAULT), (LOG_ACL + LOG_DEFAULT), (LOG_TRACE + LOG_DEFAULT)])
 def test_default_loglevel_stripped(topo, log_level):
 def test_default_loglevel_stripped(topo, log_level):
-    """ The default log level 16384 is stripped from the log level returned to a client
+    """The default log level 16384 is stripped from the log level returned to a client
 
 
     :id: c300f8f1-aa11-4621-b124-e2be51930a6b
     :id: c300f8f1-aa11-4621-b124-e2be51930a6b
-    :feature: Logging
+
     :setup: Standalone instance
     :setup: Standalone instance
+
     :steps: 1. Change the error log level to the default and custom value.
     :steps: 1. Change the error log level to the default and custom value.
             2. Check if the server returns the new value.
             2. Check if the server returns the new value.
+
     :expectedresults:
     :expectedresults:
             1. Changing the error log level should be successful.
             1. Changing the error log level should be successful.
             2. Server should return the new log level.
             2. Server should return the new log level.
@@ -42,13 +44,15 @@ def test_default_loglevel_stripped(topo, log_level):
 
 
 @pytest.mark.bz1460718
 @pytest.mark.bz1460718
 def test_dse_config_loglevel_error(topo):
 def test_dse_config_loglevel_error(topo):
-    """ Manually setting nsslapd-errorlog-level to 64 in dse.ldif throws error
+    """Manually setting nsslapd-errorlog-level to 64 in dse.ldif throws error
 
 
     :id: 0eeefa17-ec1c-4208-8e7b-44d8fbc38f10
     :id: 0eeefa17-ec1c-4208-8e7b-44d8fbc38f10
-    :feature: Logging
+
     :setup: Standalone instance
     :setup: Standalone instance
+
     :steps: 1. Stop the server, edit dse.ldif file and change nsslapd-errorlog-level value to 64
     :steps: 1. Stop the server, edit dse.ldif file and change nsslapd-errorlog-level value to 64
             2. Start the server and observe the error logs.
             2. Start the server and observe the error logs.
+
     :expectedresults:
     :expectedresults:
             1. Server should be successfully stopped and nsslapd-errorlog-level value should be changed.
             1. Server should be successfully stopped and nsslapd-errorlog-level value should be changed.
             2. Server should be successfully started without any errors being reported in the logs.
             2. Server should be successfully started without any errors being reported in the logs.

+ 23 - 2
dirsrvtests/tests/suites/gssapi_repl/gssapi_repl_test.py

@@ -68,8 +68,29 @@ def _allow_machine_account(inst, name):
 
 
 
 
 def test_gssapi_repl(topology_m2):
 def test_gssapi_repl(topology_m2):
-    """Create a kdc, then using that, provision two masters which have a gssapi
-    authenticated replication agreement.
+    """Test gssapi authenticated replication agreement of two masters using KDC
+
+    :id: 552850aa-afc3-473e-9c39-aae802b46f11
+
+    :setup: MMR with two masters
+
+    :steps:
+         1. Create the locations on each master for the other master to bind to
+         2. Set on the cn=replica config to accept the other masters mapping under mapping tree
+         3. Create the replication agreements from M1->M2 and vice versa (M2->M1)
+         4. Set the replica bind method to sasl gssapi for both agreements
+         5. Initialize all the agreements
+         6. Create a user on M1 and check if user is created on M2
+         7. Create a user on M2 and check if user is created on M1
+
+    :expectedresults:
+         1. Locations should be added successfully
+         2. Configuration should be added successfully
+         3. Replication agreements should be added successfully
+         4. Bind method should be set to sasl gssapi for both agreements
+         5. Agreements should be initialized successfully
+         6. Test User should be created on M1 and M2 both
+         7. Test User should be created on M1 and M2 both
     """
     """
 
 
     return
     return