Changeset 10401


Ignore:
Timestamp:
5 Jul 2013, 06:04:33 (11 years ago)
Author:
uli
Message:

Move non-functional test into proper test case.
Add functional login test for single-sign-on.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.cas/trunk/waeup/cas/tests/test_server.py

    r10398 r10401  
    112112        assert resp.content_type == 'text/html'
    113113        assert b'<form ' in resp.body
     114
     115    def test_login_cred_acceptor_sso_no_service(self):
     116        # 2.2.4: successful login via single sign on
     117        app = CASServer()
     118        tgc = create_tgc_value()
     119        app.db.add(tgc)
     120        value = str(tgc.value)
     121        req = Request.blank('https://localhost/login')
     122        req.headers['Cookie'] = 'cas-tgc=%s' % value
     123        resp = app(req)
     124        assert resp.status == '200 OK'
     125        assert b'already' in resp.body
     126        assert 'Set-Cookie' not in resp.headers
     127        return
    114128
    115129
     
    184198        assert b'ticket=ST-' in resp.body
    185199
    186     def test_login_cred_acceptor_sso_no_service(self):
    187         # 2.2.4: successful login via single sign on
    188         db = self.raw_app.db
    189         tgc = create_tgc_value()
    190         db.add(tgc)
    191         value = str(tgc.value)
    192         resp = self.app.get('/login', headers={'Cookie': 'cas-tgc=%s' % value})
    193         assert resp.status == '200 OK'
    194         assert b'already' in resp.body
    195         assert 'Set-Cookie' not in resp.headers
    196         return
    197 
    198200    def test_login_cred_acceptor_failed(self):
    199201        # 2.2.4: failed login yields a message
     
    205207        assert resp.status == '200 OK'
    206208        assert b'failed' in resp.body
     209
     210    def test_login_sso_no_service(self):
     211        # we can initiate single-sign-on without service
     212        resp1 = self.app.get('https://localhost/login')  # HTTPS required!
     213        assert resp1.status == '200 OK'
     214        assert 'cas-tgc' not in self.app.cookies
     215        form = resp1.forms[0]
     216        form.set('username', 'bird')
     217        form.set('password', 'bebop')
     218        resp2 = form.submit('AUTHENTICATE')
     219        assert resp2.status == '200 OK'
     220        # we got a secure cookie
     221        assert 'cas-tgc' in self.app.cookies
     222        # when we get the login page again, the cookie will replace creds.
     223        resp3 = self.app.get('https://localhost/login')
     224        assert b'You logged in already' in resp3.body
    207225
    208226
Note: See TracChangeset for help on using the changeset viewer.