Blame SOURCES/Add-PKINIT-test-case-for-generic-client-cert.patch

749169
From 5d072bc7e890e18903a18d22ecda7662db1d603e Mon Sep 17 00:00:00 2001
749169
From: Greg Hudson <ghudson@mit.edu>
749169
Date: Fri, 25 Aug 2017 12:39:14 -0400
749169
Subject: [PATCH] Add PKINIT test case for generic client cert
749169
749169
In t_pkinit.py, add a test case where a client cert with no extensions
749169
is authorized via subject and issuer using a pkinit_cert_match string
749169
attribute.
749169
749169
ticket: 8562
749169
(cherry picked from commit 8c5d50888aab554239fd51306e79c5213833c898)
749169
---
749169
 src/tests/t_pkinit.py | 10 ++++++++++
749169
 1 file changed, 10 insertions(+)
749169
749169
diff --git a/src/tests/t_pkinit.py b/src/tests/t_pkinit.py
749169
index 5a0624de7..22ab81743 100755
749169
--- a/src/tests/t_pkinit.py
749169
+++ b/src/tests/t_pkinit.py
749169
@@ -26,6 +26,7 @@ user_enc_p12 = os.path.join(certs, 'user-enc.p12')
749169
 user_upn_p12 = os.path.join(certs, 'user-upn.p12')
749169
 user_upn2_p12 = os.path.join(certs, 'user-upn2.p12')
749169
 user_upn3_p12 = os.path.join(certs, 'user-upn3.p12')
749169
+generic_p12 = os.path.join(certs, 'generic.p12')
749169
 path = os.path.join(os.getcwd(), 'testdir', 'tmp-pkinit-certs')
749169
 path_enc = os.path.join(os.getcwd(), 'testdir', 'tmp-pkinit-certs-enc')
749169
 
749169
@@ -65,6 +66,7 @@ p12_identity = 'PKCS12:%s' % user_p12
749169
 p12_upn_identity = 'PKCS12:%s' % user_upn_p12
749169
 p12_upn2_identity = 'PKCS12:%s' % user_upn2_p12
749169
 p12_upn3_identity = 'PKCS12:%s' % user_upn3_p12
749169
+p12_generic_identity = 'PKCS12:%s' % generic_p12
749169
 p12_enc_identity = 'PKCS12:%s' % user_enc_p12
749169
 p11_identity = 'PKCS11:soft-pkcs11.so'
749169
 p11_token_identity = ('PKCS11:module_name=soft-pkcs11.so:'
749169
@@ -342,6 +344,14 @@ realm.kinit(realm.user_princ,
749169
             flags=['-X', 'X509_user_identity=%s' % p12_identity],
749169
             expected_code=1, expected_msg=msg)
749169
 
749169
+# Authorize a client cert with no PKINIT extensions using subject and
749169
+# issuer.  (Relies on EKU checking being turned off.)
749169
+rule = '&&<SUBJECT>CN=user$<ISSUER>O=MIT,'
749169
+realm.run([kadminl, 'setstr', realm.user_princ, 'pkinit_cert_match', rule])
749169
+realm.kinit(realm.user_princ,
749169
+            flags=['-X', 'X509_user_identity=%s' % p12_generic_identity])
749169
+realm.klist(realm.user_princ)
749169
+
749169
 if not have_soft_pkcs11:
749169
     skip_rest('PKINIT PKCS11 tests', 'soft-pkcs11.so not found')
749169