Path: blob/main/crypto/krb5/src/tests/gssapi/t_authind.py
34889 views
from k5test import *12# Test authentication indicators. Load the test preauth module so we3# can control the indicators asserted.4testpreauth = os.path.join(buildtop, 'plugins', 'preauth', 'test', 'test.so')5conf = {'plugins': {'kdcpreauth': {'module': 'test:' + testpreauth},6'clpreauth': {'module': 'test:' + testpreauth}}}7realm = K5Realm(krb5_conf=conf)8realm.run([kadminl, 'addprinc', '-randkey', 'service/1'])9realm.run([kadminl, 'addprinc', '-randkey', 'service/2'])10realm.run([kadminl, 'modprinc', '+requires_preauth', realm.user_princ])11realm.run([kadminl, 'setstr', 'service/1', 'require_auth', 'superstrong'])12realm.run([kadminl, 'setstr', 'service/2', 'require_auth', 'one two'])13realm.run([kadminl, 'xst', 'service/1'])14realm.run([kadminl, 'xst', 'service/2'])1516realm.kinit(realm.user_princ, password('user'),17['-X', 'indicators=superstrong'])18out = realm.run(['./t_srcattrs', 'p:service/1'])19if ('Attribute auth-indicators Authenticated Complete') not in out:20fail('Expected attribute type data not seen')21# UTF8 "superstrong"22if '73757065727374726f6e67' not in out:23fail('Expected auth indicator not seen in name attributes')2425msg = 'gss_init_sec_context: KDC policy rejects request'26realm.run(['./t_srcattrs', 'p:service/2'], expected_code=1, expected_msg=msg)2728realm.kinit(realm.user_princ, password('user'), ['-X', 'indicators=one two'])29out = realm.run(['./t_srcattrs', 'p:service/2'])30# Hexadecimal "one" and "two"31if '6f6e65' not in out or '74776f' not in out:32fail('Expected auth indicator not seen in name attributes')3334realm.stop()3536# Test the FAST encrypted challenge auth indicator.37kdcconf = {'realms': {'$realm': {'encrypted_challenge_indicator': 'fast'}}}38realm = K5Realm(kdc_conf=kdcconf)39realm.run([kadminl, 'modprinc', '+requires_preauth', realm.user_princ])40realm.run([kadminl, 'xst', realm.host_princ])41realm.kinit(realm.user_princ, password('user'))42realm.kinit(realm.user_princ, password('user'), ['-T', realm.ccache])43out = realm.run(['./t_srcattrs', 'p:' + realm.host_princ])44if ('Attribute auth-indicators Authenticated Complete') not in out:45fail('Expected attribute type not seen')46if '66617374' not in out:47fail('Expected auth indicator not seen in name attributes')4849realm.stop()50success('GSSAPI auth indicator tests')515253