summaryrefslogtreecommitdiffstats
path: root/Use-expected_trace-in-test-scripts.patch
blob: 39807c8431c750e4b3742b9e84dab9e4546dd30a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
From 52eeabfdeb9a91c6e4c7124b38fa6915df37f8bf Mon Sep 17 00:00:00 2001
From: Greg Hudson <ghudson@mit.edu>
Date: Tue, 17 Jan 2017 11:25:22 -0500
Subject: [PATCH] Use expected_trace in test scripts

(cherry picked from commit 7b7e5d964e5d020fdda3fb9843d9b8cf8b29a6f8)
---
 src/tests/t_general.py | 24 ++++++++----------------
 src/tests/t_pkinit.py  | 15 ++++++---------
 2 files changed, 14 insertions(+), 25 deletions(-)

diff --git a/src/tests/t_general.py b/src/tests/t_general.py
index 6d523fe45..16bf6c5e3 100755
--- a/src/tests/t_general.py
+++ b/src/tests/t_general.py
@@ -47,21 +47,13 @@ if 'not found in Kerberos database' not in out:
     fail('Expected error message not seen in kinit -C output')
 
 # Spot-check KRB5_TRACE output
-tracefile = os.path.join(realm.testdir, 'trace')
-realm.run(['env', 'KRB5_TRACE=' + tracefile, kinit, realm.user_princ],
-          input=(password('user') + "\n"))
-f = open(tracefile, 'r')
-trace = f.read()
-f.close()
-expected = ('Sending initial UDP request',
-            'Received answer',
-            'Selected etype info',
-            'AS key obtained',
-            'Decrypted AS reply',
-            'FAST negotiation: available',
-            'Storing user@KRBTEST.COM')
-for e in expected:
-    if e not in trace:
-        fail('Expected output not in kinit trace log')
+expected_trace = ('Sending initial UDP request',
+                  'Received answer',
+                  'Selected etype info',
+                  'AS key obtained',
+                  'Decrypted AS reply',
+                  'FAST negotiation: available',
+                  'Storing user@KRBTEST.COM')
+realm.kinit(realm.user_princ, password('user'), expected_trace=expected_trace)
 
 success('FAST kinit, trace logging')
diff --git a/src/tests/t_pkinit.py b/src/tests/t_pkinit.py
index 183977750..f56141564 100755
--- a/src/tests/t_pkinit.py
+++ b/src/tests/t_pkinit.py
@@ -176,19 +176,16 @@ realm.klist(realm.user_princ)
 
 # Test a DH parameter renegotiation by temporarily setting a 4096-bit
 # minimum on the KDC.
-tracefile = os.path.join(realm.testdir, 'trace')
 minbits_kdc_conf = {'realms': {'$realm': {'pkinit_dh_min_bits': '4096'}}}
 minbits_env = realm.special_env('restrict', True, kdc_conf=minbits_kdc_conf)
 realm.stop_kdc()
 realm.start_kdc(env=minbits_env)
-realm.run(['env', 'KRB5_TRACE=' + tracefile, kinit, '-X',
-           'X509_user_identity=' + file_identity, realm.user_princ])
-with open(tracefile, 'r') as f:
-    trace = f.read()
-if ('Key parameters not accepted' not in trace or
-    'Preauth tryagain input types' not in trace or
-    'trying again with KDC-provided parameters' not in trace):
-    fail('DH renegotiation steps not found in kinit trace log')
+expected_trace = ('Key parameters not accepted',
+                  'Preauth tryagain input types',
+                  'trying again with KDC-provided parameters')
+realm.kinit(realm.user_princ,
+            flags=['-X', 'X509_user_identity=%s' % file_identity],
+            expected_trace=expected_trace)
 realm.stop_kdc()
 realm.start_kdc()