Ignore:
Timestamp:
21 Jun 2013, 23:39:57 (12 years ago)
Author:
uli
Message:

Add simple login form.

Location:
main/waeup.cas/trunk/waeup/cas
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.cas/trunk/waeup/cas/server.py

    r10327 r10335  
    11"""A WSGI app for serving CAS.
    22"""
     3import os
    34from webob import exc, Response
    45from webob.dec import wsgify
     6
     7template_dir = os.path.join(os.path.dirname(__file__), 'templates')
    58
    69
     
    1013    @wsgify
    1114    def __call__(self, req):
    12         if req.path_qs in ['/login', '/validate', '/logout']:
    13             return getattr(self, req.path_qs[1:])(req)
     15        if req.path in ['/login', '/validate', '/logout']:
     16            return getattr(self, req.path[1:])(req)
    1417        return exc.HTTPNotFound()
    1518
    1619    def login(self, req):
     20        return Response(
     21            open(os.path.join(template_dir, 'login.html'), 'r').read())
    1722        return Response('Hi there!')
    1823
  • main/waeup.cas/trunk/waeup/cas/tests/test_server.py

    r10326 r10335  
    5555        resp = app(req)
    5656        assert resp.status == '501 Not Implemented'
     57
     58    def test_login_simple(self):
     59        # a simple login with no service will result in login screen
     60        # (2.1.1#service of protocol specs)
     61        app = CASServer()
     62        req = Request.blank('http://localhost/login')
     63        resp = app(req)
     64        assert resp.status == '200 OK'
     65        assert resp.content_type == 'text/html'
     66        assert b'<form ' in resp.body
Note: See TracChangeset for help on using the changeset viewer.