dirsrvtests/suites
by Mark Reynolds
dirsrvtests/suites/basic/basic_test.py | 265 ++++++++++++++++-----------------
1 file changed, 132 insertions(+), 133 deletions(-)
New commits:
commit ee96ec73de037ae666edaeef584f8b8e48527ab5
Author: Simon Pichugin <spichugi(a)redhat.com>
Date: Wed Aug 19 17:46:10 2015 +0200
Ticket 48251 - Improve the basic test suite
Description: Refactor basic suite code, because it should
correspond pytest and PEP 8 standarts.
Added a minor fix(that addresses false failures)
written by Mark Reynolds
https://fedorahosted.org/389/ticket/48251
Signed-off-by: Mark Reynolds <mreynolds(a)redhat.com>
diff --git a/dirsrvtests/suites/basic/basic_test.py b/dirsrvtests/suites/basic/basic_test.py
index d35f7d9..0c1b83b 100644
--- a/dirsrvtests/suites/basic/basic_test.py
+++ b/dirsrvtests/suites/basic/basic_test.py
@@ -40,9 +40,8 @@ class TopologyStandalone(object):
@pytest.fixture(scope="module")
def topology(request):
- '''
- This fixture is used to standalone topology for the 'module'.
- '''
+ """This fixture is used to standalone topology for the 'module'."""
+
global installation_prefix
if installation_prefix:
@@ -70,6 +69,11 @@ def topology(request):
# Used to retrieve configuration information (dbdir, confdir...)
standalone.open()
+ # Delete each instance in the end
+ def fin():
+ standalone.delete()
+ request.addfinalizer(fin)
+
# clear the tmp directory
standalone.clearTmpDir(__file__)
@@ -77,27 +81,24 @@ def topology(request):
return TopologyStandalone(standalone)
-def test_basic_init(topology):
- '''
- Initialize our setup
- '''
- #
- # Import the Example LDIF for the tests in this suite
- #
+(a)pytest.fixture(scope="module")
+def import_example_ldif(topology):
+ """Import the Example LDIF for the tests in this suite"""
+
log.info('Initializing the "basic" test suite')
import_ldif = '%s/Example.ldif' % get_data_dir(topology.standalone.prefix)
try:
- topology.standalone.tasks.importLDIF(suffix=DEFAULT_SUFFIX, input_file=import_ldif, args={TASK_WAIT: True})
+ topology.standalone.tasks.importLDIF(suffix=DEFAULT_SUFFIX,
+ input_file=import_ldif,
+ args={TASK_WAIT: True})
except ValueError:
log.error('Online import failed')
assert False
-def test_basic_ops(topology):
- '''
- Test doing adds, mods, modrdns, and deletes
- '''
+def test_basic_ops(topology, import_example_ldif):
+ """Test doing adds, mods, modrdns, and deletes"""
log.info('Running test_basic_ops...')
@@ -113,31 +114,34 @@ def test_basic_ops(topology):
# Adds
#
try:
- topology.standalone.add_s(Entry((USER1_DN, {'objectclass': "top extensibleObject".split(),
- 'sn': '1',
- 'cn': 'user1',
- 'uid': 'user1',
- 'userpassword': 'password'})))
+ topology.standalone.add_s(Entry((USER1_DN,
+ {'objectclass': "top extensibleObject".split(),
+ 'sn': '1',
+ 'cn': 'user1',
+ 'uid': 'user1',
+ 'userpassword': 'password'})))
except ldap.LDAPError, e:
log.error('Failed to add test user' + USER1_DN + ': error ' + e.message['desc'])
assert False
try:
- topology.standalone.add_s(Entry((USER2_DN, {'objectclass': "top extensibleObject".split(),
- 'sn': '2',
- 'cn': 'user2',
- 'uid': 'user2',
- 'userpassword': 'password'})))
+ topology.standalone.add_s(Entry((USER2_DN,
+ {'objectclass': "top extensibleObject".split(),
+ 'sn': '2',
+ 'cn': 'user2',
+ 'uid': 'user2',
+ 'userpassword': 'password'})))
except ldap.LDAPError, e:
log.error('Failed to add test user' + USER2_DN + ': error ' + e.message['desc'])
assert False
try:
- topology.standalone.add_s(Entry((USER3_DN, {'objectclass': "top extensibleObject".split(),
- 'sn': '3',
- 'cn': 'user3',
- 'uid': 'user3',
- 'userpassword': 'password'})))
+ topology.standalone.add_s(Entry((USER3_DN,
+ {'objectclass': "top extensibleObject".split(),
+ 'sn': '3',
+ 'cn': 'user3',
+ 'uid': 'user3',
+ 'userpassword': 'password'})))
except ldap.LDAPError, e:
log.error('Failed to add test user' + USER3_DN + ': error ' + e.message['desc'])
assert False
@@ -146,19 +150,22 @@ def test_basic_ops(topology):
# Mods
#
try:
- topology.standalone.modify_s(USER1_DN, [(ldap.MOD_ADD, 'description', 'New description')])
+ topology.standalone.modify_s(USER1_DN, [(ldap.MOD_ADD, 'description',
+ 'New description')])
except ldap.LDAPError, e:
log.error('Failed to add description: error ' + e.message['desc'])
assert False
try:
- topology.standalone.modify_s(USER1_DN, [(ldap.MOD_REPLACE, 'description', 'Modified description')])
+ topology.standalone.modify_s(USER1_DN, [(ldap.MOD_REPLACE, 'description',
+ 'Modified description')])
except ldap.LDAPError, e:
log.error('Failed to modify description: error ' + e.message['desc'])
assert False
try:
- topology.standalone.modify_s(USER1_DN, [(ldap.MOD_DELETE, 'description', None)])
+ topology.standalone.modify_s(USER1_DN, [(ldap.MOD_DELETE, 'description',
+ None)])
except ldap.LDAPError, e:
log.error('Failed to delete description: error ' + e.message['desc'])
assert False
@@ -180,7 +187,8 @@ def test_basic_ops(topology):
# Modrdn - New superior
try:
- topology.standalone.rename_s(USER3_DN, USER3_NEWDN, newsuperior=NEW_SUPERIOR, delold=1)
+ topology.standalone.rename_s(USER3_DN, USER3_NEWDN,
+ newsuperior=NEW_SUPERIOR, delold=1)
except ldap.LDAPError, e:
log.error('Failed to modrdn(new superior) user3: error ' + e.message['desc'])
assert False
@@ -209,10 +217,8 @@ def test_basic_ops(topology):
log.info('test_basic_ops: PASSED')
-def test_basic_import_export(topology):
- '''
- Test online and offline LDIF imports & exports
- '''
+def test_basic_import_export(topology, import_example_ldif):
+ """Test online and offline LDIF imports & exports"""
log.info('Running test_basic_import_export...')
@@ -227,12 +233,14 @@ def test_basic_import_export(topology):
try:
topology.standalone.buildLDIF(50000, import_ldif)
except OSError as e:
- log.fatal('test_basic_import_export: failed to create test ldif, error: %s - %s' % (e.errno, e.strerror))
+ log.fatal('test_basic_import_export: failed to create test ldif,\
+ error: %s - %s' % (e.errno, e.strerror))
assert False
# Online
try:
- topology.standalone.tasks.importLDIF(suffix=DEFAULT_SUFFIX, input_file=import_ldif,
+ topology.standalone.tasks.importLDIF(suffix=DEFAULT_SUFFIX,
+ input_file=import_ldif,
args={TASK_WAIT: True})
except ValueError:
log.fatal('test_basic_import_export: Online import failed')
@@ -258,7 +266,8 @@ def test_basic_import_export(topology):
assert False
# Offline export
- if not topology.standalone.db2ldif(DEFAULT_BENAME, (DEFAULT_SUFFIX,), None, None, None, export_ldif):
+ if not topology.standalone.db2ldif(DEFAULT_BENAME, (DEFAULT_SUFFIX,),
+ None, None, None, export_ldif):
log.fatal('test_basic_import_export: Failed to run offline db2ldif')
assert False
@@ -267,7 +276,9 @@ def test_basic_import_export(topology):
#
import_ldif = '%s/Example.ldif' % get_data_dir(topology.standalone.prefix)
try:
- topology.standalone.tasks.importLDIF(suffix=DEFAULT_SUFFIX, input_file=import_ldif, args={TASK_WAIT: True})
+ topology.standalone.tasks.importLDIF(suffix=DEFAULT_SUFFIX,
+ input_file=import_ldif,
+ args={TASK_WAIT: True})
except ValueError:
log.fatal('test_basic_import_export: Online import failed')
assert False
@@ -275,10 +286,8 @@ def test_basic_import_export(topology):
log.info('test_basic_import_export: PASSED')
-def test_basic_backup(topology):
- '''
- Test online and offline back and restore
- '''
+def test_basic_backup(topology, import_example_ldif):
+ """Test online and offline back and restore"""
log.info('Running test_basic_backup...')
@@ -286,14 +295,16 @@ def test_basic_backup(topology):
# Test online backup
try:
- topology.standalone.tasks.db2bak(backup_dir=backup_dir, args={TASK_WAIT: True})
+ topology.standalone.tasks.db2bak(backup_dir=backup_dir,
+ args={TASK_WAIT: True})
except ValueError:
log.fatal('test_basic_backup: Online backup failed')
assert False
# Test online restore
try:
- topology.standalone.tasks.bak2db(backup_dir=backup_dir, args={TASK_WAIT: True})
+ topology.standalone.tasks.bak2db(backup_dir=backup_dir,
+ args={TASK_WAIT: True})
except ValueError:
log.fatal('test_basic_backup: Online restore failed')
assert False
@@ -311,10 +322,8 @@ def test_basic_backup(topology):
log.info('test_basic_backup: PASSED')
-def test_basic_acl(topology):
- '''
- Run some basic access control(ACL) tests
- '''
+def test_basic_acl(topology, import_example_ldif):
+ """Run some basic access control(ACL) tests"""
log.info('Running test_basic_acl...')
@@ -325,27 +334,32 @@ def test_basic_acl(topology):
# Add two users
#
try:
- topology.standalone.add_s(Entry((USER1_DN, {'objectclass': "top extensibleObject".split(),
- 'sn': '1',
- 'cn': 'user 1',
- 'uid': 'user1',
- 'userpassword': PASSWORD})))
+ topology.standalone.add_s(Entry((USER1_DN,
+ {'objectclass': "top extensibleObject".split(),
+ 'sn': '1',
+ 'cn': 'user 1',
+ 'uid': 'user1',
+ 'userpassword': PASSWORD})))
except ldap.LDAPError, e:
- log.fatal('test_basic_acl: Failed to add test user ' + USER1_DN + ': error ' + e.message['desc'])
+ log.fatal('test_basic_acl: Failed to add test user ' + USER1_DN
+ + ': error ' + e.message['desc'])
assert False
try:
- topology.standalone.add_s(Entry((USER2_DN, {'objectclass': "top extensibleObject".split(),
- 'sn': '2',
- 'cn': 'user 2',
- 'uid': 'user2',
- 'userpassword': PASSWORD})))
+ topology.standalone.add_s(Entry((USER2_DN,
+ {'objectclass': "top extensibleObject".split(),
+ 'sn': '2',
+ 'cn': 'user 2',
+ 'uid': 'user2',
+ 'userpassword': PASSWORD})))
except ldap.LDAPError, e:
- log.fatal('test_basic_acl: Failed to add test user ' + USER1_DN + ': error ' + e.message['desc'])
+ log.fatal('test_basic_acl: Failed to add test user ' + USER1_DN
+ + ': error ' + e.message['desc'])
assert False
#
- # Add an aci that denies USER1 from doing anything, and also set the default anonymous access
+ # Add an aci that denies USER1 from doing anything,
+ # and also set the default anonymous access
#
try:
topology.standalone.modify_s(DEFAULT_SUFFIX, [(ldap.MOD_ADD, 'aci', DENY_ACI)])
@@ -363,7 +377,9 @@ def test_basic_acl(topology):
assert False
try:
- entries = topology.standalone.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, '(uid=*)')
+ entries = topology.standalone.search_s(DEFAULT_SUFFIX,
+ ldap.SCOPE_SUBTREE,
+ '(uid=*)')
if entries:
log.fatal('test_basic_acl: User1 was incorrectly able to search the suffix!')
assert False
@@ -379,7 +395,9 @@ def test_basic_acl(topology):
assert False
try:
- entries = topology.standalone.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, '(uid=user1)')
+ entries = topology.standalone.search_s(DEFAULT_SUFFIX,
+ ldap.SCOPE_SUBTREE,
+ '(uid=user1)')
if not entries:
log.fatal('test_basic_acl: User1 incorrectly not able to search the suffix')
assert False
@@ -400,7 +418,9 @@ def test_basic_acl(topology):
assert False
try:
- entries = topology.standalone.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, '(uid=*)')
+ entries = topology.standalone.search_s(DEFAULT_SUFFIX,
+ ldap.SCOPE_SUBTREE,
+ '(uid=*)')
if not entries:
log.fatal('test_basic_acl: Root DN incorrectly not able to search the suffix')
assert False
@@ -432,10 +452,8 @@ def test_basic_acl(topology):
log.info('test_basic_acl: PASSED')
-def test_basic_searches(topology):
- '''
- The search results are gathered from testing with Example.ldif
- '''
+def test_basic_searches(topology, import_example_ldif):
+ """The search results are gathered from testing with Example.ldif"""
log.info('Running test_basic_searches...')
@@ -458,9 +476,12 @@ def test_basic_searches(topology):
for (search_filter, search_result) in filters:
try:
- entries = topology.standalone.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, search_filter)
+ entries = topology.standalone.search_s(DEFAULT_SUFFIX,
+ ldap.SCOPE_SUBTREE,
+ search_filter)
if len(entries) != search_result:
- log.fatal('test_basic_searches: An incorrect number of entries was returned from filter (%s): (%d) expected (%d)' %
+ log.fatal('test_basic_searches: An incorrect number of entries\
+ was returned from filter (%s): (%d) expected (%d)' %
(search_filter, len(entries), search_result))
assert False
except ldap.LDAPError, e:
@@ -470,10 +491,10 @@ def test_basic_searches(topology):
log.info('test_basic_searches: PASSED')
-def test_basic_referrals(topology):
- '''
- Set the server to referral mode, and make sure we recive the referal error(10)
- '''
+def test_basic_referrals(topology, import_example_ldif):
+ """Set the server to referral mode,
+ and make sure we recive the referal error(10)
+ """
log.info('Running test_basic_referrals...')
@@ -483,16 +504,20 @@ def test_basic_referrals(topology):
# Set the referral, adn the backend state
#
try:
- topology.standalone.modify_s(SUFFIX_CONFIG, [(ldap.MOD_REPLACE, 'nsslapd-referral',
- 'ldap://localhost.localdomain:389/o%3dnetscaperoot')])
+ topology.standalone.modify_s(SUFFIX_CONFIG,
+ [(ldap.MOD_REPLACE,
+ 'nsslapd-referral',
+ 'ldap://localhost.localdomain:389/o%3dnetscaperoot')])
except ldap.LDAPError, e:
log.fatal('test_basic_referrals: Failed to set referral: error ' + e.message['desc'])
assert False
try:
- topology.standalone.modify_s(SUFFIX_CONFIG, [(ldap.MOD_REPLACE, 'nsslapd-state', 'Referral')])
+ topology.standalone.modify_s(SUFFIX_CONFIG, [(ldap.MOD_REPLACE,
+ 'nsslapd-state', 'Referral')])
except ldap.LDAPError, e:
- log.fatal('test_basic_referrals: Failed to set backend state: error ' + e.message['desc'])
+ log.fatal('test_basic_referrals: Failed to set backend state: error '
+ + e.message['desc'])
assert False
#
@@ -516,26 +541,29 @@ def test_basic_referrals(topology):
# Cleanup
#
try:
- topology.standalone.modify_s(SUFFIX_CONFIG, [(ldap.MOD_REPLACE, 'nsslapd-state', 'Backend')])
+ topology.standalone.modify_s(SUFFIX_CONFIG, [(ldap.MOD_REPLACE,
+ 'nsslapd-state', 'Backend')])
except ldap.LDAPError, e:
- log.fatal('test_basic_referrals: Failed to set backend state: error ' + e.message['desc'])
+ log.fatal('test_basic_referrals: Failed to set backend state: error '
+ + e.message['desc'])
assert False
try:
- topology.standalone.modify_s(SUFFIX_CONFIG, [(ldap.MOD_DELETE, 'nsslapd-referral', None)])
+ topology.standalone.modify_s(SUFFIX_CONFIG, [(ldap.MOD_DELETE,
+ 'nsslapd-referral', None)])
except ldap.LDAPError, e:
- log.fatal('test_basic_referrals: Failed to delete referral: error ' + e.message['desc'])
+ log.fatal('test_basic_referrals: Failed to delete referral: error '
+ + e.message['desc'])
assert False
topology.standalone.set_option(ldap.OPT_REFERRALS, 1)
log.info('test_basic_referrals: PASSED')
-def test_basic_systemctl(topology):
- '''
- Test systemctl can stop and start the server. Also test that start reports an
+def test_basic_systemctl(topology, import_example_ldif):
+ """Test systemctl can stop and start the server. Also test that start reports an
error when the instance does not start. Only for RPM builds
- '''
+ """
log.info('Running test_basic_systemctl...')
@@ -596,12 +624,13 @@ def test_basic_systemctl(topology):
log.info('Server failed to start as expected')
#
- # Fix the dse.ldif, nad make sure the server starts up,
+ # Fix the dse.ldif, and make sure the server starts up,
# and systemctl correctly identifies the successful start
#
shutil.copy(tmp_dir + 'dse.ldif', config_dir)
log.info('Starting the server...')
rc = os.system(start_ds)
+ time.sleep(10)
log.info('Check the status...')
if rc != 0 or os.system(is_running) != 0:
log.fatal('test_basic_systemctl: Failed to start the server')
@@ -612,17 +641,16 @@ def test_basic_systemctl(topology):
log.info('test_basic_systemctl: PASSED')
-def test_basic_ldapagent(topology):
- '''
- Test that the ldap agnet starts
- '''
+def test_basic_ldapagent(topology, import_example_ldif):
+ """Test that the ldap agent starts"""
log.info('Running test_basic_ldapagent...')
tmp_dir = topology.standalone.getDir(__file__, TMP_DIR)
var_dir = topology.standalone.prefix + '/var'
config_file = tmp_dir + '/agent.conf'
- cmd = 'sudo %s/ldap-agent %s' % (get_sbin_dir(prefix=topology.standalone.prefix), config_file)
+ cmd = 'sudo %s/ldap-agent %s' % (get_sbin_dir(prefix=topology.standalone.prefix),
+ config_file)
agent_config_file = open(config_file, 'w')
agent_config_file.write('agentx-master ' + var_dir + '/agentx/master\n')
@@ -647,10 +675,10 @@ def test_basic_ldapagent(topology):
log.info('test_basic_ldapagent: PASSED')
-def test_basic_dse(topology):
- '''
- Test that the dse.ldif is not wipped out after the process is killed (bug 910581)
- '''
+def test_basic_dse(topology, import_example_ldif):
+ """Test that the dse.ldif is not wipped out
+ after the process is killed (bug 910581)
+ """
log.info('Running test_basic_dse...')
@@ -667,37 +695,8 @@ def test_basic_dse(topology):
log.info('test_basic_dse: PASSED')
-def test_basic_final(topology):
- topology.standalone.delete()
- log.info('Basic test suite PASSED')
-
-
-def run_isolated():
- '''
- run_isolated is used to run these test cases independently of a test scheduler (xunit, py.test..)
- To run isolated without py.test, you need to
- - edit this file and comment '@pytest.fixture' line before 'topology' function.
- - set the installation prefix
- - run this program
- '''
- global installation_prefix
- installation_prefix = None
-
- topo = topology(True)
-
- test_basic_init(topo)
- test_basic_ops(topo)
- test_basic_import_export(topo)
- test_basic_backup(topo)
- test_basic_acl(topo)
- test_basic_searches(topo)
- test_basic_referrals(topo)
- test_basic_systemctl(topo)
- test_basic_ldapagent(topo)
- test_basic_dse(topo)
-
- test_basic_final(topo)
-
-
if __name__ == '__main__':
- run_isolated()
+ # Run isolated
+ # -s for DEBUG mode
+ CURRENT_FILE = os.path.realpath(__file__)
+ pytest.main("-s %s" % CURRENT_FILE)
--
389 commits mailing list
389-commits@%(host_name)s
http://lists.fedoraproject.org/postorius/389-commits@lists.fedoraproject.org
8 years, 8 months
Branch '389-ds-base-1.3.4' - dirsrvtests/tickets
by Mark Reynolds
dirsrvtests/tickets/ticket47910_test.py | 205 ++++++++++++++++++++++++++++++++
1 file changed, 205 insertions(+)
New commits:
commit 73d7dcf758433b20e276e9147cb4eec424f58727
Author: amsharma <amsharma(a)redhat.com>
Date: Fri Aug 7 17:55:20 2015 +0530
Author: amsharma <amsharma(a)redhat.com> Date: Thu Aug 6 14:47:01 2015 +0530
Ticket 47910 - allow logconv.pl -S/-E switches to work even when timestamps not present in access log
Bug Description: logconv does a normal string comparison to determine the
start and end times. If these exact times do not exist
in the logs then processing never takes place.
Fix Description: Convert the start and end times to seconds, then convert
the access log line time to seconds for comparision.
https://fedorahosted.org/389/ticket/47910 : Added test cases
Reviewed by: Simon(Thanks!) and Mark(Thanks!)
Signed-off-by: Mark Reynolds <mreynolds(a)redhat.com>
(cherry picked from commit 71987edf40476373c4051aa50b429eda3679da49)
diff --git a/dirsrvtests/tickets/ticket47910_test.py b/dirsrvtests/tickets/ticket47910_test.py
new file mode 100644
index 0000000..afcfd88
--- /dev/null
+++ b/dirsrvtests/tickets/ticket47910_test.py
@@ -0,0 +1,205 @@
+# Copyright (C) 2015 Red Hat, Inc.
+# All rights reserved.
+#
+# License: GPL (version 3 or any later version).
+# See LICENSE for details.
+# --- END COPYRIGHT BLOCK ---
+#
+import os
+import sys
+import time
+import ldap
+import logging
+import pytest
+import re
+import subprocess
+from lib389 import DirSrv, Entry, tools, tasks
+from lib389.tools import DirSrvTools
+from lib389._constants import *
+from lib389.properties import *
+from lib389.tasks import *
+from datetime import datetime, timedelta
+
+
+logging.getLogger(__name__).setLevel(logging.DEBUG)
+log = logging.getLogger(__name__)
+
+installation1_prefix = None
+
+
+class TopologyStandalone(object):
+ def __init__(self, standalone):
+ standalone.open()
+ self.standalone = standalone
+
+
+(a)pytest.fixture(scope="module")
+def topology(request):
+ global installation1_prefix
+ if installation1_prefix:
+ args_instance[SER_DEPLOYED_DIR] = installation1_prefix
+
+ # Creating standalone instance ...
+ standalone = DirSrv(verbose=False)
+ args_instance[SER_HOST] = HOST_STANDALONE
+ args_instance[SER_PORT] = PORT_STANDALONE
+ args_instance[SER_SERVERID_PROP] = SERVERID_STANDALONE
+ args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
+ args_standalone = args_instance.copy()
+ standalone.allocate(args_standalone)
+ instance_standalone = standalone.exists()
+ if instance_standalone:
+ standalone.delete()
+ standalone.create()
+ standalone.open()
+
+ # Clear out the tmp dir
+ standalone.clearTmpDir(__file__)
+
+ def fin():
+ standalone.delete()
+ request.addfinalizer(fin)
+
+ return TopologyStandalone(standalone)
+
+
+(a)pytest.fixture(scope="module")
+def log_dir(topology):
+ '''
+ Do a search operation
+ and disable access log buffering
+ to generate the access log
+ '''
+
+ log.info("Diable access log buffering")
+ topology.standalone.setAccessLogBuffering(False)
+
+ log.info("Do a ldapsearch operation")
+ topology.standalone.search_s(SUFFIX, ldap.SCOPE_SUBTREE, "(objectclass=*)")
+
+ log.info("sleep for sometime so that access log file get generated")
+ time.sleep( 1 )
+
+ return topology.standalone.accesslog
+
+
+def format_time(local_datetime):
+ formatted_time = (local_datetime.strftime("[%d/%b/%Y:%H:%M:%S]"))
+ return formatted_time
+
+
+def execute_logconv(start_time_stamp, end_time_stamp, access_log):
+ '''
+ This function will take start time and end time
+ as input parameter and
+ assign these values to -S and -E options of logconv
+ and, it will execute logconv and return result value
+ '''
+
+ log.info("Executing logconv.pl with -S current time and -E end time")
+ cmd = ['logconv.pl', '-S', start_time_stamp, '-E', end_time_stamp, access_log]
+ log.info(" ".join(cmd))
+ proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ stdout, stderr = proc.communicate()
+ log.info("standard output" + stdout)
+ log.info("standard errors" + stderr)
+ return proc.returncode
+
+
+def test_ticket47910_logconv_start_end_positive(topology, log_dir):
+ '''
+ Execute logconv.pl with -S and -E(endtime) with random time stamp
+ This is execute successfully
+ '''
+ #
+ # Execute logconv.pl -S -E with random timestamp
+ #
+ log.info('Running test_ticket47910 - Execute logconv.pl -S -E with random values')
+
+ log.info("taking current time with offset of 2 mins and formatting it to feed -S")
+ start_time_stamp = (datetime.now() - timedelta(minutes=2))
+ formatted_start_time_stamp = format_time(start_time_stamp)
+
+ log.info("taking current time with offset of 2 mins and formatting it to feed -E")
+ end_time_stamp = (datetime.now() + timedelta(minutes=2))
+ formatted_end_time_stamp = format_time(end_time_stamp)
+
+ log.info("Executing logconv.pl with -S and -E")
+ result = execute_logconv(formatted_start_time_stamp, formatted_end_time_stamp, log_dir)
+ assert result == 0
+
+
+def test_ticket47910_logconv_start_end_negative(topology, log_dir):
+ '''
+ Execute logconv.pl with -S and -E(endtime) with random time stamp
+ This is a negative test case, where endtime will be lesser than the
+ starttime
+ This should give error message
+ '''
+
+ #
+ # Execute logconv.pl -S and -E with random timestamp
+ #
+ log.info('Running test_ticket47910 - Execute logconv.pl -S -E with starttime>endtime')
+
+ log.info("taking current time with offset of 2 mins and formatting it to feed -S")
+ start_time_stamp = (datetime.now() + timedelta(minutes=2))
+ formatted_start_time_stamp = format_time(start_time_stamp)
+
+ log.info("taking current time with offset of 2 mins and formatting it to feed -E")
+ end_time_stamp = (datetime.now() - timedelta(minutes=2))
+ formatted_end_time_stamp = format_time(end_time_stamp)
+
+ log.info("Executing logconv.pl with -S and -E")
+ result = execute_logconv(formatted_start_time_stamp, formatted_end_time_stamp, log_dir)
+ assert result == 1
+
+
+def test_ticket47910_logconv_start_end_invalid(topology, log_dir):
+ '''
+ Execute logconv.pl with -S and -E(endtime) with invalid time stamp
+ This is a negative test case, where it should give error message
+ '''
+ #
+ # Execute logconv.pl -S and -E with invalid timestamp
+ #
+ log.info('Running test_ticket47910 - Execute logconv.pl -S -E with invalid timestamp')
+ log.info("Set start time and end time to invalid values")
+ start_time_stamp = "invalid"
+ end_time_stamp = "invalid"
+
+ log.info("Executing logconv.pl with -S and -E")
+ result = execute_logconv(start_time_stamp, end_time_stamp, log_dir)
+ assert result == 1
+
+
+def test_ticket47910_logconv_noaccesslogs(topology, log_dir):
+
+ '''
+ Execute logconv.pl -S(starttime) without specify
+ access logs location
+ '''
+
+ #
+ # Execute logconv.pl -S with random timestamp and no access log location
+ #
+ log.info('Running test_ticket47910 - Execute logconv.pl without access logs')
+
+ log.info("taking current time with offset of 2 mins and formatting it to feed -S")
+ time_stamp = (datetime.now() - timedelta(minutes=2))
+ formatted_time_stamp = format_time(time_stamp)
+ log.info("Executing logconv.pl with -S current time")
+ cmd = ['logconv.pl', '-S', formatted_time_stamp]
+ log.info(" ".join(cmd))
+ proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ stdout, stderr = proc.communicate()
+ log.info("standard output" + stdout)
+ log.info("standard errors" + stderr)
+
+ assert proc.returncode == 1
+
+
+if __name__ == '__main__':
+ # Run isolated
+ # -s for DEBUG mode
+ pytest.main("-s ticket47910_test.py")
--
389 commits mailing list
389-commits@%(host_name)s
http://lists.fedoraproject.org/postorius/389-commits@lists.fedoraproject.org
8 years, 8 months
dirsrvtests/tickets
by Mark Reynolds
dirsrvtests/tickets/ticket47910_test.py | 205 ++++++++++++++++++++++++++++++++
1 file changed, 205 insertions(+)
New commits:
commit 71987edf40476373c4051aa50b429eda3679da49
Author: amsharma <amsharma(a)redhat.com>
Date: Fri Aug 7 17:55:20 2015 +0530
Author: amsharma <amsharma(a)redhat.com> Date: Thu Aug 6 14:47:01 2015 +0530
Ticket 47910 - allow logconv.pl -S/-E switches to work even when timestamps not present in access log
Bug Description: logconv does a normal string comparison to determine the
start and end times. If these exact times do not exist
in the logs then processing never takes place.
Fix Description: Convert the start and end times to seconds, then convert
the access log line time to seconds for comparision.
https://fedorahosted.org/389/ticket/47910 : Added test cases
Reviewed by: Simon(Thanks!) and Mark(Thanks!)
Signed-off-by: Mark Reynolds <mreynolds(a)redhat.com>
diff --git a/dirsrvtests/tickets/ticket47910_test.py b/dirsrvtests/tickets/ticket47910_test.py
new file mode 100644
index 0000000..afcfd88
--- /dev/null
+++ b/dirsrvtests/tickets/ticket47910_test.py
@@ -0,0 +1,205 @@
+# Copyright (C) 2015 Red Hat, Inc.
+# All rights reserved.
+#
+# License: GPL (version 3 or any later version).
+# See LICENSE for details.
+# --- END COPYRIGHT BLOCK ---
+#
+import os
+import sys
+import time
+import ldap
+import logging
+import pytest
+import re
+import subprocess
+from lib389 import DirSrv, Entry, tools, tasks
+from lib389.tools import DirSrvTools
+from lib389._constants import *
+from lib389.properties import *
+from lib389.tasks import *
+from datetime import datetime, timedelta
+
+
+logging.getLogger(__name__).setLevel(logging.DEBUG)
+log = logging.getLogger(__name__)
+
+installation1_prefix = None
+
+
+class TopologyStandalone(object):
+ def __init__(self, standalone):
+ standalone.open()
+ self.standalone = standalone
+
+
+(a)pytest.fixture(scope="module")
+def topology(request):
+ global installation1_prefix
+ if installation1_prefix:
+ args_instance[SER_DEPLOYED_DIR] = installation1_prefix
+
+ # Creating standalone instance ...
+ standalone = DirSrv(verbose=False)
+ args_instance[SER_HOST] = HOST_STANDALONE
+ args_instance[SER_PORT] = PORT_STANDALONE
+ args_instance[SER_SERVERID_PROP] = SERVERID_STANDALONE
+ args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
+ args_standalone = args_instance.copy()
+ standalone.allocate(args_standalone)
+ instance_standalone = standalone.exists()
+ if instance_standalone:
+ standalone.delete()
+ standalone.create()
+ standalone.open()
+
+ # Clear out the tmp dir
+ standalone.clearTmpDir(__file__)
+
+ def fin():
+ standalone.delete()
+ request.addfinalizer(fin)
+
+ return TopologyStandalone(standalone)
+
+
+(a)pytest.fixture(scope="module")
+def log_dir(topology):
+ '''
+ Do a search operation
+ and disable access log buffering
+ to generate the access log
+ '''
+
+ log.info("Diable access log buffering")
+ topology.standalone.setAccessLogBuffering(False)
+
+ log.info("Do a ldapsearch operation")
+ topology.standalone.search_s(SUFFIX, ldap.SCOPE_SUBTREE, "(objectclass=*)")
+
+ log.info("sleep for sometime so that access log file get generated")
+ time.sleep( 1 )
+
+ return topology.standalone.accesslog
+
+
+def format_time(local_datetime):
+ formatted_time = (local_datetime.strftime("[%d/%b/%Y:%H:%M:%S]"))
+ return formatted_time
+
+
+def execute_logconv(start_time_stamp, end_time_stamp, access_log):
+ '''
+ This function will take start time and end time
+ as input parameter and
+ assign these values to -S and -E options of logconv
+ and, it will execute logconv and return result value
+ '''
+
+ log.info("Executing logconv.pl with -S current time and -E end time")
+ cmd = ['logconv.pl', '-S', start_time_stamp, '-E', end_time_stamp, access_log]
+ log.info(" ".join(cmd))
+ proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ stdout, stderr = proc.communicate()
+ log.info("standard output" + stdout)
+ log.info("standard errors" + stderr)
+ return proc.returncode
+
+
+def test_ticket47910_logconv_start_end_positive(topology, log_dir):
+ '''
+ Execute logconv.pl with -S and -E(endtime) with random time stamp
+ This is execute successfully
+ '''
+ #
+ # Execute logconv.pl -S -E with random timestamp
+ #
+ log.info('Running test_ticket47910 - Execute logconv.pl -S -E with random values')
+
+ log.info("taking current time with offset of 2 mins and formatting it to feed -S")
+ start_time_stamp = (datetime.now() - timedelta(minutes=2))
+ formatted_start_time_stamp = format_time(start_time_stamp)
+
+ log.info("taking current time with offset of 2 mins and formatting it to feed -E")
+ end_time_stamp = (datetime.now() + timedelta(minutes=2))
+ formatted_end_time_stamp = format_time(end_time_stamp)
+
+ log.info("Executing logconv.pl with -S and -E")
+ result = execute_logconv(formatted_start_time_stamp, formatted_end_time_stamp, log_dir)
+ assert result == 0
+
+
+def test_ticket47910_logconv_start_end_negative(topology, log_dir):
+ '''
+ Execute logconv.pl with -S and -E(endtime) with random time stamp
+ This is a negative test case, where endtime will be lesser than the
+ starttime
+ This should give error message
+ '''
+
+ #
+ # Execute logconv.pl -S and -E with random timestamp
+ #
+ log.info('Running test_ticket47910 - Execute logconv.pl -S -E with starttime>endtime')
+
+ log.info("taking current time with offset of 2 mins and formatting it to feed -S")
+ start_time_stamp = (datetime.now() + timedelta(minutes=2))
+ formatted_start_time_stamp = format_time(start_time_stamp)
+
+ log.info("taking current time with offset of 2 mins and formatting it to feed -E")
+ end_time_stamp = (datetime.now() - timedelta(minutes=2))
+ formatted_end_time_stamp = format_time(end_time_stamp)
+
+ log.info("Executing logconv.pl with -S and -E")
+ result = execute_logconv(formatted_start_time_stamp, formatted_end_time_stamp, log_dir)
+ assert result == 1
+
+
+def test_ticket47910_logconv_start_end_invalid(topology, log_dir):
+ '''
+ Execute logconv.pl with -S and -E(endtime) with invalid time stamp
+ This is a negative test case, where it should give error message
+ '''
+ #
+ # Execute logconv.pl -S and -E with invalid timestamp
+ #
+ log.info('Running test_ticket47910 - Execute logconv.pl -S -E with invalid timestamp')
+ log.info("Set start time and end time to invalid values")
+ start_time_stamp = "invalid"
+ end_time_stamp = "invalid"
+
+ log.info("Executing logconv.pl with -S and -E")
+ result = execute_logconv(start_time_stamp, end_time_stamp, log_dir)
+ assert result == 1
+
+
+def test_ticket47910_logconv_noaccesslogs(topology, log_dir):
+
+ '''
+ Execute logconv.pl -S(starttime) without specify
+ access logs location
+ '''
+
+ #
+ # Execute logconv.pl -S with random timestamp and no access log location
+ #
+ log.info('Running test_ticket47910 - Execute logconv.pl without access logs')
+
+ log.info("taking current time with offset of 2 mins and formatting it to feed -S")
+ time_stamp = (datetime.now() - timedelta(minutes=2))
+ formatted_time_stamp = format_time(time_stamp)
+ log.info("Executing logconv.pl with -S current time")
+ cmd = ['logconv.pl', '-S', formatted_time_stamp]
+ log.info(" ".join(cmd))
+ proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ stdout, stderr = proc.communicate()
+ log.info("standard output" + stdout)
+ log.info("standard errors" + stderr)
+
+ assert proc.returncode == 1
+
+
+if __name__ == '__main__':
+ # Run isolated
+ # -s for DEBUG mode
+ pytest.main("-s ticket47910_test.py")
--
389 commits mailing list
389-commits@%(host_name)s
http://lists.fedoraproject.org/postorius/389-commits@lists.fedoraproject.org
8 years, 8 months
Changes to 'refs/tags/389-console-1.1.15'
by Noriko Hosoi
Changes since the dawn of time:
Mark Reynolds (3):
Ticket 97 - 389-console should provide man page
Ticket 47604 - 389-console: remove versioned jars from %{_javadir}
Bump version to 1.1.8
Nathan Kinder (3):
Initial import of fedora-idm-console
Resolves: 183962
Resolves: 393461
Noriko Hosoi (8):
Ticket 97 - 389-console should provide man page
Bump version to 1.1.9
version 1.1.10
version 1.1.11
version 1.1.12
version 1.1.13
version 1.1.14
version 1.1.15
Rich Megginson (33):
initial commit of Fedora Console for Windows - has no UI
added UI and graphics
package is not noarch
support for JAVA with spaces in the pathname
added license
updated spec for Fedora DS 1.1 release
Resolves: bug 428352
Resolves: bug 480631
Reviewed by: nkinder (Thanks!)
Resolves: bug 476095
bump version to 1.1.3 to sync with CVS tag
added unzip.vbs ; cleaned up/simplified Makefile
update idm console version to 20090310
update for 1.1.3
fix typo in Makefile
Initial commit of renaming to 389
Forgot to add provides and obsoletes for fedora-idm-console
added .gitignore
added need_libdir flag to control where libdir is needed to find jss
fix spelling error
Add 64-bit support - Use replaceable parameters for names, guids
Remove old package during upgrade
Remove old shortcuts must ignore All Users folders
Force shortcuts to be removed - removeoldpkg must run asyncNoWait
Bump version to 1.1.4
Changed version to 1.1.4.a1
make sure bitsadmin.exe path is quoted
update to version 1.1.4 rc1
update to version 1.1.4
update for nspr 4.8.4, nss 3.12.6, and idm console framework 1.1.5
Bug 592120 - console for 64bit Window2008 can not be installed
allow building without the script - bump version to 1.1.7
port to wix 3.0 from mozilla-build - use idm console 1.1.7
--
389 commits mailing list
389-commits@%(host_name)s
http://lists.fedoraproject.org/postorius/389-commits@lists.fedoraproject.org
8 years, 8 months
build.properties win/Makefile win/template.bat win/VERSION.mak
by Noriko Hosoi
build.properties | 2 +-
win/Makefile | 2 --
win/VERSION.mak | 2 +-
win/template.bat | 2 +-
4 files changed, 3 insertions(+), 5 deletions(-)
New commits:
commit d6e988452f43db9bfeab6a243833c559b4c0cba2
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Thu Aug 27 15:17:12 2015 -0700
version 1.1.15
- Undo generating $(FILEPREF)-console-ipv4.bat.
- Add the option "-Djava.net.preferIPv4Stack=true" to template.bat directly.
diff --git a/build.properties b/build.properties
index 3b0f34d..a275820 100644
--- a/build.properties
+++ b/build.properties
@@ -23,7 +23,7 @@ lang=en
console.root=.
console.version=11
-console.dotversion=1.1.14
+console.dotversion=1.1.15
console.dotgenversion=1.1
theme.core=389-console
diff --git a/win/Makefile b/win/Makefile
index 69e0d7a..dd994b7 100644
--- a/win/Makefile
+++ b/win/Makefile
@@ -89,7 +89,6 @@ MOZILLABUILDDIR=c:\mozilla-build
#UZCMD=cscript //nologo unzip.vbs
UZCMD=$(MOZILLABUILDDIR)\info-zip\unzip.exe -q -o
-SED=$(MOZILLABUILDDIR)\msys\bin\sed.exe
NSPRVER=4.8.4
NSSVER=3_12_6
@@ -198,7 +197,6 @@ LAYOUT : $(PKGDIR) $(NSPRLIBDIR)\nspr4.dll $(NSSLIBDIR)\nss3.dll $(JSSDIR)\jss4.
# directory should already contain the bat file, icon, and bitmaps
@(echo @echo off&echo set FILEPREF=$(FILEPREF)) > header
copy /Y header+template.bat $(PKGDIR)\$(FILEPREF)-console.bat
- $(SED) -e "s/com.netscape.management.client.console.Console/-Djava.net.preferIPv4Stack=true com.netscape.management.client.console.Console/" $(PKGDIR)\$(FILEPREF)-console.bat > $(PKGDIR)\$(FILEPREF)-console-ipv4.bat
del header
copy /Y $(ICONDIR)\*.ico $(PKGDIR)
copy /Y $(BITMAPDIR)\* $(PKGDIR)\Bitmaps\*
diff --git a/win/VERSION.mak b/win/VERSION.mak
index 4ac88bb..30f196d 100644
--- a/win/VERSION.mak
+++ b/win/VERSION.mak
@@ -7,7 +7,7 @@ BRANDNOSPACE=389
# this is the vendor or manufacturer
VENDOR=389 Project
# the version
-VERSION=1.1.14
+VERSION=1.1.15
# the name of the product - this is used in the title of the
# installer, in the name of the folder, and in the name
# of the shortcuts
diff --git a/win/template.bat b/win/template.bat
index df28dfb..c88831a 100644
--- a/win/template.bat
+++ b/win/template.bat
@@ -74,6 +74,6 @@ rem
rem Launch the Console
rem
echo on
-"%JAVA%" "-Djava.library.path=%JSSDIR%" -cp "%JSSDIR%/jss4.jar;%LDAPJARDIR%/ldapjdk.jar;%CONSOLEJARDIR%/idm-console-base.jar;%CONSOLEJARDIR%/idm-console-mcc.jar;%CONSOLEJARDIR%/idm-console-mcc_en.jar;%CONSOLEJARDIR%/idm-console-nmclf.jar;%CONSOLEJARDIR%/idm-console-nmclf_en.jar;%BRANDCONSOLEJARDIR%/%FILEPREF%-console_en.jar" -Djava.util.prefs.systemRoot=%HOME%/.%FILEPREF%-console -Djava.util.prefs.userRoot=%HOME%/.%FILEPREF%-console com.netscape.management.client.console.Console %*
+"%JAVA%" "-Djava.library.path=%JSSDIR%" -cp "%JSSDIR%/jss4.jar;%LDAPJARDIR%/ldapjdk.jar;%CONSOLEJARDIR%/idm-console-base.jar;%CONSOLEJARDIR%/idm-console-mcc.jar;%CONSOLEJARDIR%/idm-console-mcc_en.jar;%CONSOLEJARDIR%/idm-console-nmclf.jar;%CONSOLEJARDIR%/idm-console-nmclf_en.jar;%BRANDCONSOLEJARDIR%/%FILEPREF%-console_en.jar" -Djava.util.prefs.systemRoot=%HOME%/.%FILEPREF%-console -Djava.util.prefs.userRoot=%HOME%/.%FILEPREF%-console -Djava.net.preferIPv4Stack=true com.netscape.management.client.console.Console %*
:end
--
389 commits mailing list
389-commits@%(host_name)s
http://lists.fedoraproject.org/postorius/389-commits@lists.fedoraproject.org
8 years, 8 months
Branch '389-ds-base-1.2.11' - ldap/servers
by Noriko Hosoi
ldap/servers/slapd/pw.c | 21 ++++++++-------------
1 file changed, 8 insertions(+), 13 deletions(-)
New commits:
commit 1e2793d5a8984b2e390cb3038f507611b3ebc6e2
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Tue Aug 25 16:31:10 2015 -0700
Ticket #48228 - wrong password check if passwordInHistory is decreased.
Description: Regression was added by this commit:
commit 1a119125856006543aae0520b5800a8b52c3b049
Ticket #48228 - wrong password check if passwordInHistory is decreased.
Compare function pw_history_cmp used in qsort did not check the correct
address for the timestamp string, which made qsort return the password
history in the wrong order.
https://fedorahosted.org/389/ticket/48228
Reviewed by rmeggins(a)redhat.com (Thank you, Rich!)
(cherry picked from commit 391acfcf9a67b9b27ebbd98d1dfe30ef54a027c4)
(cherry picked from commit 096b386663c949136095def77a7fb12eee64e542)
(cherry picked from commit 90cf9fdbc8b71e68f615f8a72328c25e41a8fd0c)
diff --git a/ldap/servers/slapd/pw.c b/ldap/servers/slapd/pw.c
index bd3a47c..fe3c025 100644
--- a/ldap/servers/slapd/pw.c
+++ b/ldap/servers/slapd/pw.c
@@ -1090,8 +1090,6 @@ retry:
static int
pw_history_cmp(const void *h0, const void *h1)
{
- size_t h0sz = 0;
- size_t h1sz = 0;
if (!h0) {
if (!h1) {
return 0;
@@ -1102,23 +1100,20 @@ pw_history_cmp(const void *h0, const void *h1)
if (!h1) {
return 1;
} else {
- size_t delta;
- h0sz = strlen(h0);
- h1sz = strlen(h1);
- delta = h0sz - h1sz;
- if (!delta) {
- return delta;
- }
- if (h0sz < GENERALIZED_TIME_LENGTH) {
+ char *h0str = *(char **)h0;
+ char *h1str = *(char **)h1;
+ size_t h0sz = strlen(h0str);
+ size_t h1sz = strlen(h1str);
+ if ((h0sz < GENERALIZED_TIME_LENGTH) ||
+ (h1sz < GENERALIZED_TIME_LENGTH)) {
/* too short for the history str. */
- return 0;
+ return h0sz - h1sz;
}
+ return PL_strncmp(h0str, h1str, GENERALIZED_TIME_LENGTH);
}
}
- return PL_strncmp(h0, h1, GENERALIZED_TIME_LENGTH);
}
-
static int
update_pw_history( Slapi_PBlock *pb, const Slapi_DN *sdn, char *old_pw )
{
--
389 commits mailing list
389-commits@%(host_name)s
http://lists.fedoraproject.org/postorius/389-commits@lists.fedoraproject.org
8 years, 8 months
Branch '389-ds-base-1.3.3' - ldap/servers
by Noriko Hosoi
ldap/servers/slapd/pw.c | 21 ++++++++-------------
1 file changed, 8 insertions(+), 13 deletions(-)
New commits:
commit 90cf9fdbc8b71e68f615f8a72328c25e41a8fd0c
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Tue Aug 25 16:31:10 2015 -0700
Ticket #48228 - wrong password check if passwordInHistory is decreased.
Description: Regression was added by this commit:
commit 1a119125856006543aae0520b5800a8b52c3b049
Ticket #48228 - wrong password check if passwordInHistory is decreased.
Compare function pw_history_cmp used in qsort did not check the correct
address for the timestamp string, which made qsort return the password
history in the wrong order.
https://fedorahosted.org/389/ticket/48228
Reviewed by rmeggins(a)redhat.com (Thank you, Rich!)
(cherry picked from commit 391acfcf9a67b9b27ebbd98d1dfe30ef54a027c4)
(cherry picked from commit 096b386663c949136095def77a7fb12eee64e542)
diff --git a/ldap/servers/slapd/pw.c b/ldap/servers/slapd/pw.c
index 192584a..387ee5e 100644
--- a/ldap/servers/slapd/pw.c
+++ b/ldap/servers/slapd/pw.c
@@ -1121,8 +1121,6 @@ retry:
static int
pw_history_cmp(const void *h0, const void *h1)
{
- size_t h0sz = 0;
- size_t h1sz = 0;
if (!h0) {
if (!h1) {
return 0;
@@ -1133,23 +1131,20 @@ pw_history_cmp(const void *h0, const void *h1)
if (!h1) {
return 1;
} else {
- size_t delta;
- h0sz = strlen(h0);
- h1sz = strlen(h1);
- delta = h0sz - h1sz;
- if (!delta) {
- return delta;
- }
- if (h0sz < GENERALIZED_TIME_LENGTH) {
+ char *h0str = *(char **)h0;
+ char *h1str = *(char **)h1;
+ size_t h0sz = strlen(h0str);
+ size_t h1sz = strlen(h1str);
+ if ((h0sz < GENERALIZED_TIME_LENGTH) ||
+ (h1sz < GENERALIZED_TIME_LENGTH)) {
/* too short for the history str. */
- return 0;
+ return h0sz - h1sz;
}
+ return PL_strncmp(h0str, h1str, GENERALIZED_TIME_LENGTH);
}
}
- return PL_strncmp(h0, h1, GENERALIZED_TIME_LENGTH);
}
-
static int
update_pw_history( Slapi_PBlock *pb, const Slapi_DN *sdn, char *old_pw )
{
--
389 commits mailing list
389-commits@%(host_name)s
http://lists.fedoraproject.org/postorius/389-commits@lists.fedoraproject.org
8 years, 8 months
Branch '389-ds-base-1.3.4' - ldap/servers
by Noriko Hosoi
ldap/servers/slapd/pw.c | 21 ++++++++-------------
1 file changed, 8 insertions(+), 13 deletions(-)
New commits:
commit 096b386663c949136095def77a7fb12eee64e542
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Tue Aug 25 16:31:10 2015 -0700
Ticket #48228 - wrong password check if passwordInHistory is decreased.
Description: Regression was added by this commit:
commit 1a119125856006543aae0520b5800a8b52c3b049
Ticket #48228 - wrong password check if passwordInHistory is decreased.
Compare function pw_history_cmp used in qsort did not check the correct
address for the timestamp string, which made qsort return the password
history in the wrong order.
https://fedorahosted.org/389/ticket/48228
Reviewed by rmeggins(a)redhat.com (Thank you, Rich!)
(cherry picked from commit 391acfcf9a67b9b27ebbd98d1dfe30ef54a027c4)
diff --git a/ldap/servers/slapd/pw.c b/ldap/servers/slapd/pw.c
index 3abebbf..4e222d7 100644
--- a/ldap/servers/slapd/pw.c
+++ b/ldap/servers/slapd/pw.c
@@ -1085,8 +1085,6 @@ retry:
static int
pw_history_cmp(const void *h0, const void *h1)
{
- size_t h0sz = 0;
- size_t h1sz = 0;
if (!h0) {
if (!h1) {
return 0;
@@ -1097,23 +1095,20 @@ pw_history_cmp(const void *h0, const void *h1)
if (!h1) {
return 1;
} else {
- size_t delta;
- h0sz = strlen(h0);
- h1sz = strlen(h1);
- delta = h0sz - h1sz;
- if (!delta) {
- return delta;
- }
- if (h0sz < GENERALIZED_TIME_LENGTH) {
+ char *h0str = *(char **)h0;
+ char *h1str = *(char **)h1;
+ size_t h0sz = strlen(h0str);
+ size_t h1sz = strlen(h1str);
+ if ((h0sz < GENERALIZED_TIME_LENGTH) ||
+ (h1sz < GENERALIZED_TIME_LENGTH)) {
/* too short for the history str. */
- return 0;
+ return h0sz - h1sz;
}
+ return PL_strncmp(h0str, h1str, GENERALIZED_TIME_LENGTH);
}
}
- return PL_strncmp(h0, h1, GENERALIZED_TIME_LENGTH);
}
-
static int
update_pw_history( Slapi_PBlock *pb, const Slapi_DN *sdn, char *old_pw )
{
--
389 commits mailing list
389-commits@%(host_name)s
http://lists.fedoraproject.org/postorius/389-commits@lists.fedoraproject.org
8 years, 8 months
ldap/servers
by Noriko Hosoi
ldap/servers/slapd/pw.c | 21 ++++++++-------------
1 file changed, 8 insertions(+), 13 deletions(-)
New commits:
commit 391acfcf9a67b9b27ebbd98d1dfe30ef54a027c4
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Tue Aug 25 16:31:10 2015 -0700
Ticket #48228 - wrong password check if passwordInHistory is decreased.
Description: Regression was added by this commit:
commit 1a119125856006543aae0520b5800a8b52c3b049
Ticket #48228 - wrong password check if passwordInHistory is decreased.
Compare function pw_history_cmp used in qsort did not check the correct
address for the timestamp string, which made qsort return the password
history in the wrong order.
https://fedorahosted.org/389/ticket/48228
Reviewed by rmeggins(a)redhat.com (Thank you, Rich!)
diff --git a/ldap/servers/slapd/pw.c b/ldap/servers/slapd/pw.c
index 3abebbf..4e222d7 100644
--- a/ldap/servers/slapd/pw.c
+++ b/ldap/servers/slapd/pw.c
@@ -1085,8 +1085,6 @@ retry:
static int
pw_history_cmp(const void *h0, const void *h1)
{
- size_t h0sz = 0;
- size_t h1sz = 0;
if (!h0) {
if (!h1) {
return 0;
@@ -1097,23 +1095,20 @@ pw_history_cmp(const void *h0, const void *h1)
if (!h1) {
return 1;
} else {
- size_t delta;
- h0sz = strlen(h0);
- h1sz = strlen(h1);
- delta = h0sz - h1sz;
- if (!delta) {
- return delta;
- }
- if (h0sz < GENERALIZED_TIME_LENGTH) {
+ char *h0str = *(char **)h0;
+ char *h1str = *(char **)h1;
+ size_t h0sz = strlen(h0str);
+ size_t h1sz = strlen(h1str);
+ if ((h0sz < GENERALIZED_TIME_LENGTH) ||
+ (h1sz < GENERALIZED_TIME_LENGTH)) {
/* too short for the history str. */
- return 0;
+ return h0sz - h1sz;
}
+ return PL_strncmp(h0str, h1str, GENERALIZED_TIME_LENGTH);
}
}
- return PL_strncmp(h0, h1, GENERALIZED_TIME_LENGTH);
}
-
static int
update_pw_history( Slapi_PBlock *pb, const Slapi_DN *sdn, char *old_pw )
{
--
389 commits mailing list
389-commits@%(host_name)s
http://lists.fedoraproject.org/postorius/389-commits@lists.fedoraproject.org
8 years, 8 months
Branch '389-ds-base-1.3.3' - ldap/servers
by Noriko Hosoi
ldap/servers/slapd/back-ldbm/ldif2ldbm.c | 66 ++++++++++++++++++++-----------
1 file changed, 44 insertions(+), 22 deletions(-)
New commits:
commit ef0a2954cba650364ba4c48038d69731ebe19387
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Fri Aug 21 12:10:27 2015 -0700
Ticket #48252 - db2index creates index entry from deleted records
Bug Description: When an entry is deleted, its indexed attribute values
are also removed from each index file. But if the entry is turned to be
a tombstone entry, reindexing adds the removed attribute value back to
the index file.
Fix Description: In the reindexing function ldbm_back_ldbm2index, if the
entry is a tombstone entry, it skips reindexing operation unless the target
attribute is entryrdn or objectclass. If it is reindexing the objectclass,
it indexes just for the key "=nstombstone".
https://fedorahosted.org/389/ticket/48252
Reviewed by mreynolds(a)redhat.com (Thank you, Mark!!)
(cherry picked from commit ca4d38dff3bd820af2bf60c9bcc82fd64aac2556)
(cherry picked from commit 86b96278871d8b08f7c6a75379935c2183f6668f)
diff --git a/ldap/servers/slapd/back-ldbm/ldif2ldbm.c b/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
index 51fa8e0..5d18bfc 100644
--- a/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
+++ b/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
@@ -54,9 +54,12 @@
static char *sourcefile = "ldif2ldbm.c";
-#define DB2INDEX_ANCESTORID 0x1 /* index ancestorid */
-#define DB2INDEX_ENTRYRDN 0x2 /* index entryrdn */
-#define DB2LDIF_ENTRYRDN 0x4 /* export entryrdn */
+#define DB2INDEX_ANCESTORID 0x1 /* index ancestorid */
+#define DB2INDEX_ENTRYRDN 0x2 /* index entryrdn */
+#define DB2LDIF_ENTRYRDN 0x4 /* export entryrdn */
+#define DB2INDEX_OBJECTCLASS 0x10 /* for reindexing "objectclass: nstombstone" */
+
+#define LDIF2LDBM_EXTBITS(x) ((x) & 0xf)
typedef struct _export_args {
struct backentry *ep;
@@ -1704,6 +1707,7 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
struct vlvIndex *vlvip = NULL;
back_txn txn;
ID suffixid = NOID; /* holds the id of the suffix entry */
+ Slapi_Value **nstombstone_vals = NULL;
LDAPDebug( LDAP_DEBUG_TRACE, "=> ldbm_back_ldbm2index\n", 0, 0, 0 );
if ( g_get_shutdown() || c_get_shutdown() ) {
@@ -1824,7 +1828,7 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
if (strcasecmp(attrs[i]+1, LDBM_ANCESTORID_STR) == 0) {
if (task) {
slapi_task_log_notice(task, "%s: Indexing %s",
- inst->inst_name, LDBM_ENTRYRDN_STR);
+ inst->inst_name, LDBM_ANCESTORID_STR);
}
LDAPDebug2Args(LDAP_DEBUG_ANY, "%s: Indexing %s\n",
inst->inst_name, LDBM_ANCESTORID_STR);
@@ -1877,6 +1881,9 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
inst->inst_name, attrs[i] + 1);
}
} else {
+ if (strcasecmp(attrs[i]+1, SLAPI_ATTR_OBJECTCLASS) == 0) {
+ index_ext |= DB2INDEX_OBJECTCLASS;
+ }
charray_add(&indexAttrs, attrs[i]+1);
ai->ai_indexmask |= INDEX_OFFLINE;
if (task) {
@@ -1922,7 +1929,7 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
* idl composed from the ancestorid list, instead of traversing the
* entire database.
*/
- if (!indexAttrs && !index_ext && pvlv) {
+ if (!indexAttrs && !LDIF2LDBM_EXTBITS(index_ext) && pvlv) {
int err;
char **suffix_list = NULL;
@@ -2181,11 +2188,13 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
/*
* If this entry is a tombstone, update the 'nstombstonecsn' index
*/
- if(ep->ep_entry->e_flags & SLAPI_ENTRY_FLAG_TOMBSTONE){
- const CSN *tombstone_csn = NULL;
+ if (ep->ep_entry->e_flags & SLAPI_ENTRY_FLAG_TOMBSTONE) {
+ const CSN *tombstone_csn = entry_get_deletion_csn(ep->ep_entry);
char deletion_csn_str[CSN_STRSIZE];
- if((tombstone_csn = entry_get_deletion_csn(ep->ep_entry))){
+ nstombstone_vals = (Slapi_Value **) slapi_ch_calloc(2, sizeof(Slapi_Value *));
+ *nstombstone_vals = slapi_value_new_string(SLAPI_ATTR_VALUE_TOMBSTONE);
+ if (tombstone_csn) {
if (!run_from_cmdline) {
rc = dblayer_txn_begin(be, NULL, &txn);
if (0 != rc) {
@@ -2244,18 +2253,31 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
/*
* Update the attribute indexes
*/
- if (indexAttrs != NULL) {
+ if (indexAttrs) {
+ if (nstombstone_vals && !(index_ext & (DB2INDEX_ENTRYRDN|DB2INDEX_OBJECTCLASS))) {
+ /* if it is a tombstone entry, just entryrdn or "objectclass: nstombstone"
+ * need to be reindexed. the to-be-indexed list does not contain them. */
+ continue;
+ }
for (i = slapi_entry_first_attr(ep->ep_entry, &attr); i == 0;
i = slapi_entry_next_attr(ep->ep_entry, attr, &attr)) {
Slapi_Value **svals;
slapi_attr_get_type( attr, &type );
for ( j = 0; indexAttrs[j] != NULL; j++ ) {
+ int is_tombstone_obj = 0;
if ( g_get_shutdown() || c_get_shutdown() ) {
goto err_out;
}
- if (slapi_attr_type_cmp(indexAttrs[j], type,
- SLAPI_TYPE_CMP_SUBTYPE) == 0 ) {
+ if (slapi_attr_type_cmp(indexAttrs[j], type, SLAPI_TYPE_CMP_SUBTYPE) == 0) {
+ if (nstombstone_vals) {
+ if (!slapi_attr_type_cmp(indexAttrs[j], SLAPI_ATTR_OBJECTCLASS, SLAPI_TYPE_CMP_SUBTYPE)) {
+ is_tombstone_obj = 1; /* is tombstone && is objectclass. need to index "nstombstone"*/
+ } else if (slapi_attr_type_cmp(indexAttrs[j], LDBM_ENTRYRDN_STR, SLAPI_TYPE_CMP_SUBTYPE)) {
+ /* Entry is a tombstone && this index is not an entryrdn. */
+ continue;
+ }
+ }
svals = attr_get_present_values(attr);
if (!run_from_cmdline) {
@@ -2279,10 +2301,12 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
goto err_out;
}
}
- rc = index_addordel_values_sv(
- be, indexAttrs[j], svals,
- NULL, ep->ep_id, BE_INDEX_ADD, &txn);
- if (rc != 0) {
+ if (is_tombstone_obj) {
+ rc = index_addordel_values_sv(be, indexAttrs[j], nstombstone_vals, NULL, ep->ep_id, BE_INDEX_ADD, &txn);
+ } else {
+ rc = index_addordel_values_sv(be, indexAttrs[j], svals, NULL, ep->ep_id, BE_INDEX_ADD, &txn);
+ }
+ if (rc) {
LDAPDebug(LDAP_DEBUG_ANY,
"%s: ERROR: failed to update index '%s'\n",
inst->inst_name, indexAttrs[j], 0);
@@ -2328,18 +2352,16 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
}
/*
- * Update the Virtual List View indexes
+ * If it is NOT a tombstone entry, update the Virtual List View indexes.
*/
- for ( vlvidx = 0; vlvidx < numvlv; vlvidx++ ) {
+ for (vlvidx = 0; !nstombstone_vals && (vlvidx < numvlv); vlvidx++) {
char *ai = "Unknown index";
if ( g_get_shutdown() || c_get_shutdown() ) {
goto err_out;
}
- if(indexAttrs){
- if(indexAttrs[vlvidx]){
- ai = indexAttrs[vlvidx];
- }
+ if (indexAttrs && indexAttrs[vlvidx]) {
+ ai = indexAttrs[vlvidx];
}
if (!run_from_cmdline) {
rc = dblayer_txn_begin(be, NULL, &txn);
@@ -2393,7 +2415,7 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
/*
* Update the ancestorid and entryrdn index
*/
- if (!entryrdn_get_noancestorid() && index_ext & DB2INDEX_ANCESTORID) {
+ if (!entryrdn_get_noancestorid() && (index_ext & DB2INDEX_ANCESTORID)) {
rc = ldbm_ancestorid_index_entry(be, ep, BE_INDEX_ADD, NULL);
if (rc != 0) {
LDAPDebug(LDAP_DEBUG_ANY,
--
389 commits mailing list
389-commits@%(host_name)s
http://lists.fedoraproject.org/postorius/389-commits@lists.fedoraproject.org
8 years, 8 months