Ignore:
Timestamp:
5 Jul 2013, 10:45:41 (11 years ago)
Author:
uli
Message:

Service tickets now store SSO flag in db.

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

Legend:

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

    r10394 r10406  
    33import time
    44from sqlalchemy import (
    5     create_engine, Column, Integer, Float, String, MetaData)
     5    create_engine, Column, Integer, Float, String, Boolean, MetaData)
    66from sqlalchemy.ext.declarative import declarative_base
    77from sqlalchemy.orm import sessionmaker, scoped_session
     
    1919    service = Column(String(2048), nullable=True)
    2020    user = Column(String(512), nullable=False)
     21    sso = Column(Boolean, nullable=False, default=True)
    2122
    22     def __init__(self, ticket, user, service=None, timestamp=None):
     23    def __init__(self, ticket, user, service=None, sso=True, timestamp=None):
    2324        if timestamp is None:
    2425            timestamp = time.time()
     
    2728        self.service = service
    2829        self.user = user
     30        self.sso = sso
    2931
    3032    def __repr__(self):
    31         return "ServiceTicket('%s', '%s', '%s', %s)" % (
    32             self.ticket, self.user, self.service, self.ts)
     33        return "ServiceTicket('%s', '%s', '%s', %s, %s)" % (
     34            self.ticket, self.user, self.service, self.sso, self.ts)
    3335
    3436
  • main/waeup.cas/trunk/waeup/cas/tests/test_db.py

    r10394 r10406  
    9696    def test_add_service_ticket(self):
    9797        # we can add service tickets
    98         self.db.add(ServiceTicket('foo', 'bar', 'baz', 12.1))
    99         result = [(x.ticket, x.user, x.service, x.ts)
     98        self.db.add(ServiceTicket('foo', 'bar', 'baz', False, 12.1))
     99        result = [(x.ticket, x.user, x.service, x.sso, x.ts)
    100100                  for x in self.db.query(ServiceTicket)]
    101         assert result == [('foo', 'bar', 'baz', 12.1)]
     101        assert result == [('foo', 'bar', 'baz', False, 12.1)]
    102102
    103103    def test_service_ticket_repr(self):
    104104        # we can get a proper ServiceTicket representation
    105105        # (i.e. one that can be fed to `eval`)
    106         sticket = ServiceTicket('foo', 'bar', 'baz', 12.1)
     106        sticket = ServiceTicket('foo', 'bar', 'baz', True, 12.1)
    107107        st_repr = sticket.__repr__()
    108         assert st_repr == "ServiceTicket('foo', 'bar', 'baz', 12.1)"
     108        assert st_repr == "ServiceTicket('foo', 'bar', 'baz', True, 12.1)"
    109109
    110110    def test_service_ticket_timestamp(self):
     
    112112        sticket = ServiceTicket('foo', 'bar', 'baz')
    113113        assert isinstance(sticket.ts, float)
     114
     115
     116    def test_service_ticket_sso(self):
     117        # sso is set to True by default
     118        sticket = ServiceTicket('foo', 'bar', 'baz')
     119        assert sticket.sso is True
    114120
    115121    def test_ticket_granting_cookie_add(self):
Note: See TracChangeset for help on using the changeset viewer.