mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Netgroup nisdomain and hosts validation
nisdomain validation: Added pattern to the 'nisdomain' parameter to validate the specified nisdomain name. According to most common use cases the same pattern as for netgroup should fit. Unit-tests added. https://fedorahosted.org/freeipa/ticket/2448 'add_external_pre_callback' function was created to allow validation of all external members. Validation is based on usage of objects primary key parameter. The 'add_external_pre_callback' fucntion has to be called directly from in the 'pre_callback' function. This change affects netgroup, hbacrule and sudorule commands. For hostname, the validator allows non-fqdn and underscore characters. validate_hostname function in ipalib.util was modified and contains additional option that allows hostname to contain underscore characters. This option is disabled by default. Unit-tests added. https://fedorahosted.org/freeipa/ticket/2447
This commit is contained in:
committed by
Martin Kosek
parent
159e848d85
commit
5cfee2338d
@@ -57,6 +57,9 @@ user2 = u'pexample'
|
||||
group1 = u'testgroup'
|
||||
|
||||
invalidnetgroup1=u'+badnetgroup'
|
||||
invalidnisdomain1=u'domain1,domain2'
|
||||
invalidnisdomain2=u'+invalidnisdomain'
|
||||
invalidhost=u'+invalid&host'
|
||||
|
||||
class test_netgroup(Declarative):
|
||||
"""
|
||||
@@ -105,6 +108,20 @@ class test_netgroup(Declarative):
|
||||
),
|
||||
|
||||
|
||||
dict(
|
||||
desc='Test an invalid nisdomain1 name %r' % invalidnisdomain1,
|
||||
command=('netgroup_add', [netgroup1], dict(description=u'Test',nisdomainname=invalidnisdomain1)),
|
||||
expected=errors.ValidationError(name='nisdomainname', error='may only include letters, numbers, _, - and .'),
|
||||
),
|
||||
|
||||
|
||||
dict(
|
||||
desc='Test an invalid nisdomain2 name %r' % invalidnisdomain2,
|
||||
command=('netgroup_add', [netgroup1], dict(description=u'Test',nisdomainname=invalidnisdomain2)),
|
||||
expected=errors.ValidationError(name='nisdomainname', error='may only include letters, numbers, _, - and .'),
|
||||
),
|
||||
|
||||
|
||||
dict(
|
||||
desc='Create %r' % netgroup1,
|
||||
command=('netgroup_add', [netgroup1],
|
||||
@@ -333,6 +350,14 @@ class test_netgroup(Declarative):
|
||||
),
|
||||
|
||||
|
||||
dict(
|
||||
desc='Add invalid host %r to netgroup %r' % (invalidhost, netgroup1),
|
||||
command=('netgroup_add_member', [netgroup1], dict(host=invalidhost)),
|
||||
expected=errors.ValidationError(name='host',
|
||||
error='only letters, numbers, _, and - are allowed. - must not be the DNS label character'),
|
||||
),
|
||||
|
||||
|
||||
dict(
|
||||
desc='Add host %r to netgroup %r' % (host1, netgroup1),
|
||||
command=(
|
||||
@@ -756,7 +781,7 @@ class test_netgroup(Declarative):
|
||||
'cn': [netgroup1],
|
||||
'description': [u'Test netgroup 1'],
|
||||
'nisdomainname': [u'%s' % api.env.domain],
|
||||
'externalhost': [u'unknown'],
|
||||
'externalhost': [unknown_host],
|
||||
},
|
||||
),
|
||||
),
|
||||
@@ -777,7 +802,7 @@ class test_netgroup(Declarative):
|
||||
'cn': [netgroup1],
|
||||
'description': [u'Test netgroup 1'],
|
||||
'nisdomainname': [u'%s' % api.env.domain],
|
||||
'externalhost': [u'unknown'],
|
||||
'externalhost': [unknown_host],
|
||||
},
|
||||
),
|
||||
),
|
||||
@@ -800,7 +825,7 @@ class test_netgroup(Declarative):
|
||||
'cn': [netgroup1],
|
||||
'description': [u'Test netgroup 1'],
|
||||
'nisdomainname': [u'%s' % api.env.domain],
|
||||
'externalhost': [u'unknown'],
|
||||
'externalhost': [unknown_host],
|
||||
},
|
||||
],
|
||||
),
|
||||
@@ -824,7 +849,7 @@ class test_netgroup(Declarative):
|
||||
'cn': [netgroup1],
|
||||
'description': [u'Test netgroup 1'],
|
||||
'nisdomainname': [u'%s' % api.env.domain],
|
||||
'externalhost': [u'unknown'],
|
||||
'externalhost': [unknown_host],
|
||||
},
|
||||
],
|
||||
),
|
||||
@@ -848,7 +873,7 @@ class test_netgroup(Declarative):
|
||||
'cn': [netgroup1],
|
||||
'description': [u'Test netgroup 1'],
|
||||
'nisdomainname': [u'%s' % api.env.domain],
|
||||
'externalhost': [u'unknown'],
|
||||
'externalhost': [unknown_host],
|
||||
},
|
||||
{
|
||||
'dn': fuzzy_netgroupdn,
|
||||
@@ -878,7 +903,7 @@ class test_netgroup(Declarative):
|
||||
'cn': [netgroup1],
|
||||
'description': [u'Updated netgroup 1'],
|
||||
'nisdomainname': [u'%s' % api.env.domain],
|
||||
'externalhost': [u'unknown'],
|
||||
'externalhost': [unknown_host],
|
||||
},
|
||||
),
|
||||
),
|
||||
@@ -913,7 +938,7 @@ class test_netgroup(Declarative):
|
||||
'cn': [netgroup1],
|
||||
'description': [u'Updated netgroup 1'],
|
||||
'nisdomainname': [u'%s' % api.env.domain],
|
||||
'externalhost': [u'unknown'],
|
||||
'externalhost': [unknown_host],
|
||||
},
|
||||
),
|
||||
),
|
||||
@@ -947,7 +972,7 @@ class test_netgroup(Declarative):
|
||||
'cn': [netgroup1],
|
||||
'description': [u'Updated netgroup 1'],
|
||||
'nisdomainname': [u'%s' % api.env.domain],
|
||||
'externalhost': [u'unknown'],
|
||||
'externalhost': [unknown_host],
|
||||
},
|
||||
),
|
||||
),
|
||||
@@ -980,7 +1005,7 @@ class test_netgroup(Declarative):
|
||||
'cn': [netgroup1],
|
||||
'description': [u'Updated netgroup 1'],
|
||||
'nisdomainname': [u'%s' % api.env.domain],
|
||||
'externalhost': [u'unknown'],
|
||||
'externalhost': [unknown_host],
|
||||
},
|
||||
),
|
||||
),
|
||||
@@ -1012,7 +1037,7 @@ class test_netgroup(Declarative):
|
||||
'cn': [netgroup1],
|
||||
'description': [u'Updated netgroup 1'],
|
||||
'nisdomainname': [u'%s' % api.env.domain],
|
||||
'externalhost': [u'unknown'],
|
||||
'externalhost': [unknown_host],
|
||||
},
|
||||
),
|
||||
),
|
||||
@@ -1043,7 +1068,7 @@ class test_netgroup(Declarative):
|
||||
'cn': [netgroup1],
|
||||
'description': [u'Updated netgroup 1'],
|
||||
'nisdomainname': [u'%s' % api.env.domain],
|
||||
'externalhost': [u'unknown'],
|
||||
'externalhost': [unknown_host],
|
||||
},
|
||||
),
|
||||
),
|
||||
@@ -1074,7 +1099,7 @@ class test_netgroup(Declarative):
|
||||
'cn': [netgroup1],
|
||||
'description': [u'Updated netgroup 1'],
|
||||
'nisdomainname': [u'%s' % api.env.domain],
|
||||
'externalhost': [u'unknown'],
|
||||
'externalhost': [unknown_host],
|
||||
},
|
||||
),
|
||||
),
|
||||
@@ -1105,7 +1130,7 @@ class test_netgroup(Declarative):
|
||||
'cn': [netgroup1],
|
||||
'description': [u'Updated netgroup 1'],
|
||||
'nisdomainname': [u'%s' % api.env.domain],
|
||||
'externalhost': [u'unknown'],
|
||||
'externalhost': [unknown_host],
|
||||
},
|
||||
),
|
||||
),
|
||||
@@ -1136,7 +1161,7 @@ class test_netgroup(Declarative):
|
||||
'cn': [netgroup1],
|
||||
'description': [u'Updated netgroup 1'],
|
||||
'nisdomainname': [u'%s' % api.env.domain],
|
||||
'externalhost': [u'unknown'],
|
||||
'externalhost': [unknown_host],
|
||||
},
|
||||
),
|
||||
),
|
||||
@@ -1167,7 +1192,7 @@ class test_netgroup(Declarative):
|
||||
'cn': [netgroup1],
|
||||
'description': [u'Updated netgroup 1'],
|
||||
'nisdomainname': [u'%s' % api.env.domain],
|
||||
'externalhost': [u'unknown'],
|
||||
'externalhost': [unknown_host],
|
||||
},
|
||||
),
|
||||
),
|
||||
@@ -1198,7 +1223,7 @@ class test_netgroup(Declarative):
|
||||
'cn': [netgroup1],
|
||||
'description': [u'Updated netgroup 1'],
|
||||
'nisdomainname': [u'%s' % api.env.domain],
|
||||
'externalhost': [u'unknown'],
|
||||
'externalhost': [unknown_host],
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user