diff options
| author | Frederic Peters <fpeters@entrouvert.com> | 2008-02-25 09:55:36 +0000 |
|---|---|---|
| committer | Frederic Peters <fpeters@entrouvert.com> | 2008-02-25 09:55:36 +0000 |
| commit | 4f01ae30cfc6e5b816479d08d8fe39c651316bcf (patch) | |
| tree | 4f05c98be9caea9c3d1ab50d54ef4f9634b8573d /tests/integration/saml2 | |
| parent | ac0dcdda5e470af346a8a2c4a9e8097ea03a4c9a (diff) | |
| download | lasso-4f01ae30cfc6e5b816479d08d8fe39c651316bcf.tar.gz lasso-4f01ae30cfc6e5b816479d08d8fe39c651316bcf.tar.xz lasso-4f01ae30cfc6e5b816479d08d8fe39c651316bcf.zip | |
added integration tests to repository
Diffstat (limited to 'tests/integration/saml2')
| -rw-r--r-- | tests/integration/saml2/__init__.py | 50 | ||||
| -rw-r--r-- | tests/integration/saml2/config.py.example | 10 | ||||
| -rw-r--r-- | tests/integration/saml2/test_00_config.py | 54 | ||||
| -rw-r--r-- | tests/integration/saml2/test_01_sso.py | 45 | ||||
| -rw-r--r-- | tests/integration/saml2/test_02_slo.py | 95 |
5 files changed, 254 insertions, 0 deletions
diff --git a/tests/integration/saml2/__init__.py b/tests/integration/saml2/__init__.py new file mode 100644 index 00000000..41f79377 --- /dev/null +++ b/tests/integration/saml2/__init__.py @@ -0,0 +1,50 @@ +import sys +import os +import signal +import subprocess +import time +import twill + +AUTHENTIC_SRCDIR = '/usr/local/src/authentic' +AUTHENTICCTL = '/usr/sbin/authenticctl.py' +AUTHENTIC_DATA_DIR = '/usr/share/authentic/' +LCSCTL = '/usr/sbin/lcsctl.py' +LCS_DATADIR = '/usr/share/lcs/' + +try: + from config import * +except ImportError: + pass + +pids = [] + +def setup(): + if not os.path.exists(AUTHENTIC_SRCDIR): + print >> sys.stderr, 'Authentic source dir (%s) does not exist' % AUTHENTIC_SRCDIR + print >> sys.stderr, 'Create it or edit tests/config.py to match your local installation' + sys.exit(1) + + os.mkdir('/tmp/.tests') + sp = subprocess.Popen([AUTHENTICCTL, 'start', + '--app-dir', '/tmp/.tests/authentictests', + '--data-dir', AUTHENTIC_DATADIR, + '--extra', os.path.join(AUTHENTIC_SRCDIR, 'extra', 'conformance'), + '--port', '10001', '--http', '--silent']) + pids.append(sp.pid) + sp = subprocess.Popen([LCSCTL, 'start', + '--app-dir', '/tmp/.tests/lcstests', + '--data-dir', LCS_DATADIR, + '--port', '10002', '--http', '--silent']) + pids.append(sp.pid) + + time.sleep(2) # let process bind ports + + twill.commands.reset_browser() + twill.set_output(file('/dev/null', 'w')) + + +def teardown(): + for pid in pids: + os.kill(pid, signal.SIGTERM) + os.system('rm -rf /tmp/.tests/') + diff --git a/tests/integration/saml2/config.py.example b/tests/integration/saml2/config.py.example new file mode 100644 index 00000000..dd7d8b15 --- /dev/null +++ b/tests/integration/saml2/config.py.example @@ -0,0 +1,10 @@ +import os + +AUTHENTIC_SRCDIR = '/home/fred/src/eo/authentic/' +AUTHENTICCTL = os.path.join(AUTHENTIC_SRCDIR, 'authenticctl.py') +AUTHENTIC_DATADIR = os.path.join(AUTHENTIC_SRCDIR, 'data') + +LCS_SRCDIR = '/home/fred/src/eo/lasso-conformance-sp/' +LCSCTL = os.path.join(LCS_SRCDIR, 'lcsctl.py') +LCS_DATADIR = os.path.join(LCS_SRCDIR, 'data') + diff --git a/tests/integration/saml2/test_00_config.py b/tests/integration/saml2/test_00_config.py new file mode 100644 index 00000000..1ff286c1 --- /dev/null +++ b/tests/integration/saml2/test_00_config.py @@ -0,0 +1,54 @@ +import twill + +def test_config_authentic(): + '''Setting up Authentic metadata''' + twill.execute_string(''' +go http://localhost:10001/admin/settings/idp +formfile 1 privatekey private-key.pem +formfile 1 publickey public-key.pem +submit''') + +def test_create_users(): + '''Creating Authentic user''' + twill.execute_string(''' +go http://localhost:10001/admin/identities/new +fv 1 name Fred +fv 1 roles$element0 Administrator +fv 1 username fred +fv 1 password fred +submit submit''') + +def test_config_lcs(): + '''Setting up LCS metadata''' + twill.execute_string(''' +go http://localhost:10002/admin/settings/identification/ +fv 1 methods$elementidp true +submit +go http://localhost:10002/admin/settings/identification/idp/sp +formfile 1 privatekey private-key.pem +formfile 1 publickey public-key.pem +submit''') + +def test_config_authentic_providers(): + '''Adding LCS as service provider in Authentic''' + twill.execute_string(''' +go http://localhost:10001/login +fv 1 username fred +fv 1 password fred +submit + +go http://localhost:10001/admin/settings/liberty_providers/new_remote +showforms +fv 1 metadata_url http://localhost:10002/saml/metadata +submit +''') + +def test_config_lcs_providers(): + '''Adding Authentic as identity provider in LCS''' + twill.execute_string(''' +go http://localhost:10002/admin/settings/identification/idp/idp/new_remote +showforms +fv 1 metadata_url http://localhost:10001/saml/metadata +submit +''') + diff --git a/tests/integration/saml2/test_01_sso.py b/tests/integration/saml2/test_01_sso.py new file mode 100644 index 00000000..3d4b6cdb --- /dev/null +++ b/tests/integration/saml2/test_01_sso.py @@ -0,0 +1,45 @@ +import twill + +def test_sso_default(): + twill.commands.reset_browser() + twill.execute_string(''' +go http://localhost:10001 +save_html /tmp/haze.html +go http://localhost:10002 +submit +fv 1 username fred +fv 1 password fred +submit +#submit consent +url http://localhost:10002 +find 'Logged in' +''') + +def test_sso_post(): + twill.commands.reset_browser() + twill.execute_string(''' +go http://localhost:10002 +fv 1 binding POST +submit +fv 1 username fred +fv 1 password fred +submit +find 'You should be automaticaly' +submit +url http://localhost:10002 +find 'Logged in' +''') + +def test_sso_idp_initiated(): + twill.commands.reset_browser() + twill.execute_string(''' +go http://localhost:10001 +fv 1 username fred +fv 1 password fred +submit +fv 1 sp http-localhost-10002-saml-metadata +submit sso +url http://localhost:10002 +find 'Logged in' +''') + diff --git a/tests/integration/saml2/test_02_slo.py b/tests/integration/saml2/test_02_slo.py new file mode 100644 index 00000000..b5464d9e --- /dev/null +++ b/tests/integration/saml2/test_02_slo.py @@ -0,0 +1,95 @@ +import twill + +def test_sso_slo_initiated_by_sp_redirect(): + twill.commands.reset_browser() + twill.execute_string(''' +go http://localhost:10002 +submit +fv 1 username fred +fv 1 password fred +submit +url http://localhost:10002 +submit slo-redirect +url http://localhost:10002 +find 'Log on' +go http://localhost:10001 +find password +''') + +def test_sso_slo_initiated_by_sp_soap(): + twill.commands.reset_browser() + twill.execute_string(''' +go http://localhost:10002 +submit +fv 1 username fred +fv 1 password fred +submit +url http://localhost:10002 +submit slo-soap +url http://localhost:10002 +find 'Log on' +go http://localhost:10001 +find password +''') + + + +def test_sso_slo_initiated_by_idp_redirect(): + twill.commands.reset_browser() + twill.execute_string(''' +go http://localhost:10002 +submit +fv 1 username fred +fv 1 password fred +submit +url http://localhost:10002 +go http://localhost:10001 +save_html /tmp/a1.html +fv 2 slo 'Single Logout' +submit 'Single Logout' +url http://localhost:10001 +find password +go http://localhost:10002 +find 'Log on' +''') + +def test_sso_slo_initiated_by_idp_soap(): + twill.commands.reset_browser() + twill.execute_string(''' +go http://localhost:10002 +submit +fv 1 username fred +fv 1 password fred +submit +url http://localhost:10002 +go http://localhost:10001 +save_html /tmp/a1.html +fv 2 binding SOAP +fv 2 slo 'Single Logout' +submit 'Single Logout' +url http://localhost:10001 +find password +go http://localhost:10002 +find 'Log on' +''') + + +def test_sso_idp_initiated_then_slo_sp_soap(): + ### http://bugs.entrouvert.org/rapport-de-bug-pour-la-conformance-saml-2-0/8/ + twill.commands.reset_browser() + twill.execute_string(''' +go http://localhost:10001 +fv 1 username fred +fv 1 password fred +submit +fv 1 sp http-localhost-10002-saml-metadata +submit sso +url http://localhost:10002 +find 'Logged in' +submit slo-soap +url http://localhost:10002 +find 'Log on' +go http://localhost:10001 +find password +''') + |
