summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorIsaac Boukris <iboukris@gmail.com>2015-07-27 01:26:41 +0300
committerSimo Sorce <simo@redhat.com>2015-08-06 19:06:13 -0400
commit09104abbab05f92bf1f489fb8e4ee5ab3c2bec1a (patch)
treefd4562ebf3f8072024135bcc5fee1c91c4dbd3e6 /tests
parentc8ac2a462bf649711707cf09c789f27892a05837 (diff)
Add test for basic auth with two different users over the same connection
Make sure each request is authenticated according to given credentials even when GssapiConnectionBound is set. Reviewed-by: Simo Sorce <simo@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/httpd.conf7
-rw-r--r--tests/index.html2
-rwxr-xr-xtests/magtests.py24
-rwxr-xr-xtests/t_basic_k5_two_users.py27
4 files changed, 55 insertions, 5 deletions
diff --git a/tests/httpd.conf b/tests/httpd.conf
index 77701f9..18ba14b 100644
--- a/tests/httpd.conf
+++ b/tests/httpd.conf
@@ -62,13 +62,14 @@ LoadModule unixd_module modules/mod_unixd.so
LoadModule userdir_module modules/mod_userdir.so
LoadModule version_module modules/mod_version.so
LoadModule vhost_alias_module modules/mod_vhost_alias.so
-
LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
LoadModule auth_gssapi_module mod_auth_gssapi.so
<Directory />
+ Options +Includes
+ AddOutputFilter INCLUDES .html
AllowOverride none
Require all denied
</Directory>
@@ -117,6 +118,7 @@ IncludeOptional conf.d/*.conf
CoreDumpDirectory /tmp
+
<Location /spnego>
AuthType GSSAPI
AuthName "Login"
@@ -133,6 +135,8 @@ CoreDumpDirectory /tmp
</Location>
<Location /basic_auth_krb5>
+ Options +Includes
+ AddOutputFilter INCLUDES .html
AuthType GSSAPI
AuthName "Password Login"
GssapiSSLonly Off
@@ -141,6 +145,7 @@ CoreDumpDirectory /tmp
GssapiCredStore keytab:${HTTPROOT}/http.keytab
GssapiBasicAuth On
GssapiBasicAuthMech krb5
+ GssapiConnectionBound On
Require valid-user
</Location>
diff --git a/tests/index.html b/tests/index.html
index c5ad10e..9416405 100644
--- a/tests/index.html
+++ b/tests/index.html
@@ -1 +1 @@
-WORKS
+<!--#echo var="GSS_NAME" -->
diff --git a/tests/magtests.py b/tests/magtests.py
index 27f55f2..e144e83 100755
--- a/tests/magtests.py
+++ b/tests/magtests.py
@@ -73,8 +73,8 @@ KRB5_CONF_TEMPLATE = '''
}
[domain_realm]
- .mag.dev = MAG.DEV
- mag.dev = MAG.DEV
+ .mag.dev = ${TESTREALM}
+ mag.dev = ${TESTREALM}
[dbmodules]
${TESTREALM} = {
@@ -167,6 +167,8 @@ def kadmin_local(cmd, env, logfile):
USR_NAME = "maguser"
USR_PWD = "magpwd"
+USR_NAME_2 = "maguser2"
+USR_PWD_2 = "magpwd2"
SVC_KTNAME = "httpd/http.keytab"
KEY_TYPE = "aes256-cts-hmac-sha1-96:normal"
@@ -188,6 +190,10 @@ def setup_keys(tesdir, env):
with (open(testlog, 'a')) as logfile:
kadmin_local(cmd, env, logfile)
+ cmd = "addprinc -pw %s -e %s %s" % (USR_PWD_2, KEY_TYPE, USR_NAME_2)
+ with (open(testlog, 'a')) as logfile:
+ kadmin_local(cmd, env, logfile)
+
keys_env = { "KRB5_KTNAME": svc_keytab }
keys_env.update(env)
@@ -280,6 +286,16 @@ def test_basic_auth_krb5(testdir, testenv, testlog):
else:
sys.stderr.write('BASIC-AUTH: SUCCESS\n')
+ with (open(testlog, 'a')) as logfile:
+ basick5 = subprocess.Popen(["tests/t_basic_k5_two_users.py"],
+ stdout=logfile, stderr=logfile,
+ env=testenv, preexec_fn=os.setsid)
+ basick5.wait()
+ if basick5.returncode != 0:
+ sys.stderr.write('BASIC-AUTH Two Users: FAILED\n')
+ else:
+ sys.stderr.write('BASIC-AUTH Two Users: SUCCESS\n')
+
if __name__ == '__main__':
@@ -310,7 +326,9 @@ if __name__ == '__main__':
testenv = {'MAG_USER_NAME': USR_NAME,
- 'MAG_USER_PASSWORD': USR_PWD}
+ 'MAG_USER_PASSWORD': USR_PWD,
+ 'MAG_USER_NAME_2': USR_NAME_2,
+ 'MAG_USER_PASSWORD_2': USR_PWD_2}
testenv.update(kdcenv)
test_basic_auth_krb5(testdir, testenv, testlog)
diff --git a/tests/t_basic_k5_two_users.py b/tests/t_basic_k5_two_users.py
new file mode 100755
index 0000000..0d3d45b
--- /dev/null
+++ b/tests/t_basic_k5_two_users.py
@@ -0,0 +1,27 @@
+#!/usr/bin/python
+# Copyright (C) 2015 - mod_auth_gssapi contributors, see COPYING for license.
+
+import os
+import requests
+from requests.auth import HTTPBasicAuth
+
+
+if __name__ == '__main__':
+ s = requests.Session()
+
+ url = 'http://%s:%s@%s/basic_auth_krb5/' % (os.environ['MAG_USER_NAME'],
+ os.environ['MAG_USER_PASSWORD'],
+ os.environ['NSS_WRAPPER_HOSTNAME'])
+ r = s.get(url)
+ if r.status_code != 200:
+ raise ValueError('Basic Auth Failed')
+
+ url = 'http://%s:%s@%s/basic_auth_krb5/' % (os.environ['MAG_USER_NAME_2'],
+ os.environ['MAG_USER_PASSWORD_2'],
+ os.environ['NSS_WRAPPER_HOSTNAME'])
+ r2 = s.get(url)
+ if r2.status_code != 200:
+ raise ValueError('Basic Auth failed')
+
+ if r.text == r2.text:
+ raise ValueError('Basic Auth fatal error')