Projet

Général

Profil

0001-misc-remove-usage-of-django.utils.six-63684.patch

Frédéric Péters, 15 avril 2022 17:32

Télécharger (31,9 ko)

Voir les différences:

Subject: [PATCH] misc: remove usage of django.utils.six (#63684)

 hobo/agent/authentic2/provisionning.py              |  4 ++--
 hobo/agent/authentic2/role_forms.py                 |  3 +--
 .../agent/common/management/commands/hobo_deploy.py |  6 +++---
 hobo/agent/worker/services.py                       |  6 +++---
 hobo/context_processors.py                          |  6 +++---
 hobo/environment/management/commands/cook.py        |  7 +++----
 hobo/environment/models.py                          | 13 +++----------
 hobo/environment/utils.py                           |  4 ++--
 hobo/environment/validators.py                      |  5 +++--
 hobo/journal.py                                     |  3 +--
 hobo/matomo/utils.py                                |  4 ++--
 hobo/multitenant/management/commands/__init__.py    |  5 -----
 hobo/multitenant/management/commands/runserver.py   |  1 -
 .../management/commands/tenant_command.py           |  3 +--
 hobo/multitenant/models.py                          |  4 ++--
 hobo/multitenant/settings_loaders.py                |  7 +++----
 hobo/profile/models.py                              |  3 +--
 hobo/provisionning/middleware.py                    |  4 ++--
 hobo/scrutiny/wsgi/middleware.py                    |  6 +++---
 hobo/signature.py                                   | 13 ++++++-------
 hobo/theme/utils.py                                 |  3 +--
 tests/test_cook.py                                  |  2 +-
 tests/test_hobo_deploy.py                           |  2 +-
 tests/test_signature.py                             |  5 ++---
 tests/utils.py                                      |  5 +----
 tests_authentic/settings.py                         |  2 +-
 tests_authentic/test_rest_authentication.py         |  8 ++++----
 tests_multipublik/settings.py                       |  2 +-
 tests_multitenant/settings.py                       |  2 +-
 tests_passerelle/settings.py                        |  2 +-
 tests_passerelle/test_deploy.py                     |  2 +-
 31 files changed, 59 insertions(+), 83 deletions(-)
hobo/agent/authentic2/provisionning.py
3 3
import json
4 4
import logging
5 5
import threading
6
import urllib.parse
6 7
from itertools import chain, islice
7 8

  
8 9
import requests
......
14 15
from django.db import connection, transaction
15 16
from django.urls import reverse
16 17
from django.utils.encoding import force_text
17
from django.utils.six.moves.urllib.parse import urljoin
18 18
from django_rbac.utils import get_ou_model, get_role_model, get_role_parenting_model
19 19

  
20 20
from hobo.agent.common import notify_agents
......
417 417
        tenant = getattr(connection, 'tenant', None)
418 418
        assert tenant
419 419
        base_url = tenant.get_base_url()
420
        return urljoin(base_url, reverse('a2-idp-saml-metadata'))
420
        return urllib.parse.urljoin(base_url, reverse('a2-idp-saml-metadata'))
421 421

  
422 422
    def pre_save(self, sender, instance, raw, using, update_fields, **kwargs):
423 423
        if not self.stack:
hobo/agent/authentic2/role_forms.py
22 22
from django import forms
23 23
from django.core import validators
24 24
from django.core.exceptions import ValidationError
25
from django.utils import six
26 25
from django.utils.translation import ugettext_lazy as _
27 26

  
28 27

  
......
42 41
    def format_value(self, value):
43 42
        if not value:
44 43
            return ''
45
        if not isinstance(value, six.string_types):
44
        if not isinstance(value, str):
46 45
            return u', '.join(value)
47 46
        return value
48 47

  
hobo/agent/common/management/commands/hobo_deploy.py
5 5
import subprocess
6 6
import sys
7 7
import tempfile
8
import urllib.parse
8 9

  
9 10
import requests
10 11
from django.conf import settings
11 12
from django.core.management import call_command, get_commands
12 13
from django.core.management.base import BaseCommand, CommandError
13 14
from django.utils.encoding import force_text
14
from django.utils.six.moves.urllib import parse as urlparse
15 15
from tenant_schemas.utils import tenant_context
16 16

  
17 17
from hobo.multitenant.middleware import TenantMiddleware, TenantNotFound
......
73 73
        if self.me.get('secondary') and self.early_secondary_exit:
74 74
            # early exit, we don't redeploy secondary services
75 75
            return
76
        domain = urlparse.urlparse(self.me.get('base_url')).netloc.split(':')[0]
76
        domain = urllib.parse.urlparse(self.me.get('base_url')).netloc.split(':')[0]
77 77
        legacy_domain = None
78 78

  
79 79
        try:
......
81 81
        except TenantNotFound:
82 82
            # might be a domain change request
83 83
            for legacy_urls in self.me.get('legacy_urls', []):
84
                old_domain = urlparse.urlparse(legacy_urls['base_url']).netloc.split(':')[0]
84
                old_domain = urllib.parse.urlparse(legacy_urls['base_url']).netloc.split(':')[0]
85 85
                try:
86 86
                    tenant = TenantMiddleware.get_tenant_by_hostname(old_domain)
87 87
                    legacy_domain = old_domain
hobo/agent/worker/services.py
23 23
import os
24 24
import subprocess
25 25
import sys
26
import urllib.parse
26 27

  
27 28
from django.utils.encoding import force_bytes
28
from django.utils.six.moves.urllib import parse as urlparse
29 29

  
30 30
from . import settings
31 31

  
......
59 59
        patterns = settings.AGENT_HOST_PATTERNS.get(cls.service_id)
60 60
        if patterns is None:
61 61
            return True
62
        parsed_url = urlparse.urlsplit(url)
62
        parsed_url = urllib.parse.urlsplit(url)
63 63
        netloc = parsed_url.netloc
64 64
        match = False
65 65
        for pattern in patterns:
......
94 94
        tenants = list(cls.get_actual_tenants())
95 95
        if tenants:
96 96
            for audience in data.get('audience', []):
97
                parsed_url = urlparse.urlsplit(audience)
97
                parsed_url = urllib.parse.urlsplit(audience)
98 98
                netloc = parsed_url.netloc.split(':')[0]
99 99
                if netloc in tenants:
100 100
                    break
hobo/context_processors.py
4 4
import logging
5 5
import os
6 6
import threading
7
import urllib.parse
7 8

  
8 9
import requests
9 10
from django.conf import settings
......
11 12
from django.template import Template
12 13
from django.utils.encoding import smart_bytes
13 14
from django.utils.http import urlencode
14
from django.utils.six.moves.urllib import parse as urlparse
15 15

  
16 16
from hobo.scrutiny.wsgi.middleware import VersionMiddleware
17 17

  
......
68 68
    @property
69 69
    def cache_key(self):
70 70
        return hashlib.md5(
71
            urlparse.urlunparse(urlparse.urlparse(self.source)[:3] + ('', '', '')).encode('ascii')
71
            urllib.parse.urlunparse(urllib.parse.urlparse(self.source)[:3] + ('', '', '')).encode('ascii')
72 72
        ).hexdigest()
73 73

  
74 74
    def get_template(self):
......
116 116

  
117 117
    def update_all_pages_cache(self):
118 118
        # always cache root
119
        root_url = urlparse.urlunparse(urlparse.urlparse(self.source)[:2] + ('/', '', '', ''))
119
        root_url = urllib.parse.urlunparse(urllib.parse.urlparse(self.source)[:2] + ('/', '', '', ''))
120 120
        if not root_url in self.combo_skeleton_pages.values():
121 121
            self.combo_skeleton_pages['__root'] = root_url
122 122

  
hobo/environment/management/commands/cook.py
20 20
import os
21 21
import string
22 22
import subprocess
23
import urllib.parse
23 24

  
24 25
from django.contrib.auth.models import User
25 26
from django.contrib.contenttypes.models import ContentType
......
28 29
from django.core.management.base import BaseCommand, CommandError
29 30
from django.db import connection
30 31
from django.db.models import Max
31
from django.utils import six
32
from django.utils.six.moves.urllib import parse as urlparse
33 32
from django.utils.text import slugify
34 33

  
35 34
from hobo.agent.common.management.commands.hobo_deploy import Command as HoboDeployCommand
......
56 55

  
57 56

  
58 57
def get_domain(url):
59
    return urlparse.urlparse(url).netloc.split(':')[0]
58
    return urllib.parse.urlparse(url).netloc.split(':')[0]
60 59

  
61 60

  
62 61
class Command(BaseCommand):
......
100 99
        for step in recipe.get('steps', []):
101 100
            action, action_args = list(step.items())[0]
102 101
            for arg in action_args:
103
                if not isinstance(action_args[arg], six.string_types):
102
                if not isinstance(action_args[arg], str):
104 103
                    continue
105 104
                action_args[arg] = string.Template(action_args[arg]).substitute(variables)
106 105
            if not self.permissive:
hobo/environment/models.py
20 20
import re
21 21
import socket
22 22
import time
23
import urllib.parse
23 24

  
24 25
import requests
25 26
from django.conf import settings
......
30 31
from django.core.exceptions import ValidationError
31 32
from django.core.validators import URLValidator
32 33
from django.db import models
33
from django.utils import six
34 34
from django.utils.crypto import get_random_string
35 35
from django.utils.encoding import force_text
36
from django.utils.six.moves.urllib.parse import urlparse
37 36
from django.utils.timezone import now
38 37
from django.utils.translation import ugettext_lazy as _
39 38

  
......
154 153
        return (self.last_operational_check_timestamp - self.last_update_timestamp) < two_minutes
155 154

  
156 155
    def as_dict(self):
157
        as_dict = dict(
158
            [
159
                (x, y)
160
                for (x, y) in self.__dict__.items()
161
                if isinstance(y, six.integer_types + six.string_types)
162
            ]
163
        )
156
        as_dict = dict([(x, y) for (x, y) in self.__dict__.items() if isinstance(y, (int, str))])
164 157
        as_dict['base_url'] = self.get_base_url_path()
165 158
        if self.legacy_urls:
166 159
            as_dict['legacy_urls'] = self.legacy_urls
......
233 226

  
234 227
    def is_resolvable(self):
235 228
        try:
236
            netloc = urlparse(self.base_url).netloc
229
            netloc = urllib.parse.urlparse(self.base_url).netloc
237 230
            if netloc and socket.gethostbyname(netloc):
238 231
                return True
239 232
        except socket.gaierror:
hobo/environment/utils.py
16 16

  
17 17
import sys
18 18
import time
19
import urllib.parse
19 20

  
20 21
from django.conf import settings
21 22
from django.core.management.base import CommandError
22 23
from django.db import connection, transaction
23 24
from django.urls import reverse
24 25
from django.utils.encoding import force_text
25
from django.utils.six.moves.urllib.parse import urlparse
26 26

  
27 27
from hobo.middleware.utils import StoreRequestMiddleware
28 28
from hobo.multitenant.settings_loaders import KnownServices
......
147 147
    Distinguish mutualised domains (matching a "-" in the first part of the netloc)
148 148
    from the normal scenario with a dedicated parent domain.
149 149
    """
150
    ph = urlparse(hostname)
150
    ph = urllib.parse.urlparse(hostname)
151 151
    parts = ph.netloc.split('.')
152 152
    if '-' in parts[0]:
153 153
        netloc = '%s-%s.%s' % (service, parts[0].split('-')[1], '.'.join(parts[1:]))
hobo/environment/validators.py
1
import urllib.parse
2

  
1 3
from django.core.exceptions import ValidationError
2
from django.utils.six.moves.urllib import parse as urlparse
3 4
from django.utils.translation import gettext_lazy as _
4 5

  
5 6
from hobo.environment.models import ServiceBase
......
11 12
        raise ValidationError(
12 13
            _('Error: %(netloc)s is not resolvable in URL %(url)s'),
13 14
            code='not-resolvable',
14
            params={'netloc': urlparse.urlsplit(url).netloc, 'url': url},
15
            params={'netloc': urllib.parse.urlsplit(url).netloc, 'url': url},
15 16
        )
16 17
    if not service.has_valid_certificate():
17 18
        raise ValidationError(
hobo/journal.py
23 23
import traceback as _traceback
24 24
from syslog import LOG_ALERT, LOG_CRIT, LOG_DEBUG, LOG_ERR, LOG_INFO, LOG_WARNING
25 25

  
26
from django.utils import six
27 26
from systemd._journal import sendv
28 27

  
29 28
_IDENT_CHARACTER = set('ABCDEFGHIJKLMNOPQRTSUVWXYZ_0123456789')
......
36 35
def _make_line(field, value):
37 36
    if isinstance(value, bytes):
38 37
        return field.encode('utf-8') + b'=' + value
39
    elif isinstance(value, six.string_types):
38
    elif isinstance(value, str):
40 39
        return field + '=' + value
41 40
    else:
42 41
        return field + '=' + str(value)
hobo/matomo/utils.py
17 17
import hashlib
18 18
import re
19 19
import string
20
import urllib.parse
20 21
from random import choice, randint
21 22

  
22 23
import requests
......
24 25
from django.core import exceptions
25 26
from django.db import connection
26 27
from django.utils.encoding import force_bytes
27
from django.utils.six.moves.urllib import parse as urlparse
28 28
from lxml import etree
29 29

  
30 30
from hobo.environment.models import Combo, Fargo, Variable, Wcs
......
94 94
    tenant_name = None
95 95
    services = [x for x in Combo.objects.all() if 'portal-user' in x.template_name and not x.secondary]
96 96
    if services != [] and services[0] != '':
97
        tenant_name = urlparse.urlparse(services[0].base_url).netloc
97
        tenant_name = urllib.parse.urlparse(services[0].base_url).netloc
98 98
    services += [x for x in Wcs.objects.all() if not x.secondary]
99 99
    services += [x for x in Fargo.objects.all() if not x.secondary]
100 100
    site_urls = [x.base_url for x in services if x.base_url != '']
hobo/multitenant/management/commands/__init__.py
10 10
from django.core.management import call_command, get_commands, load_command_class
11 11
from django.core.management.base import BaseCommand, CommandError
12 12
from django.db import connection
13

  
14
try:
15
    from django.utils.six.moves import input
16
except ImportError:
17
    input = raw_input
18 13
from tenant_schemas.utils import get_public_schema_name
19 14

  
20 15
from hobo.multitenant.middleware import TenantMiddleware
hobo/multitenant/management/commands/runserver.py
6 6
from django.contrib.staticfiles.management.commands.runserver import Command as StaticRunserverCommand
7 7
from django.contrib.staticfiles.views import serve
8 8
from django.core.management.commands.runserver import Command as RunserverCommand
9
from django.utils.six.moves.urllib.request import url2pathname
10 9
from django.views import static
11 10

  
12 11
from hobo.multitenant.middleware import TenantMiddleware, TenantNotFound
hobo/multitenant/management/commands/tenant_command.py
14 14
from django.core.management import call_command, get_commands, load_command_class
15 15
from django.core.management.base import BaseCommand, CommandError, SystemCheckError, handle_default_options
16 16
from django.db import connection, connections
17
from django.utils import six
18 17
from django.utils.encoding import force_text
19 18

  
20 19
from hobo.multitenant.management.commands import InteractiveTenantOption
......
23 22

  
24 23
def exception_to_text(e):
25 24
    try:
26
        return six.text_type(e)
25
        return str(e)
27 26
    except Exception:
28 27
        pass
29 28

  
hobo/multitenant/models.py
1 1
import json
2 2
import os
3
import urllib.parse
3 4
from shutil import rmtree
4 5

  
5 6
from django.conf import settings
6 7
from django.db import connection
7 8
from django.utils import timezone
8
from django.utils.six.moves.urllib.parse import urljoin
9 9
from tenant_schemas.models import TenantMixin
10 10
from tenant_schemas.postgresql_backend.base import _check_schema_name
11 11
from tenant_schemas.utils import django_is_in_test_mode, get_public_schema_name, schema_exists
......
48 48
        return 'https://%s' % self.domain_url
49 49

  
50 50
    def build_absolute_uri(self, location):
51
        return urljoin(self.get_base_url(), location)
51
        return urllib.parse.urljoin(self.get_base_url(), location)
52 52

  
53 53
    def create_schema(self, check_if_exists=False, sync_schema=True, verbosity=1, legacy_schema_name=None):
54 54
        if not legacy_schema_name:
hobo/multitenant/settings_loaders.py
6 6
from django.conf import settings
7 7
from django.utils.encoding import force_bytes
8 8
from django.utils.http import urlencode
9
from django.utils.six.moves.urllib import parse as urlparse
10 9

  
11 10
from hobo.theme.utils import get_theme
12 11

  
......
76 75
        services = hobo_json.get('services')
77 76
        this = [s for s in services if s.get('this')][0]
78 77
        base_url = this['base_url']
79
        orig = urlparse.urlparse(base_url).netloc.split(':')[0]
78
        orig = urllib.parse.urlparse(base_url).netloc.split(':')[0]
80 79
        secret = this['secret_key']
81 80

  
82 81
        for service in services:
83 82
            service_id = service.get('service-id')
84 83
            url = service.get('base_url')
85
            verif_orig = urlparse.urlparse(url).netloc.split(':')[0]
84
            verif_orig = urllib.parse.urlparse(url).netloc.split(':')[0]
86 85
            service_data = {
87 86
                'url': url,
88 87
                'backoffice-menu-url': service.get('backoffice-menu-url'),
......
238 237
            base_url = service.get('base_url')
239 238
            if not base_url:
240 239
                continue
241
            base_url = urlparse.urlparse(base_url)
240
            base_url = urllib.parse.urlparse(base_url)
242 241
            origin = '%s://%s' % (base_url.scheme, base_url.netloc)
243 242
            if not origin in whitelist:
244 243
                whitelist.append(origin)
hobo/profile/models.py
16 16

  
17 17
from django.core.validators import RegexValidator
18 18
from django.db import models
19
from django.utils import six
20 19
from django.utils.translation import ugettext_lazy as _
21 20

  
22 21
validate_attribute_name = RegexValidator(
......
68 67
        ordering = ['order']
69 68

  
70 69
    def as_dict(self):
71
        as_dict = dict([(x, y) for (x, y) in self.__dict__.items() if type(y) in (str, six.text_type, bool)])
70
        as_dict = dict([(x, y) for (x, y) in self.__dict__.items() if type(y) in (str, bool)])
72 71
        return as_dict
73 72

  
74 73
    def get_real_kind_display(self):
hobo/provisionning/middleware.py
17 17
import json
18 18
import logging
19 19
import sys
20
import urllib.parse
20 21

  
21 22
from django.conf import settings
22 23
from django.db import connection
23 24
from django.http import HttpResponseBadRequest, HttpResponseForbidden, JsonResponse
24 25
from django.utils.deprecation import MiddlewareMixin
25 26
from django.utils.encoding import force_bytes, force_text
26
from django.utils.six.moves.urllib.parse import urlparse
27 27

  
28 28
from hobo.provisionning.utils import NotificationProcessing
29 29
from hobo.rest_authentication import PublikAuthentication, PublikAuthenticationFailed
......
102 102
            from hobo.multitenant.settings_loaders import KnownServices
103 103

  
104 104
            authentic = Authentic.objects.all().first()
105
            orig = urlparse(authentic.base_url).netloc.split(':')[0]
105
            orig = urllib.parse.urlparse(authentic.base_url).netloc.split(':')[0]
106 106
            # create stub settings.KNOWN_SERVICES with just enough to get
107 107
            # authentication passing.
108 108
            idp_service = list(settings.KNOWN_SERVICES['authentic'].values())[0]
hobo/scrutiny/wsgi/middleware.py
1 1
import json
2
import urllib.parse
2 3

  
3 4
import pkg_resources
4 5
from django.utils.deprecation import MiddlewareMixin
5
from django.utils.six.moves.urllib.parse import quote
6 6

  
7 7
try:
8 8
    import apt.cache as apt_cache
......
49 49

  
50 50
    def __call__(self, environ, start_response):
51 51
        path = ''
52
        path += quote(environ.get('SCRIPT_NAME', ''))
53
        path += quote(environ.get('PATH_INFO', ''))
52
        path += urllib.parse.quote(environ.get('SCRIPT_NAME', ''))
53
        path += urllib.parse.quote(environ.get('PATH_INFO', ''))
54 54
        method = environ.get('REQUEST_METHOD', 'GET')
55 55
        if method == 'GET' and (path == '/__version__' or path == '/__version__/'):
56 56
            packages_version = self.get_packages_version()
hobo/signature.py
4 4
import hmac
5 5
import random
6 6
import secrets
7
import urllib.parse
7 8

  
8
from django.utils import six
9 9
from django.utils.encoding import smart_bytes
10 10
from django.utils.http import quote, urlencode
11
from django.utils.six.moves.urllib import parse as urlparse
12 11

  
13 12
'''Simple signature scheme for query strings'''
14 13

  
......
18 17

  
19 18

  
20 19
def sign_url(url, key, algo='sha256', timestamp=None, nonce=None):
21
    parsed = urlparse.urlparse(url)
20
    parsed = urllib.parse.urlparse(url)
22 21
    new_query = sign_query(parsed.query, key, algo, timestamp, nonce)
23
    return urlparse.urlunparse(parsed[:4] + (new_query,) + parsed[5:])
22
    return urllib.parse.urlunparse(parsed[:4] + (new_query,) + parsed[5:])
24 23

  
25 24

  
26 25
def sign_query(query, key, algo='sha256', timestamp=None, nonce=None):
......
42 41

  
43 42
def sign_string(s, key, algo='sha256'):
44 43
    digestmod = getattr(hashlib, algo)
45
    if isinstance(key, six.text_type):
44
    if isinstance(key, str):
46 45
        key = key.encode('utf-8')
47 46
    hash = hmac.HMAC(smart_bytes(key), digestmod=digestmod, msg=smart_bytes(s))
48 47
    return hash.digest()
49 48

  
50 49

  
51 50
def check_url(url, key, known_nonce=None, timedelta=30, raise_on_error=False):
52
    parsed = urlparse.urlparse(url, 'https')
51
    parsed = urllib.parse.urlparse(url, 'https')
53 52
    return check_query(
54 53
        parsed.query, key, known_nonce=known_nonce, timedelta=timedelta, raise_on_error=raise_on_error
55 54
    )
56 55

  
57 56

  
58 57
def check_query(query, key, known_nonce=None, timedelta=30, raise_on_error=False):
59
    parsed = urlparse.parse_qs(query)
58
    parsed = urllib.parse.parse_qs(query)
60 59
    parsed = {key: value[0] if len(value) == 1 else value for key, value in parsed.items()}
61 60
    signature = parsed.get('signature')
62 61
    if not signature or not isinstance(signature, str):
hobo/theme/utils.py
18 18
import os
19 19

  
20 20
from django.conf import settings
21
from django.utils import six
22 21

  
23 22

  
24 23
def get_themes():
......
62 61
    for variable in theme.get('variables', {}).keys():
63 62
        theme_variable, created = Variable.objects.get_or_create(name=variable, service_pk__isnull=True)
64 63
        theme_variable.auto = True
65
        if isinstance(theme['variables'][variable], six.string_types):
64
        if isinstance(theme['variables'][variable], str):
66 65
            theme_variable.value = theme['variables'][variable]
67 66
        else:
68 67
            theme_variable.value = json.dumps(theme['variables'][variable])
tests/test_cook.py
1 1
import json
2 2
import os
3
from io import StringIO
3 4

  
4 5
import pytest
5 6
from django.contrib.auth.models import User
6 7
from django.contrib.contenttypes.models import ContentType
7 8
from django.core.management.base import CommandError
8
from django.utils.six import StringIO
9 9
from mock import Mock, call, mock_open, patch
10 10

  
11 11
from hobo.environment.management.commands.cook import Command
tests/test_hobo_deploy.py
3 3
import json
4 4
import os
5 5
import sys
6
from io import StringIO
6 7

  
7 8
import pytest
8
from django.utils.six import StringIO
9 9
from mock import Mock, call, patch
10 10
from requests import Response, exceptions
11 11

  
tests/test_signature.py
1 1
import datetime
2

  
3
from django.utils.six.moves.urllib import parse as urllib
2
import urllib.parse
4 3

  
5 4
from hobo import signature
6 5

  
......
38 37

  
39 38
    # Test timedelta parameter
40 39
    now = datetime.datetime.utcnow()
41
    assert '&timestamp=%s' % urllib.quote(now.strftime('%Y-%m-%dT%H:%M:%SZ')) in signature.sign_url(
40
    assert '&timestamp=%s' % urllib.parse.quote(now.strftime('%Y-%m-%dT%H:%M:%SZ')) in signature.sign_url(
42 41
        URL, KEY, timestamp=now
43 42
    )
44 43

  
tests/utils.py
1
from django.utils import six
2

  
3

  
4 1
def byteify(input):
5 2
    if isinstance(input, dict):
6 3
        return {byteify(key): byteify(value) for key, value in input.items()}
7 4
    elif isinstance(input, list):
8 5
        return [byteify(element) for element in input]
9
    elif isinstance(input, six.text_type):
6
    elif isinstance(input, str):
10 7
        return input.encode('utf-8')
11 8
    else:
12 9
        return input
tests_authentic/settings.py
1
import builtins
1 2
import os
2 3

  
3
from django.utils.six.moves import builtins
4 4
from mock import mock_open, patch
5 5

  
6 6
# Debian defaults
tests_authentic/test_rest_authentication.py
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17 17
import re
18
import urllib.parse
18 19

  
19 20
import pytest
20 21
from django.contrib.auth import get_user_model
21 22
from django.test import RequestFactory
22
from django.utils.six.moves.urllib import parse as urllib
23 23
from rest_framework import permissions
24 24
from rest_framework.response import Response
25 25
from rest_framework.views import APIView
......
39 39
        User = get_user_model()
40 40
        user = User.objects.create(username='foo', password='foo')
41 41
        ORIG = 'other.example.net'
42
        AUTH_QUERY = '&NameID=%s&orig=%s' % (user.uuid, urllib.quote(ORIG))
42
        AUTH_QUERY = '&NameID=%s&orig=%s' % (user.uuid, urllib.parse.quote(ORIG))
43 43

  
44 44
        URL = '/api/?coucou=zob'
45 45
        factory = RequestFactory()
......
54 54
        assert result[1] is None
55 55

  
56 56
        # Test anonymous user
57
        AUTH_QUERY = '&orig=%s' % urllib.quote(ORIG)
57
        AUTH_QUERY = '&orig=%s' % urllib.parse.quote(ORIG)
58 58
        request = factory.get(signature.sign_url(URL + AUTH_QUERY, key))
59 59

  
60 60
        publik_authentication = rest_authentication.PublikAuthentication()
......
73 73
        # Test user named after service orig
74 74
        service_user = User.objects.create(username=ORIG)
75 75

  
76
        AUTH_QUERY = '&orig=%s' % urllib.quote(ORIG)
76
        AUTH_QUERY = '&orig=%s' % urllib.parse.quote(ORIG)
77 77
        request = factory.get(signature.sign_url(URL + AUTH_QUERY, key))
78 78

  
79 79
        publik_authentication = rest_authentication.PublikAuthentication()
tests_multipublik/settings.py
1
import builtins
1 2
import os.path
2 3

  
3
from django.utils.six.moves import builtins
4 4
from mock import mock_open, patch
5 5

  
6 6
from hobo.settings import *
tests_multitenant/settings.py
1
import builtins
1 2
import os
2 3

  
3
from django.utils.six.moves import builtins
4 4
from mock import mock_open, patch
5 5

  
6 6
LANGUAGE_CODE = 'en-us'
tests_passerelle/settings.py
1
import builtins
1 2
import os
2 3

  
3
from django.utils.six.moves import builtins
4 4
from mock import mock_open, patch
5 5

  
6 6
# Debian defaults
tests_passerelle/test_deploy.py
1 1
import json
2 2
import os
3 3
import sys
4
from io import StringIO
4 5

  
5 6
from django.core.management import call_command
6 7
from django.db import connection
7
from django.utils.six import StringIO
8 8
from passerelle.utils import export_site
9 9

  
10 10
from hobo.multitenant.middleware import TenantMiddleware
11
-