Skip to content

Commit

Permalink
Increase use of expected_msg in GSS tests
Browse files Browse the repository at this point in the history
This prevents additional debugging output from breaking the tests, and
reduces collision with k5test.py's output().
  • Loading branch information
frozencemetery authored and greghudson committed Aug 29, 2021
1 parent 0232e34 commit 4b170a1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 22 deletions.
7 changes: 3 additions & 4 deletions src/tests/gssapi/t_credstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,9 @@
mark('rcache')
# t_credstore -r should produce a replay error normally, but not with
# rcache set to "none:".
output = realm.run(['./t_credstore', '-r', '-a', 'p:' + realm.host_princ],
expected_code=1)
if 'gss_accept_sec_context(2): Request is a replay' not in output:
fail('Expected replay error not seen in t_credstore output')
realm.run(['./t_credstore', '-r', '-a', 'p:' + realm.host_princ],
expected_code=1,
expected_msg='gss_accept_sec_context(2): Request is a replay')
realm.run(['./t_credstore', '-r', '-a', 'p:' + realm.host_princ,
'rcache', 'none:'])

Expand Down
31 changes: 13 additions & 18 deletions src/tests/gssapi/t_gssapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@

# Verify that we can't acquire acceptor creds without a keytab.
os.remove(realm.keytab)
output = realm.run(['./t_accname', 'p:abc'], expected_code=1)
if ('gss_acquire_cred: Keytab' not in output or
'nonexistent or empty' not in output):
out = realm.run(['./t_accname', 'p:abc'], expected_code=1)
if ('gss_acquire_cred: Keytab' not in out or
'nonexistent or empty' not in out):
fail('Expected error message not seen for nonexistent keytab')

realm.stop()
Expand Down Expand Up @@ -143,23 +143,18 @@
realm.run(['./t_inq_cred', '-k', '-b'], expected_msg=realm.host_princ)

# Test gss_export_name behavior.
out = realm.run(['./t_export_name', 'u:x'])
if out != '0401000B06092A864886F7120102020000000D78404B5242544553542E434F4D\n':
fail('Unexpected output from t_export_name (krb5 username)')
output = realm.run(['./t_export_name', '-s', 'u:xyz'])
if output != '0401000806062B06010505020000000378797A\n':
fail('Unexpected output from t_export_name (SPNEGO username)')
output = realm.run(['./t_export_name', 'p:a@b'])
if output != '0401000B06092A864886F71201020200000003614062\n':
fail('Unexpected output from t_export_name (krb5 principal)')
output = realm.run(['./t_export_name', '-s', 'p:a@b'])
if output != '0401000806062B060105050200000003614062\n':
fail('Unexpected output from t_export_name (SPNEGO krb5 principal)')
realm.run(['./t_export_name', 'u:x'], expected_msg=\
'0401000B06092A864886F7120102020000000D78404B5242544553542E434F4D\n')
realm.run(['./t_export_name', '-s', 'u:xyz'],
expected_msg='0401000806062B06010505020000000378797A\n')
realm.run(['./t_export_name', 'p:a@b'],
expected_msg='0401000B06092A864886F71201020200000003614062\n')
realm.run(['./t_export_name', '-s', 'p:a@b'],
expected_msg='0401000806062B060105050200000003614062\n')

# Test that composite-export tokens can be imported.
output = realm.run(['./t_export_name', '-c', 'p:a@b'])
if (output != '0402000B06092A864886F7120102020000000361406200000000\n'):
fail('Unexpected output from t_export_name (using COMPOSITE_EXPORT)')
realm.run(['./t_export_name', '-c', 'p:a@b'], expected_msg=
'0402000B06092A864886F7120102020000000361406200000000\n')

# Test gss_inquire_mechs_for_name behavior.
krb5_mech = '{ 1 2 840 113554 1 2 2 }'
Expand Down

0 comments on commit 4b170a1

Please sign in to comment.