Skip to content

Commit 33ba083

Browse files
committed
Add tests for delegation and ccache mode setting
Signed-off-by: Simo Sorce <simo@redhat.com> Reviewed-by: Robbie Harwood <rharwood@redhat.com> Closes #112
1 parent f8f308f commit 33ba083

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

tests/httpd.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ CoreDumpDirectory /tmp
132132
GssapiCredStore ccache:${HTTPROOT}/tmp/httpd_krb5_ccache
133133
GssapiCredStore client_keytab:${HTTPROOT}/http.keytab
134134
GssapiCredStore keytab:${HTTPROOT}/http.keytab
135+
GssapiDelegCcacheDir ${HTTPROOT}
136+
GssapiDelegCcachePerms mode:0666
135137
GssapiBasicAuth Off
136138
GssapiAllowedMech krb5
137139
Require valid-user

tests/magtests.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,6 @@ def kinit_user(testdir, kdcenv):
257257
kinit.wait()
258258
if kinit.returncode != 0:
259259
raise ValueError('kinit failed')
260-
261260
return testenv
262261

263262

@@ -388,6 +387,8 @@ def test_basic_auth_krb5(testdir, testenv, testlog):
388387
keysenv = setup_keys(testdir, kdcenv)
389388
testenv = kinit_user(testdir, kdcenv)
390389

390+
testenv['DELEGCCACHE'] = os.path.join(testdir, 'httpd',
391+
USR_NAME + '@' + TESTREALM)
391392
test_spnego_auth(testdir, testenv, testlog)
392393

393394
test_spnego_negotiate_once(testdir, testenv, testlog)

tests/t_spnego.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,21 @@
33

44
import os
55
import requests
6+
from stat import ST_MODE
67
from requests_kerberos import HTTPKerberosAuth, OPTIONAL
78

89

910
if __name__ == '__main__':
1011
sess = requests.Session()
1112
url = 'http://%s/spnego/' % os.environ['NSS_WRAPPER_HOSTNAME']
12-
r = sess.get(url, auth=HTTPKerberosAuth())
13+
r = sess.get(url, auth=HTTPKerberosAuth(delegate=True))
1314
if r.status_code != 200:
1415
raise ValueError('Spnego failed')
1516

1617
c = r.cookies
1718
if not c.get("gssapi_session").startswith("MagBearerToken="):
1819
raise ValueError('gssapi_session not set')
20+
21+
data = os.stat(os.environ['DELEGCCACHE'])
22+
if data[ST_MODE] != 0100666:
23+
raise ValueError('Incorrect perm on ccache: %o' % data[ST_MODE])

0 commit comments

Comments
 (0)