mirror of
https://gitlab.com/tildes/tildes.git
synced 2026-04-16 06:18:34 +02:00
This follows the REUSE practices to add license and copyright info to all source files: https://reuse.software/practices/2.0/ In addition, LICENSE.md was switched to a plaintext LICENSE file, to support the tag-value header as recommended. Note that files that are closer to configuration than code did not have headers added. This includes all Salt files, Alembic files, and Python files such as most __init__.py files that only import other files, since those are similar to header files which are not considered copyrightable.
21 lines
655 B
Python
21 lines
655 B
Python
# Copyright (c) 2018 Tildes contributors <code@tildes.net>
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
from tildes.lib.hash import hash_string, is_match_for_hash
|
|
|
|
|
|
def test_same_string_verifies():
|
|
"""Ensure that the same string will match the hashed result."""
|
|
string = "hunter2"
|
|
hashed = hash_string(string)
|
|
assert is_match_for_hash(string, hashed)
|
|
|
|
|
|
def test_different_string_fails():
|
|
"""Ensure that a different string doesn't match the hash."""
|
|
string = "correct horse battery staple"
|
|
wrong_string = "incorrect horse battery staple"
|
|
|
|
hashed = hash_string(string)
|
|
assert not is_match_for_hash(wrong_string, hashed)
|