|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +# |
| 3 | +# --- BEGIN_HEADER --- |
| 4 | +# |
| 5 | +# test_mig_shared_pwcrypto - unit test of the corresponding mig shared module |
| 6 | +# Copyright (C) 2003-2025 The MiG Project by the Science HPC Center at UCPH |
| 7 | +# |
| 8 | +# This file is part of MiG. |
| 9 | +# |
| 10 | +# MiG is free software: you can redistribute it and/or modify |
| 11 | +# it under the terms of the GNU General Public License as published by |
| 12 | +# the Free Software Foundation; either version 2 of the License, or |
| 13 | +# (at your option) any later version. |
| 14 | +# |
| 15 | +# MiG is distributed in the hope that it will be useful, |
| 16 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | +# GNU General Public License for more details. |
| 19 | +# |
| 20 | +# You should have received a copy of the GNU General Public License |
| 21 | +# along with this program; if not, write to the Free Software |
| 22 | +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, |
| 23 | +# USA. |
| 24 | +# |
| 25 | +# --- END_HEADER --- |
| 26 | +# |
| 27 | + |
| 28 | +"""Unit test pwcrypto functions""" |
| 29 | + |
| 30 | +import os |
| 31 | +import sys |
| 32 | + |
| 33 | +sys.path.append(os.path.realpath(os.path.join(os.path.dirname(__file__), "."))) |
| 34 | + |
| 35 | +from support import MigTestCase, temppath, testmain |
| 36 | + |
| 37 | +from mig.shared.pwcrypto import * |
| 38 | + |
| 39 | +class MigSharedPwcrypto_make_hash(MigTestCase): |
| 40 | + def test_pickle_string(self): |
| 41 | + expected = "PBKDF2$sha256$10000$MDAwMDAwMDAwMDAw$epib2rEg/HYTQZFnCp7hmIGZ6rzHnViy" |
| 42 | + |
| 43 | + actual = make_hash('foobar', _urandom=lambda vlen: b'0' * vlen) |
| 44 | + |
| 45 | + self.assertEqual(actual, expected, "mismatch pickling string") |
| 46 | + |
| 47 | + |
| 48 | +if __name__ == '__main__': |
| 49 | + testmain() |
0 commit comments