mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-01-28 09:06:44 -06:00
Sort policies numerically in pwpolicy-find
Password policies in pwpolicy-find are now sorted in the expected numerical manner. Also tweaks one of the unit tests so that it tests this behaviour. https://fedorahosted.org/freeipa/ticket/3039
This commit is contained in:
parent
be8a9e6ddb
commit
208e6930de
@ -481,7 +481,7 @@ class pwpolicy_find(LDAPSearch):
|
|||||||
# policies with higher priority (lower number) will be at the
|
# policies with higher priority (lower number) will be at the
|
||||||
# beginning of the list
|
# beginning of the list
|
||||||
try:
|
try:
|
||||||
cospriority = entry[1]['cospriority'][0]
|
cospriority = int(entry[1]['cospriority'][0])
|
||||||
except KeyError:
|
except KeyError:
|
||||||
# if cospriority is not present in the entry, rather return 0
|
# if cospriority is not present in the entry, rather return 0
|
||||||
# than crash
|
# than crash
|
||||||
|
@ -39,7 +39,7 @@ class test_pwpolicy(XMLRPC_test):
|
|||||||
user = u'testuser12'
|
user = u'testuser12'
|
||||||
kw = {'cospriority': 1, 'krbminpwdlife': 30, 'krbmaxpwdlife': 40, 'krbpwdhistorylength': 5, 'krbpwdminlength': 6 }
|
kw = {'cospriority': 1, 'krbminpwdlife': 30, 'krbmaxpwdlife': 40, 'krbpwdhistorylength': 5, 'krbpwdminlength': 6 }
|
||||||
kw2 = {'cospriority': 2, 'krbminpwdlife': 40, 'krbmaxpwdlife': 60, 'krbpwdhistorylength': 8, 'krbpwdminlength': 9 }
|
kw2 = {'cospriority': 2, 'krbminpwdlife': 40, 'krbmaxpwdlife': 60, 'krbpwdhistorylength': 8, 'krbpwdminlength': 9 }
|
||||||
kw3 = {'cospriority': 3, 'krbminpwdlife': 50, 'krbmaxpwdlife': 30, 'krbpwdhistorylength': 3, 'krbpwdminlength': 4 }
|
kw3 = {'cospriority': 10, 'krbminpwdlife': 50, 'krbmaxpwdlife': 30, 'krbpwdhistorylength': 3, 'krbpwdminlength': 4 }
|
||||||
global_policy = u'global_policy'
|
global_policy = u'global_policy'
|
||||||
|
|
||||||
def test_1_pwpolicy_add(self):
|
def test_1_pwpolicy_add(self):
|
||||||
@ -177,12 +177,14 @@ class test_pwpolicy(XMLRPC_test):
|
|||||||
assert_attr_equal(entry, 'krbmaxpwdlife', '30')
|
assert_attr_equal(entry, 'krbmaxpwdlife', '30')
|
||||||
assert_attr_equal(entry, 'krbpwdhistorylength', '3')
|
assert_attr_equal(entry, 'krbpwdhistorylength', '3')
|
||||||
assert_attr_equal(entry, 'krbpwdminlength', '4')
|
assert_attr_equal(entry, 'krbpwdminlength', '4')
|
||||||
assert_attr_equal(entry, 'cospriority', '3')
|
assert_attr_equal(entry, 'cospriority', '10')
|
||||||
|
|
||||||
def test_c_pwpolicy_find(self):
|
def test_c_pwpolicy_find(self):
|
||||||
"""Test that password policies are sorted and reported properly"""
|
"""Test that password policies are sorted and reported properly"""
|
||||||
result = api.Command['pwpolicy_find']()['result']
|
result = api.Command['pwpolicy_find']()['result']
|
||||||
assert len(result) == 4
|
assert len(result) == 4
|
||||||
|
|
||||||
|
# Test that policies are sorted in numerical order
|
||||||
assert result[0]['cn'] == (self.group,)
|
assert result[0]['cn'] == (self.group,)
|
||||||
assert result[1]['cn'] == (self.group2,)
|
assert result[1]['cn'] == (self.group2,)
|
||||||
assert result[2]['cn'] == (self.group3,)
|
assert result[2]['cn'] == (self.group3,)
|
||||||
|
Loading…
Reference in New Issue
Block a user