Make it possible to use PluginLoader without store
[cascardo/ipsilon.git] / tests / pgdb.py
index ae4b47c..c29d883 100755 (executable)
@@ -1,22 +1,6 @@
 #!/usr/bin/python
 #
-# Copyright (C) 2014  Simo Sorce <simo@redhat.com>
-#
-# see file 'COPYING' for use and warranty information
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
+# Copyright (C) 2014 Ipsilon project Contributors, for license see COPYING
 
 from helpers.common import IpsilonTestBase  # pylint: disable=relative-import
 from helpers.http import HttpSessions  # pylint: disable=relative-import
@@ -29,6 +13,7 @@ from string import Template
 idp_g = {'TEMPLATES': '${TESTDIR}/templates/install',
          'CONFDIR': '${TESTDIR}/etc',
          'DATADIR': '${TESTDIR}/lib',
+         'CACHEDIR': '${TESTDIR}/cache',
          'HTTPDCONFD': '${TESTDIR}/${NAME}/conf.d',
          'STATICDIR': '${ROOTDIR}',
          'BINDIR': '${ROOTDIR}/ipsilon',
@@ -43,10 +28,11 @@ idp_a = {'hostname': '${ADDRESS}:${PORT}',
          'admin_user': '${TEST_USER}',
          'system_user': '${TEST_USER}',
          'instance': '${NAME}',
+         'openid': 'False',
          'secure': 'no',
          'testauth': 'yes',
          'pam': 'no',
-         'krb': 'no',
+         'gssapi': 'no',
          'ipa': 'no',
          'server_debugging': 'True'}
 
@@ -72,8 +58,14 @@ Alias /sp ${HTTPDIR}/sp
 <Directory ${HTTPDIR}/sp>
     Require all granted
 </Directory>
+
+Alias /open ${HTTPDIR}/open
+
+<Directory ${HTTPDIR}/open>
+</Directory>
 """
     index = """WORKS!"""
+    logged_out = """Logged out"""
 
     t = Template(location)
     text = t.substitute({'HTTPDIR': httpdir})
@@ -83,6 +75,9 @@ Alias /sp ${HTTPDIR}/sp
     os.mkdir(httpdir + '/sp')
     with open(httpdir + '/sp/index.html', 'w') as f:
         f.write(index)
+    os.mkdir(httpdir + '/open')
+    with open(httpdir + '/open/logged_out.html', 'w') as f:
+        f.write(logged_out)
 
 
 class IpsilonTest(IpsilonTestBase):
@@ -135,7 +130,7 @@ if __name__ == '__main__':
     sess.add_server(idpname, 'http://127.0.0.10:45080', user, 'ipsilon')
     sess.add_server(spname, 'http://127.0.0.11:45081')
 
-    print "test1: Authenticate to IDP ...",
+    print "pgdb: Authenticate to IDP ...",
     sys.stdout.flush()
     try:
         print 'Stress-testing the database connections...',
@@ -149,7 +144,7 @@ if __name__ == '__main__':
         sys.exit(1)
     print " SUCCESS"
 
-    print "test1: Add SP Metadata to IDP ...",
+    print "pgdb: Add SP Metadata to IDP ...",
     try:
         sess.add_sp_metadata(idpname, spname)
     except Exception, e:  # pylint: disable=broad-except
@@ -157,7 +152,7 @@ if __name__ == '__main__':
         sys.exit(1)
     print " SUCCESS"
 
-    print "test1: Access SP Protected Area ...",
+    print "pgdb: Access SP Protected Area ...",
     try:
         page = sess.fetch_page(idpname, 'http://127.0.0.11:45081/sp/')
         page.expected_value('text()', 'WORKS!')
@@ -165,3 +160,14 @@ if __name__ == '__main__':
         print >> sys.stderr, " ERROR: %s" % repr(e)
         sys.exit(1)
     print " SUCCESS"
+
+    print "pgdb: Logout from SP ...",
+    try:
+        page = sess.fetch_page(idpname, '%s/%s?%s' % (
+            'http://127.0.0.11:45081', 'saml2/logout',
+            'ReturnTo=http://127.0.0.11:45081/open/logged_out.html'))
+        page.expected_value('text()', 'Logged out')
+    except ValueError, e:
+        print >> sys.stderr, " ERROR: %s" % repr(e)
+        sys.exit(1)
+    print " SUCCESS"