From 7e9bc573ac570c15e4deee8b288d8c69c62df0f2 Mon Sep 17 00:00:00 2001
From: Benjamin Renard <brenard@easter-eggs.com>
Date: Wed, 23 May 2018 12:18:15 +0200
Subject: [PATCH] Remove CAS service's URLs length limit

---
 src/authentic2_idp_cas/migrations/0001_initial.py |  2 +-
 src/authentic2_idp_cas/models.py                  |  4 ++--
 tests/{test_cas.py => test_idp_cas.py}            | 14 +++++++++++++-
 3 files changed, 16 insertions(+), 4 deletions(-)
 rename tests/{test_cas.py => test_idp_cas.py} (97%)

diff --git a/src/authentic2_idp_cas/migrations/0001_initial.py b/src/authentic2_idp_cas/migrations/0001_initial.py
index 49488c0e6..64e9ce58c 100644
--- a/src/authentic2_idp_cas/migrations/0001_initial.py
+++ b/src/authentic2_idp_cas/migrations/0001_initial.py
@@ -35,7 +35,7 @@ class Migration(migrations.Migration):
                 ('logout_use_iframe_timeout', models.PositiveIntegerField(default=300, help_text="if iframe logout is used, it's the time between the onload event for this iframe and the moment we consider its loading to be really finished", verbose_name='iframe logout timeout (ms)')),
                 ('name', models.CharField(unique=True, max_length=128, verbose_name='name')),
                 ('slug', models.SlugField(unique=True, max_length=128, verbose_name='slug')),
-                ('urls', models.TextField(max_length=128, verbose_name='urls')),
+                ('urls', models.TextField(verbose_name='urls')),
                 ('identifier_attribute', models.CharField(max_length=64, verbose_name='attribute name')),
                 ('proxy', models.ManyToManyField(help_text='services who can request proxy tickets for this service', related_name='proxy_rel_+', verbose_name='proxy', to='authentic2_idp_cas.Service')),
             ],
diff --git a/src/authentic2_idp_cas/models.py b/src/authentic2_idp_cas/models.py
index 43a192a1c..f028ea3a2 100644
--- a/src/authentic2_idp_cas/models.py
+++ b/src/authentic2_idp_cas/models.py
@@ -1,5 +1,5 @@
 # authentic2 - versatile identity manager
-# Copyright (C) 2010-2019 Entr'ouvert
+# Copyright (C) 2010-2020 Entr'ouvert
 #
 # This program is free software: you can redistribute it and/or modify it
 # under the terms of the GNU Affero General Public License as published
@@ -31,7 +31,7 @@ url_validator = URLValidator(schemes=['http', 'https', 'ftp', 'ftps', 'imap', 'i
 
 @six.python_2_unicode_compatible
 class Service(LogoutUrlAbstract, Service):
-    urls = models.TextField(max_length=128, verbose_name=_('urls'))
+    urls = models.TextField(verbose_name=_('urls'))
     identifier_attribute = models.CharField(max_length=64, verbose_name=_('attribute name'), blank=False)
     proxy = models.ManyToManyField(
         'self',
diff --git a/tests/test_cas.py b/tests/test_idp_cas.py
similarity index 97%
rename from tests/test_cas.py
rename to tests/test_idp_cas.py
index bab7de368..d35aaeda1 100644
--- a/tests/test_cas.py
+++ b/tests/test_idp_cas.py
@@ -1,5 +1,5 @@
 # authentic2 - versatile identity manager
-# Copyright (C) 2010-2019 Entr'ouvert
+# Copyright (C) 2010-2020 Entr'ouvert
 #
 # This program is free software: you can redistribute it and/or modify it
 # under the terms of the GNU Affero General Public License as published
@@ -74,6 +74,18 @@ class CasTests(Authentic2TestCase):
         self.authorized_service = Role.objects.create(name='rogue', ou=get_default_ou())
         self.factory = RequestFactory()
 
+    def test_long_urls(self):
+        self.service.urls = 'https://casclient.com/%C3%A9/'\
+            'lorem/ipsum/dolor/sit/amet/consectetur/adipiscing/elit/sed/do/'\
+            'eiusmod/tempor/incididunt/ut/labore/et/dolore/magna/aliqua/ut/'\
+            'enim/ad/minim/veniam/quis/nostrud/exercitation/ullamco/laboris/'\
+            'nisi/ut/aliquip/ex/ea/commodo/consequat/duis/aute/irure/dolor/'\
+            'in/reprehenderit/in/voluptate/velit/esse/cillum/dolore/eu/'\
+            'fugiat/nulla/pariatur/excepteur/sint/occaecat/cupidatat/non/'\
+            'proident/sunt/in/culpa/qui/officia/deserunt/mollit/anim/id/est/'\
+            'laborum'
+        self.service.save()
+
     def test_service_matching(self):
         self.service.clean()
         self.service2.clean()
-- 
2.26.0

