fnp
/
django-cas-provider.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix standard urls. Test for Django up to 5.0.
[django-cas-provider.git]
/
cas_provider_examples
/
simple
/
tests.py
diff --git
a/cas_provider_examples/simple/tests.py
b/cas_provider_examples/simple/tests.py
index
2d95228
..
4e8b05e
100644
(file)
--- a/
cas_provider_examples/simple/tests.py
+++ b/
cas_provider_examples/simple/tests.py
@@
-1,5
+1,6
@@
-from __future__ import unicode_literals
from io import StringIO
from io import StringIO
+from urllib.parse import urlparse, parse_qsl, parse_qs
+from urllib.request import install_opener
from xml import etree
from xml.etree import ElementTree
import cas_provider
from xml import etree
from xml.etree import ElementTree
import cas_provider
@@
-8,18
+9,9
@@
from cas_provider.models import ServiceTicket
from cas_provider.signals import cas_collect_custom_attributes
from cas_provider.views import _cas2_sucess_response, INVALID_TICKET, _cas2_error_response, generate_proxy_granting_ticket
from django.contrib.auth.models import User, UserManager
from cas_provider.signals import cas_collect_custom_attributes
from cas_provider.views import _cas2_sucess_response, INVALID_TICKET, _cas2_error_response, generate_proxy_granting_ticket
from django.contrib.auth.models import User, UserManager
-from django.core.urlresolvers import reverse
from django.test import TestCase
from django.conf import settings
from django.test import TestCase
from django.conf import settings
-
-try:
- from urllib.parse import urlparse, parse_qsl, parse_qs
- from urllib.request import install_opener
-except:
- from urlparse import urlparse, parse_qsl, parse_qs
- from urllib2 import install_opener
-
-
+from django.urls import reverse
class DummyOpener(object):
class DummyOpener(object):
@@
-133,7
+125,7
@@
class ViewsTest(TestCase):
self.assertIsNotNone(proxyTicketResponseXml_2.find(CAS + "proxySuccess/" + CAS + "proxyTicket"))
proxyTicket_2 = proxyTicketResponseXml_2.find(CAS + "proxySuccess/" + CAS + "proxyTicket")
self.assertIsNotNone(proxyTicketResponseXml_2.find(CAS + "proxySuccess/" + CAS + "proxyTicket"))
proxyTicket_2 = proxyTicketResponseXml_2.find(CAS + "proxySuccess/" + CAS + "proxyTicket")
- proxyValidateResponse_3 = self.client.get(reverse('cas_proxy_validate'), {'ticket': proxyTicket_2.text, 'service': proxyTarget_2, 'pgtUrl':
None
})
+ proxyValidateResponse_3 = self.client.get(reverse('cas_proxy_validate'), {'ticket': proxyTicket_2.text, 'service': proxyTarget_2, 'pgtUrl':
''
})
proxyValidateResponseXml_3 = ElementTree.parse(StringIO(proxyValidateResponse_3.content.decode('utf-8')))
auth_success_3 = proxyValidateResponseXml_3.find(CAS + 'authenticationSuccess')
proxyValidateResponseXml_3 = ElementTree.parse(StringIO(proxyValidateResponse_3.content.decode('utf-8')))
auth_success_3 = proxyValidateResponseXml_3.find(CAS + 'authenticationSuccess')
@@
-148,8
+140,6
@@
class ViewsTest(TestCase):
self.assertEqual('root', user_3.text)
self.assertEqual('root', user_3.text)
-
-
def test_succeessful_login(self):
response = self._login_user('root', '123')
self._validate_cas1(response, True)
def test_succeessful_login(self):
response = self._login_user('root', '123')
self._validate_cas1(response, True)
@@
-160,7
+150,7
@@
class ViewsTest(TestCase):
response = self.client.get(reverse('cas_login'), follow=False)
self.assertEqual(response.status_code, 302)
response = self.client.get(reverse('cas_login'), follow=False)
self.assertEqual(response.status_code, 302)
- self.assertTrue(response['location'].startswith('
http://testserver
/'))
+ self.assertTrue(response['location'].startswith('/'))
response = self.client.get(response['location'], follow=False)
self.assertIn(response.status_code, [302, 200])
response = self.client.get(response['location'], follow=False)
self.assertIn(response.status_code, [302, 200])
@@
-183,7
+173,7
@@
class ViewsTest(TestCase):
response = self.client.get(reverse('cas_login'), follow=False)
self.assertEqual(response.status_code, 200)
response = self.client.get(reverse('cas_login'), follow=False)
self.assertEqual(response.status_code, 200)
- self.assert
Equal(response.context['user'].is_anonymous(), True
)
+ self.assert
True(response.context['user'].is_anonymous
)
def test_broken_pwd(self):
def test_broken_pwd(self):