Index: main/waeup.cas/trunk/waeup/cas/tests/test_server.py
===================================================================
--- main/waeup.cas/trunk/waeup/cas/tests/test_server.py	(revision 10411)
+++ main/waeup.cas/trunk/waeup/cas/tests/test_server.py	(revision 10412)
@@ -140,4 +140,12 @@
         assert 'Set-Cookie' not in resp.headers
 
+    def test_login_renew_without_cookie(self):
+        # 2.1.1: with renew and no cookie, normal auth will happen
+        app = CASServer()
+        req = Request.blank('https://localhost/login?renew=true')
+        resp = app(req)
+        assert resp.status == '200 OK'
+        assert b'username' in resp.body
+
     def test_login_renew_as_empty_string(self):
         # `renew` is handled correctly, even with empty value
@@ -149,4 +157,44 @@
         req.headers['Cookie'] = 'cas-tgc=%s' % value
         resp = app(req)
+        assert resp.status == '200 OK'
+        assert b'username' in resp.body
+        assert 'Set-Cookie' not in resp.headers
+
+    def test_login_gateway_no_cookie_with_service(self):
+        # 2.1.1: with gateway but w/o cookie we will be redirected to service
+        # no service ticket will be issued
+        app = CASServer()
+        params = 'gateway=true&service=http%3A%2F%2Fwww.service.com'
+        req = Request.blank('https://localhost/login?%s' % params)
+        resp = app(req)
+        assert resp.status == '303 See Other'
+        assert 'Location' in resp.headers
+        assert resp.headers['Location'] == 'http://www.service.com'
+
+    def test_login_gateway_with_cookie_and_service(self):
+        # 2.1.1: with cookie and gateway we will be redirected to service
+        app = CASServer()
+        tgc = create_tgc_value()
+        app.db.add(tgc)
+        value = str(tgc.value)
+        params = 'gateway=true&service=http%3A%2F%2Fwww.service.com'
+        req = Request.blank('https://localhost/login?%s' % params)
+        req.headers['Cookie'] = 'cas-tgc=%s' % value
+        resp = app(req)
+        assert resp.status == '303 See Other'
+        assert 'Location' in resp.headers
+        assert resp.headers['Location'].startswith(
+            'http://www.service.com?ticket=ST-')
+
+    def test_login_gateway_and_renew(self):
+        # 2.1.1 if both, gateway and renew are specified, only renew is valid
+        app = CASServer()
+        tgc = create_tgc_value()
+        app.db.add(tgc)
+        value = str(tgc.value)
+        req = Request.blank('https://localhost/login?renew=true&gateway=true')
+        req.headers['Cookie'] = 'cas-tgc=%s' % value
+        resp = app(req)
+        # with only gateway true, this would lead to a redirect
         assert resp.status == '200 OK'
         assert b'username' in resp.body
