From ebbef7c9fc4fe5614612796d4e5b5c67a66fc582 Mon Sep 17 00:00:00 2001
From: Paul Marillonnet <pmarillonnet@entrouvert.com>
Date: Thu, 24 Jan 2019 11:40:48 +0100
Subject: [PATCH] python3: use django.utils.six url-parsing functions (#31139)

---
 src/authentic2/cors.py                          | 2 +-
 src/authentic2/disco_service/disco_responder.py | 2 +-
 src/authentic2/middleware.py                    | 2 +-
 src/authentic2/models.py                        | 2 +-
 src/authentic2/saml/common.py                   | 2 +-
 src/authentic2/utils.py                         | 2 +-
 src/authentic2_auth_oidc/utils.py               | 2 +-
 src/authentic2_idp_cas/managers.py              | 2 +-
 src/authentic2_idp_oidc/utils.py                | 2 +-
 tests/conftest.py                               | 2 +-
 tests/test_admin.py                             | 3 +--
 tests/test_all.py                               | 2 +-
 tests/test_auth_oidc.py                         | 2 +-
 tests/test_cas.py                               | 4 +---
 tests/test_idp_oidc.py                          | 2 +-
 tests/test_idp_saml2.py                         | 2 +-
 tests/test_manager.py                           | 2 +-
 tests/test_registration.py                      | 2 +-
 tests/test_views.py                             | 3 +--
 tests/utils.py                                  | 2 +-
 20 files changed, 20 insertions(+), 24 deletions(-)

diff --git a/src/authentic2/cors.py b/src/authentic2/cors.py
index a41b27f8..aae0ffd4 100644
--- a/src/authentic2/cors.py
+++ b/src/authentic2/cors.py
@@ -1,7 +1,7 @@
 from .decorators import SessionCache
-import urlparse
 
 from django.conf import settings
+from django.utils.six.moves.urllib import parse as urlparse
 
 from . import plugins, app_settings
 
diff --git a/src/authentic2/disco_service/disco_responder.py b/src/authentic2/disco_service/disco_responder.py
index 34006763..9c94e6df 100644
--- a/src/authentic2/disco_service/disco_responder.py
+++ b/src/authentic2/disco_service/disco_responder.py
@@ -7,7 +7,6 @@
 
 
 import logging
-import urlparse
 import urllib
 
 from xml.dom.minidom import parseString
@@ -17,6 +16,7 @@ from django.conf.urls import url
 from django.utils.translation import ugettext as _
 from django.core.urlresolvers import reverse
 from django.utils.http import urlquote
+from django.utils.six.moves.urllib import parse as urlparse
 
 from authentic2 import settings
 from authentic2.saml.common import error_page as base_error_page
diff --git a/src/authentic2/middleware.py b/src/authentic2/middleware.py
index 3393fb37..f09e911b 100644
--- a/src/authentic2/middleware.py
+++ b/src/authentic2/middleware.py
@@ -1,4 +1,3 @@
-import urlparse
 import logging
 import datetime
 import random
@@ -12,6 +11,7 @@ except ImportError:
 from django.conf import settings
 from django.contrib import messages
 from django.utils.translation import ugettext as _
+from django.utils.six.moves.urllib import parse as urlparse
 from django.shortcuts import render
 
 from . import app_settings, utils, plugins
diff --git a/src/authentic2/models.py b/src/authentic2/models.py
index 11461264..2080fc02 100644
--- a/src/authentic2/models.py
+++ b/src/authentic2/models.py
@@ -1,11 +1,11 @@
 import time
-import urlparse
 import uuid
 from django.utils.http import urlquote
 from django.conf import settings
 from django.db import models
 from django.db.models.query import Q
 from django.utils.translation import ugettext_lazy as _
+from django.utils.six.moves.urllib import parse as urlparse
 from django.core.exceptions import ValidationError, FieldDoesNotExist
 from django.contrib.contenttypes.models import ContentType
 
diff --git a/src/authentic2/saml/common.py b/src/authentic2/saml/common.py
index d1052c98..a05ccab4 100644
--- a/src/authentic2/saml/common.py
+++ b/src/authentic2/saml/common.py
@@ -1,4 +1,3 @@
-import urlparse
 import os.path
 import urllib
 import httplib
@@ -12,6 +11,7 @@ from authentic2.compat_lasso import lasso
 from django.conf import settings
 from django.http import HttpResponseRedirect, Http404, HttpResponse
 from django.shortcuts import render
+from django.utils.six.moves.urllib import parse as urlparse
 from django.core.exceptions import ValidationError
 
 from authentic2.saml.models import (LibertyFederation, LibertyProvider,
diff --git a/src/authentic2/utils.py b/src/authentic2/utils.py
index 5f494844..12de1b9b 100644
--- a/src/authentic2/utils.py
+++ b/src/authentic2/utils.py
@@ -3,7 +3,6 @@ import random
 import time
 import logging
 import urllib
-import urlparse
 import uuid
 import datetime
 import copy
@@ -25,6 +24,7 @@ from django.forms.utils import ErrorList, to_current_timezone
 from django.utils import timezone
 from django.utils import html, http, six, encoding
 from django.utils.translation import ugettext as _, ungettext
+from django.utils.six.moves.urllib import parse as urlparse
 from django.shortcuts import resolve_url
 from django.template.loader import render_to_string, TemplateDoesNotExist
 from django.core.mail import send_mail
diff --git a/src/authentic2_auth_oidc/utils.py b/src/authentic2_auth_oidc/utils.py
index 6b5f1baf..1f2956e7 100644
--- a/src/authentic2_auth_oidc/utils.py
+++ b/src/authentic2_auth_oidc/utils.py
@@ -1,4 +1,3 @@
-import urlparse
 import datetime
 import base64
 import json
@@ -8,6 +7,7 @@ import requests
 from django.utils.timezone import utc
 from django.shortcuts import get_object_or_404
 from django.utils.translation import ugettext as _
+from django.utils.six.moves.urllib import parse as urlparse
 
 from authentic2.decorators import GlobalCache
 from authentic2.models import Attribute
diff --git a/src/authentic2_idp_cas/managers.py b/src/authentic2_idp_cas/managers.py
index 317ab0df..6bc0f220 100644
--- a/src/authentic2_idp_cas/managers.py
+++ b/src/authentic2_idp_cas/managers.py
@@ -1,9 +1,9 @@
-import urlparse
 from datetime import timedelta
 
 from django.db import models
 from django.db.models import query
 from django.utils.timezone import now
+from django.utils.six.moves.urllib import parse as urlparse
 
 
 class TicketQuerySet(query.QuerySet):
diff --git a/src/authentic2_idp_oidc/utils.py b/src/authentic2_idp_oidc/utils.py
index 5297d9f6..88e0dbf3 100644
--- a/src/authentic2_idp_oidc/utils.py
+++ b/src/authentic2_idp_oidc/utils.py
@@ -1,6 +1,5 @@
 import json
 import hashlib
-import urlparse
 import base64
 import uuid
 
@@ -10,6 +9,7 @@ from jwcrypto.jwt import JWT
 from django.core.exceptions import ImproperlyConfigured
 from django.conf import settings
 from django.utils.encoding import smart_bytes
+from django.utils.six.moves.urllib import parse as urlparse
 
 from authentic2 import hooks, crypto
 from authentic2.attributes_ng.engine import get_attributes
diff --git a/tests/conftest.py b/tests/conftest.py
index b5b5e78c..d18add5d 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -2,13 +2,13 @@
 
 import pytest
 import mock
-import urlparse
 
 import django_webtest
 
 from django.contrib.auth import get_user_model
 from django_rbac.utils import get_ou_model, get_role_model
 from django.conf import settings
+from django.utils.six.moves.urllib import parse as urlparse
 
 from pytest_django.migrations import DisableMigrations
 
diff --git a/tests/test_admin.py b/tests/test_admin.py
index ba48ccac..90955bd8 100644
--- a/tests/test_admin.py
+++ b/tests/test_admin.py
@@ -1,9 +1,8 @@
 # -*- coding: utf-8 -*-
 
-from urlparse import urlparse
-
 from authentic2.custom_user.models import User
 from authentic2.models import Attribute
+from django.utils.six.moves.urllib.parse import urlparse
 
 import utils
 
diff --git a/tests/test_all.py b/tests/test_all.py
index 98ad6d16..71f2278e 100644
--- a/tests/test_all.py
+++ b/tests/test_all.py
@@ -1,6 +1,5 @@
 # -*- coding: utf-8 -*-
 import json
-import urlparse
 import base64
 
 import pytest
@@ -14,6 +13,7 @@ from django.core.serializers.json import DjangoJSONEncoder
 from django.contrib.auth import get_user_model
 from django.contrib.contenttypes.models import ContentType
 from django.utils.translation import ugettext as _
+from django.utils.six.moves.urllib import parse as urlparse
 
 from rest_framework import test
 from rest_framework import status
diff --git a/tests/test_auth_oidc.py b/tests/test_auth_oidc.py
index 4dea423d..2420e4c0 100644
--- a/tests/test_auth_oidc.py
+++ b/tests/test_auth_oidc.py
@@ -1,7 +1,6 @@
 # -*- coding: utf-8 -*-
 import datetime
 import pytest
-import urlparse
 import json
 import time
 
@@ -14,6 +13,7 @@ from django.utils.timezone import utc
 from django.core.urlresolvers import reverse
 from django.contrib.auth import get_user_model
 from django.utils.timezone import now
+from django.utils.six.moves.urllib import parse as urlparse
 
 from django_rbac.utils import get_ou_model
 
diff --git a/tests/test_cas.py b/tests/test_cas.py
index acb940d5..997393a0 100644
--- a/tests/test_cas.py
+++ b/tests/test_cas.py
@@ -1,8 +1,6 @@
-import urlparse
-
-
 from django.test.client import RequestFactory, Client
 from django.test.utils import override_settings
+from django.utils.six.moves.urllib import parse as urlparse
 
 
 from authentic2.compat import get_user_model
diff --git a/tests/test_idp_oidc.py b/tests/test_idp_oidc.py
index 82635eb0..514fea9d 100644
--- a/tests/test_idp_oidc.py
+++ b/tests/test_idp_oidc.py
@@ -1,4 +1,3 @@
-import urlparse
 import base64
 import json
 import datetime
@@ -16,6 +15,7 @@ from django.db import connection
 from django.db.migrations.executor import MigrationExecutor
 from django.utils.timezone import now
 from django.contrib.auth import get_user_model
+from django.utils.six.moves.urllib import parse as urlparse
 
 
 User = get_user_model()
diff --git a/tests/test_idp_saml2.py b/tests/test_idp_saml2.py
index 3e0748f2..cb2ebd44 100644
--- a/tests/test_idp_saml2.py
+++ b/tests/test_idp_saml2.py
@@ -3,7 +3,6 @@ import datetime
 import base64
 import unittest
 import StringIO
-import urlparse
 from lxml.html import parse
 
 from django.test import Client
@@ -12,6 +11,7 @@ from django.contrib.auth import get_user_model, REDIRECT_FIELD_NAME
 from django.core.urlresolvers import reverse
 from django.core.files import File
 from django.utils.translation import gettext as _
+from django.utils.six.moves.urllib import parse as urlparse
 
 from authentic2.saml import models as saml_models
 from authentic2.a2_rbac.models import Role, OrganizationalUnit
diff --git a/tests/test_manager.py b/tests/test_manager.py
index c23839b2..b5da74c6 100644
--- a/tests/test_manager.py
+++ b/tests/test_manager.py
@@ -2,7 +2,6 @@
 
 import pytest
 import json
-from urlparse import urlparse
 
 from django.core.urlresolvers import reverse
 from django.core import mail
@@ -13,6 +12,7 @@ from authentic2.a2_rbac.utils import get_default_ou
 
 from django_rbac.utils import get_ou_model, get_role_model
 from django.contrib.auth import get_user_model
+from django.utils.six.moves.urllib.parse import urlparse
 from utils import login, get_link_from_mail
 
 
diff --git a/tests/test_registration.py b/tests/test_registration.py
index a6a09cd5..a8e5b019 100644
--- a/tests/test_registration.py
+++ b/tests/test_registration.py
@@ -1,11 +1,11 @@
 # -*- coding: utf-8 -*-
 
 import re
-from urlparse import urlparse
 
 from django.core.urlresolvers import reverse
 from django.contrib.auth import get_user_model, REDIRECT_FIELD_NAME
 from django.utils.http import urlquote
+from django.utils.six.moves.urllib.parse import urlparse
 
 from authentic2 import utils, models
 
diff --git a/tests/test_views.py b/tests/test_views.py
index 6cab8874..1963564e 100644
--- a/tests/test_views.py
+++ b/tests/test_views.py
@@ -1,9 +1,8 @@
-from urlparse import urlparse
-
 from utils import login
 import pytest
 
 from django.core.urlresolvers import reverse
+from django.utils.six.moves.urllib.parse import urlparse
 
 from authentic2.custom_user.models import User
 
diff --git a/tests/utils.py b/tests/utils.py
index 277edf31..d82d9422 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -1,6 +1,5 @@
 import re
 import base64
-import urlparse
 from contextlib import contextmanager
 
 from lxml import etree
@@ -10,6 +9,7 @@ from django.core.urlresolvers import reverse
 from django.conf import settings
 from django.utils.encoding import iri_to_uri
 from django.shortcuts import resolve_url
+from django.utils.six.moves.urllib.parse import urlparse
 
 from authentic2 import utils
 
-- 
2.20.1

