Projet

Général

Profil

0001-ctl-preserve-key-length-in-py3-38240.patch

Emmanuel Cazenave, 05 décembre 2019 18:43

Télécharger (2,54 ko)

Voir les différences:

Subject: [PATCH] ctl: preserve key length in py3 (#38240)

 tests/test_hobo.py     | 9 +++------
 wcs/ctl/check_hobos.py | 6 +++++-
 2 files changed, 8 insertions(+), 7 deletions(-)
tests/test_hobo.py
235 235
    assert pub.get_site_option('portal_agent_url', 'variables') == 'http://agents.example.net/'
236 236
    assert pub.get_site_option('portal_url', 'variables') == 'http://portal.example.net/'
237 237
    assert pub.get_site_option('test_wcs_url', 'variables') == 'http://wcs.example.net/'
238
    assert (pub.get_site_option('authentic.example.net', 'api-secrets')
239
            == CmdCheckHobos.shared_secret(HOBO_JSON['services'][1]['secret_key'],
240
                                           HOBO_JSON['services'][2]['secret_key']))
241
    assert (pub.get_site_option('authentic.example.net', 'wscall-secrets')
242
            == CmdCheckHobos.shared_secret(HOBO_JSON['services'][1]['secret_key'],
243
                                           HOBO_JSON['services'][2]['secret_key']))
238
    key = '109fca71e7dc8ec49708a08fa7c02795de13f34f7d29d27bd150f203b3e0ab40'
239
    assert pub.get_site_option('authentic.example.net', 'api-secrets') == key
240
    assert pub.get_site_option('authentic.example.net', 'wscall-secrets') == key
244 241
    self_domain = urlparse.urlsplit(service.get('base_url')).netloc
245 242
    assert pub.get_site_option(self_domain, 'wscall-secrets') != '0'
246 243

  
wcs/ctl/check_hobos.py
25 25

  
26 26
from django.utils import six
27 27
from django.utils.encoding import force_bytes, force_text
28
from django.utils import six
28 29
from django.utils.six.moves import configparser as ConfigParser
29 30
from django.utils.six.moves.urllib import parse as urlparse
30 31

  
......
552 553
    def shared_secret(cls, secret1, secret2):
553 554
        secret1 = hashlib.sha256(force_bytes(secret1)).hexdigest()
554 555
        secret2 = hashlib.sha256(force_bytes(secret2)).hexdigest()
555
        return hex(int(secret1, 16) ^ int(secret2, 16))[2:-1]
556
        hex_str = hex(int(secret1, 16) ^ int(secret2, 16))
557
        if six.PY2:
558
            return hex_str[2:-1]
559
        return hex_str[2:]
556 560

  
557 561

  
558 562
CmdCheckHobos.register()
559
-