Blame src/tests/t_skew.py

Packit fd8b60
from k5test import *
Packit fd8b60
Packit fd8b60
# Create a realm with the KDC one hour in the past.
Packit fd8b60
realm = K5Realm(start_kdc=False)
Packit fd8b60
realm.start_kdc(['-T', '-3600'])
Packit fd8b60
Packit fd8b60
# kinit (no preauth) should work, and should set a clock skew allowing
Packit fd8b60
# kvno to work, with or without FAST.
Packit fd8b60
mark('kdc_timesync enabled, no preauth')
Packit fd8b60
realm.kinit(realm.user_princ, password('user'))
Packit fd8b60
realm.run([kvno, realm.host_princ])
Packit fd8b60
realm.kinit(realm.user_princ, password('user'), flags=['-T', realm.ccache])
Packit fd8b60
realm.run([kvno, realm.host_princ])
Packit fd8b60
realm.run([kdestroy])
Packit fd8b60
Packit fd8b60
# kinit (with preauth) should work, with or without FAST.
Packit fd8b60
mark('kdc_timesync enabled, with preauth')
Packit fd8b60
realm.run([kadminl, 'modprinc', '+requires_preauth', 'user'])
Packit fd8b60
realm.kinit(realm.user_princ, password('user'))
Packit fd8b60
realm.run([kvno, realm.host_princ])
Packit fd8b60
realm.kinit(realm.user_princ, password('user'), flags=['-T', realm.ccache])
Packit fd8b60
realm.run([kvno, realm.host_princ])
Packit fd8b60
realm.run([kdestroy])
Packit fd8b60
Packit fd8b60
realm.stop()
Packit fd8b60
Packit fd8b60
# Repeat the above tests with kdc_timesync disabled.
Packit fd8b60
conf = {'libdefaults': {'kdc_timesync': '0'}}
Packit fd8b60
realm = K5Realm(start_kdc=False, krb5_conf=conf)
Packit fd8b60
realm.start_kdc(['-T', '-3600'])
Packit fd8b60
Packit fd8b60
# Get tickets to use for FAST kinit tests.  The start time offset is
Packit fd8b60
# ignored by the KDC since we aren't getting postdatable tickets, but
Packit fd8b60
# serves to suppress the client clock skew check on the KDC reply.
Packit fd8b60
fast_cache = realm.ccache + '.fast'
Packit fd8b60
realm.kinit(realm.user_princ, password('user'),
Packit fd8b60
            flags=['-s', '-3600s', '-c', fast_cache])
Packit fd8b60
Packit fd8b60
# kinit should detect too much skew in the KDC response.  kinit with
Packit fd8b60
# FAST should fail from the KDC since the armor AP-REQ won't be valid.
Packit fd8b60
mark('KDC timesync disabled, no preauth')
Packit fd8b60
realm.kinit(realm.user_princ, password('user'), expected_code=1,
Packit fd8b60
            expected_msg='Clock skew too great in KDC reply')
Packit fd8b60
realm.kinit(realm.user_princ, None, flags=['-T', fast_cache], expected_code=1,
Packit fd8b60
            expected_msg='Clock skew too great while')
Packit fd8b60
Packit fd8b60
# kinit (with preauth) should fail from the KDC, with or without FAST.
Packit fd8b60
mark('KDC timesync disabled, with preauth')
Packit fd8b60
realm.run([kadminl, 'modprinc', '+requires_preauth', 'user'])
Packit fd8b60
realm.kinit(realm.user_princ, password('user'), expected_code=1,
Packit fd8b60
            expected_msg='Clock skew too great while')
Packit fd8b60
realm.kinit(realm.user_princ, None, flags=['-T', fast_cache], expected_code=1,
Packit fd8b60
            expected_msg='Clock skew too great while')
Packit fd8b60
Packit fd8b60
success('Clock skew tests')