Skip to content
Snippets Groups Projects
Commit 39accc0a authored by Julia Eskew's avatar Julia Eskew
Browse files

Make hash generation method private.

parent ad2cdb8c
Branches
Tags
No related merge requests found
......@@ -291,7 +291,7 @@ def get_retired_email_by_email(email):
return user_util.get_retired_email(email, settings.RETIRED_USER_SALTS, settings.RETIRED_EMAIL_FMT)
def get_all_retired_usernames_by_username(username):
def _get_all_retired_usernames_by_username(username):
"""
Returns a generator of "retired usernames", one hashed with each
configured salt. Used for finding out if the given username has
......@@ -300,7 +300,7 @@ def get_all_retired_usernames_by_username(username):
return user_util.get_all_retired_usernames(username, settings.RETIRED_USER_SALTS, settings.RETIRED_USERNAME_FMT)
def get_all_retired_emails_by_email(email):
def _get_all_retired_emails_by_email(email):
"""
Returns a generator of "retired emails", one hashed with each
configured salt. Used for finding out if the given email has
......@@ -315,7 +315,7 @@ def get_potentially_retired_user_by_username(username):
does not exist, then any hashed username salted with the historical
salts.
"""
locally_hashed_usernames = list(get_all_retired_usernames_by_username(username))
locally_hashed_usernames = list(_get_all_retired_usernames_by_username(username))
locally_hashed_usernames.append(username)
potential_users = User.objects.filter(username__in=locally_hashed_usernames)
......@@ -360,7 +360,7 @@ def get_potentially_retired_user_by_username_and_hash(username, hashed_username)
does not exist, the any hashed username salted with the historical
salts.
"""
locally_hashed_usernames = list(get_all_retired_usernames_by_username(username))
locally_hashed_usernames = list(_get_all_retired_usernames_by_username(username))
if hashed_username not in locally_hashed_usernames:
raise Exception('Mismatched hashed_username, bad salt?')
......
......@@ -12,8 +12,8 @@ from django.test import TestCase
import pytest
from student.models import (
get_all_retired_emails_by_email,
get_all_retired_usernames_by_username,
_get_all_retired_emails_by_email,
_get_all_retired_usernames_by_username,
get_potentially_retired_user_by_username,
get_potentially_retired_user_by_username_and_hash,
get_retired_email_by_email,
......@@ -110,7 +110,7 @@ def test_get_all_retired_usernames_by_username(retirement_user):
Check that all salts are used for this method and return expected
formats.
"""
hashed_usernames = list(get_all_retired_usernames_by_username(retirement_user.username))
hashed_usernames = list(_get_all_retired_usernames_by_username(retirement_user.username))
assert len(hashed_usernames) == len(settings.RETIRED_USER_SALTS)
for hashed_username in hashed_usernames:
......@@ -185,7 +185,7 @@ def test_get_all_retired_email_by_email(retirement_user):
Check that all salts are used for this method and return expected
formats.
"""
hashed_emails = list(get_all_retired_emails_by_email(retirement_user.email))
hashed_emails = list(_get_all_retired_emails_by_email(retirement_user.email))
assert len(hashed_emails) == len(settings.RETIRED_USER_SALTS)
for hashed_email in hashed_emails:
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment