|
Packit |
fd8b60 |
from k5test import *
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
# This file contains tests for kadmin command parsing. Principal
|
|
Packit |
fd8b60 |
# flags (which can also be used in kadm5.acl or krb5.conf) are tested
|
|
Packit |
fd8b60 |
# in t_princflags.py.
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
# kadmin recognizes time intervals using either the
|
|
Packit |
fd8b60 |
# krb5_string_to_deltat() formats or the relative getdate.y formats.
|
|
Packit |
fd8b60 |
# (Absolute getdate.y formats also work with the current time
|
|
Packit |
fd8b60 |
# subtracted; this isn't very useful and we won't test it here.)
|
|
Packit |
fd8b60 |
intervals = (
|
|
Packit |
fd8b60 |
# krb5_string_to_deltat() formats. Whitespace ( \t\n) is allowed
|
|
Packit |
fd8b60 |
# before or between most elements or at the end, but not after
|
|
Packit |
fd8b60 |
# 's'. Negative or oversized numbers are allowed in most places,
|
|
Packit |
fd8b60 |
# but not after the first number in an HH:MM:SS form.
|
|
Packit |
fd8b60 |
('28s', '0 days 00:00:28'),
|
|
Packit |
fd8b60 |
('7m ', '0 days 00:07:00'),
|
|
Packit |
fd8b60 |
('6m 9s', '0 days 00:06:09'),
|
|
Packit |
fd8b60 |
('2h', '0 days 02:00:00'),
|
|
Packit |
fd8b60 |
('2h-5s', '0 days 01:59:55'),
|
|
Packit |
fd8b60 |
('2h3m', '0 days 02:03:00'),
|
|
Packit |
fd8b60 |
('2h3m5s', '0 days 02:03:05'),
|
|
Packit |
fd8b60 |
('5d ', '5 days 00:00:00'),
|
|
Packit |
fd8b60 |
('5d-48s', '4 days 23:59:12'),
|
|
Packit |
fd8b60 |
('5d18m', '5 days 00:18:00'),
|
|
Packit |
fd8b60 |
('5d -6m56s', '4 days 23:54:56'),
|
|
Packit |
fd8b60 |
('5d4h', '5 days 04:00:00'),
|
|
Packit |
fd8b60 |
('5d4h 1s', '5 days 04:00:01'),
|
|
Packit |
fd8b60 |
('5d4h3m', '5 days 04:03:00'),
|
|
Packit |
fd8b60 |
(' \t 15d \n 4h 3m 2s', '15 days 04:03:02'),
|
|
Packit |
fd8b60 |
('10-8:45:0', '10 days 08:45:00'),
|
|
Packit |
fd8b60 |
('1000:67:99', '41 days 17:08:39'),
|
|
Packit |
fd8b60 |
('999:11', '41 days 15:11:00'),
|
|
Packit |
fd8b60 |
('382512', '4 days 10:15:12'),
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
# getdate.y relative formats (and "never", which is handled
|
|
Packit |
fd8b60 |
# specially as a zero interval). Any number of relative forms can
|
|
Packit |
fd8b60 |
# be specified in any order. Whitespace is ignored before or
|
|
Packit |
fd8b60 |
# after any token. "month" and "year" are allowed as units but
|
|
Packit |
fd8b60 |
# depend on the current time, so we won't test them. Plural unit
|
|
Packit |
fd8b60 |
# names are treated identically to singular unit names. Numbers
|
|
Packit |
fd8b60 |
# before unit names are optional and may be signed; there are also
|
|
Packit |
fd8b60 |
# aliases for some numbers. "ago" inverts the interval up to the
|
|
Packit |
fd8b60 |
# point where it appears.
|
|
Packit |
fd8b60 |
('never', '0 days 00:00:00'),
|
|
Packit |
fd8b60 |
('fortnight', '14 days 00:00:00'),
|
|
Packit |
fd8b60 |
('3 day ago 4 weeks 8 hours', '25 days 08:00:00'),
|
|
Packit |
fd8b60 |
('8 second -3 secs 5 minute ago 63 min', '0 days 00:57:55'),
|
|
Packit |
fd8b60 |
('min mins min mins min', '0 days 00:05:00'),
|
|
Packit |
fd8b60 |
('tomorrow tomorrow today yesterday now last minute', '0 days 23:59:00'),
|
|
Packit |
fd8b60 |
('this second next minute first hour third fortnight fourth day '
|
|
Packit |
fd8b60 |
'fifth weeks sixth sec seventh secs eighth second ninth mins tenth '
|
|
Packit |
fd8b60 |
'day eleventh min twelfth sec', '91 days 01:22:34'))
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
realm = K5Realm(create_host=False, get_creds=False)
|
|
Packit |
fd8b60 |
realm.run([kadminl, 'addpol', 'pol'])
|
|
Packit |
fd8b60 |
for instr, outstr in intervals:
|
|
Packit |
fd8b60 |
realm.run([kadminl, 'modprinc', '-maxlife', instr, realm.user_princ])
|
|
Packit |
fd8b60 |
msg = 'Maximum ticket life: ' + outstr + '\n'
|
|
Packit |
fd8b60 |
realm.run([kadminl, 'getprinc', realm.user_princ], expected_msg=msg)
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
realm.run([kadminl, 'modprinc', '-maxrenewlife', instr, realm.user_princ])
|
|
Packit |
fd8b60 |
msg = 'Maximum renewable life: ' + outstr + '\n'
|
|
Packit |
fd8b60 |
realm.run([kadminl, 'getprinc', realm.user_princ], expected_msg=msg)
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
realm.run([kadminl, 'modpol', '-maxlife', instr, 'pol'])
|
|
Packit |
fd8b60 |
msg = 'Maximum password life: ' + outstr + '\n'
|
|
Packit |
fd8b60 |
realm.run([kadminl, 'getpol', 'pol'], expected_msg=msg)
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
realm.run([kadminl, 'modpol', '-minlife', instr, 'pol'])
|
|
Packit |
fd8b60 |
msg = 'Minimum password life: ' + outstr + '\n'
|
|
Packit |
fd8b60 |
realm.run([kadminl, 'getpol', 'pol'], expected_msg=msg)
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
realm.run([kadminl, 'modpol', '-failurecountinterval', instr, 'pol'])
|
|
Packit |
fd8b60 |
msg = 'Password failure count reset interval: ' + outstr + '\n'
|
|
Packit |
fd8b60 |
realm.run([kadminl, 'getpol', 'pol'], expected_msg=msg)
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
realm.run([kadminl, 'modpol', '-lockoutduration', instr, 'pol'])
|
|
Packit |
fd8b60 |
msg = 'Password lockout duration: ' + outstr + '\n'
|
|
Packit |
fd8b60 |
realm.run([kadminl, 'getpol', 'pol'], expected_msg=msg)
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
success('kadmin command parsing tests')
|