Changeset 10406 for main/waeup.cas/trunk
- Timestamp:
- 5 Jul 2013, 10:45:41 (11 years ago)
- Location:
- main/waeup.cas/trunk/waeup/cas
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.cas/trunk/waeup/cas/db.py
r10394 r10406 3 3 import time 4 4 from sqlalchemy import ( 5 create_engine, Column, Integer, Float, String, MetaData)5 create_engine, Column, Integer, Float, String, Boolean, MetaData) 6 6 from sqlalchemy.ext.declarative import declarative_base 7 7 from sqlalchemy.orm import sessionmaker, scoped_session … … 19 19 service = Column(String(2048), nullable=True) 20 20 user = Column(String(512), nullable=False) 21 sso = Column(Boolean, nullable=False, default=True) 21 22 22 def __init__(self, ticket, user, service=None, timestamp=None):23 def __init__(self, ticket, user, service=None, sso=True, timestamp=None): 23 24 if timestamp is None: 24 25 timestamp = time.time() … … 27 28 self.service = service 28 29 self.user = user 30 self.sso = sso 29 31 30 32 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) 33 35 34 36 -
main/waeup.cas/trunk/waeup/cas/tests/test_db.py
r10394 r10406 96 96 def test_add_service_ticket(self): 97 97 # 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) 100 100 for x in self.db.query(ServiceTicket)] 101 assert result == [('foo', 'bar', 'baz', 12.1)]101 assert result == [('foo', 'bar', 'baz', False, 12.1)] 102 102 103 103 def test_service_ticket_repr(self): 104 104 # we can get a proper ServiceTicket representation 105 105 # (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) 107 107 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)" 109 109 110 110 def test_service_ticket_timestamp(self): … … 112 112 sticket = ServiceTicket('foo', 'bar', 'baz') 113 113 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 114 120 115 121 def test_ticket_granting_cookie_add(self):
Note: See TracChangeset for help on using the changeset viewer.