##// END OF EJS Templates
tests: don't use md5 for testing crypto for compliance reasons.
marcink -
r2836:66997538 default
parent child Browse files
Show More
@@ -49,7 +49,7 b' from rhodecode.model.db import ('
49 49 User, Repository, Permission, UserToPerm, UserGroupToPerm, UserGroupMember,
50 50 UserIpMap, UserApiKeys, RepoGroup, UserGroup)
51 51 from rhodecode.lib import caches
52 from rhodecode.lib.utils2 import safe_unicode, aslist, safe_str, md5, safe_int
52 from rhodecode.lib.utils2 import safe_unicode, aslist, safe_str, md5, safe_int, sha1
53 53 from rhodecode.lib.utils import (
54 54 get_repo_slug, get_repo_group_slug, get_user_group_slug)
55 55 from rhodecode.lib.caching_query import FromCache
@@ -210,12 +210,12 b' class _RhodeCodeCryptoSha256(_RhodeCodeC'
210 210 return hashlib.sha256(password).hexdigest() == hashed
211 211
212 212
213 class _RhodeCodeCryptoMd5(_RhodeCodeCryptoBase):
213 class _RhodeCodeCryptoTest(_RhodeCodeCryptoBase):
214 214 ENC_PREF = '_'
215 215
216 216 def hash_create(self, str_):
217 217 self._assert_bytes(str_)
218 return hashlib.md5(str_).hexdigest()
218 return sha1(str_)
219 219
220 220 def hash_check(self, password, hashed):
221 221 """
@@ -225,18 +225,18 b' class _RhodeCodeCryptoMd5(_RhodeCodeCryp'
225 225 :param hashed: password in hashed form
226 226 """
227 227 self._assert_bytes(password)
228 return hashlib.md5(password).hexdigest() == hashed
228 return sha1(password) == hashed
229 229
230 230
231 231 def crypto_backend():
232 232 """
233 233 Return the matching crypto backend.
234 234
235 Selection is based on if we run tests or not, we pick md5 backend to run
235 Selection is based on if we run tests or not, we pick sha1-test backend to run
236 236 tests faster since BCRYPT is expensive to calculate
237 237 """
238 238 if rhodecode.is_test:
239 RhodeCodeCrypto = _RhodeCodeCryptoMd5()
239 RhodeCodeCrypto = _RhodeCodeCryptoTest()
240 240 else:
241 241 RhodeCodeCrypto = _RhodeCodeCryptoBCrypt()
242 242
@@ -75,7 +75,7 b' def test_hash_check_with_update_enforces'
75 75
76 76
77 77 @pytest.fixture(params=[
78 auth._RhodeCodeCryptoMd5,
78 auth._RhodeCodeCryptoTest,
79 79 auth._RhodeCodeCryptoBCrypt,
80 80 auth._RhodeCodeCryptoSha256,
81 81 ])
General Comments 0
You need to be logged in to leave comments. Login now