Skip to content

Commit 704f996

Browse files
authored
fix: remove no longer needed htpasswd infrastructure (ietf-tools#7590)
1 parent a1902cf commit 704f996

5 files changed

Lines changed: 0 additions & 168 deletions

File tree

ietf/ietfauth/htpasswd.py

Lines changed: 0 additions & 30 deletions
This file was deleted.

ietf/ietfauth/tests.py

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@
33

44

55
import datetime
6-
import io
76
import logging # pyflakes:ignore
8-
import os
97
import re
108
import requests
119
import requests_mock
12-
import shutil
1310
import time
1411
import urllib
1512

@@ -21,7 +18,6 @@
2118
from oic.utils.authn.client import CLIENT_AUTHN_METHOD
2219
from oidc_provider.models import RSAKey
2320
from pyquery import PyQuery
24-
from unittest import skipIf
2521
from urllib.parse import urlsplit
2622

2723
import django.core.signing
@@ -35,7 +31,6 @@
3531

3632
from ietf.group.factories import GroupFactory, RoleFactory
3733
from ietf.group.models import Group, Role, RoleName
38-
from ietf.ietfauth.htpasswd import update_htpasswd_file
3934
from ietf.ietfauth.utils import has_role
4035
from ietf.meeting.factories import MeetingFactory
4136
from ietf.nomcom.factories import NomComFactory
@@ -45,41 +40,12 @@
4540
from ietf.review.factories import ReviewRequestFactory, ReviewAssignmentFactory
4641
from ietf.review.models import ReviewWish, UnavailablePeriod
4742
from ietf.stats.models import MeetingRegistration
48-
from ietf.utils.decorators import skip_coverage
4943
from ietf.utils.mail import outbox, empty_outbox, get_payload_text
5044
from ietf.utils.test_utils import TestCase, login_testing_unauthorized
5145
from ietf.utils.timezone import date_today
5246

5347

54-
if os.path.exists(settings.HTPASSWD_COMMAND):
55-
skip_htpasswd_command = False
56-
skip_message = ""
57-
else:
58-
skip_htpasswd_command = True
59-
skip_message = ("Skipping htpasswd test: The binary for htpasswd wasn't found in the\n "
60-
"location indicated in settings.py.")
61-
print(" "+skip_message)
62-
6348
class IetfAuthTests(TestCase):
64-
def setUp(self):
65-
super().setUp()
66-
self.saved_use_python_htdigest = getattr(settings, "USE_PYTHON_HTDIGEST", None)
67-
settings.USE_PYTHON_HTDIGEST = True
68-
69-
self.saved_htpasswd_file = settings.HTPASSWD_FILE
70-
self.htpasswd_dir = self.tempdir('htpasswd')
71-
settings.HTPASSWD_FILE = os.path.join(self.htpasswd_dir, "htpasswd")
72-
io.open(settings.HTPASSWD_FILE, 'a').close() # create empty file
73-
74-
self.saved_htdigest_realm = getattr(settings, "HTDIGEST_REALM", None)
75-
settings.HTDIGEST_REALM = "test-realm"
76-
77-
def tearDown(self):
78-
shutil.rmtree(self.htpasswd_dir)
79-
settings.USE_PYTHON_HTDIGEST = self.saved_use_python_htdigest
80-
settings.HTPASSWD_FILE = self.saved_htpasswd_file
81-
settings.HTDIGEST_REALM = self.saved_htdigest_realm
82-
super().tearDown()
8349

8450
def test_index(self):
8551
self.assertEqual(self.client.get(urlreverse("ietf.ietfauth.views.index")).status_code, 200)
@@ -162,15 +128,6 @@ def extract_confirm_url(self, confirm_email):
162128

163129
return confirm_url
164130

165-
def username_in_htpasswd_file(self, username):
166-
with io.open(settings.HTPASSWD_FILE) as f:
167-
for l in f:
168-
if l.startswith(username + ":"):
169-
return True
170-
with io.open(settings.HTPASSWD_FILE) as f:
171-
print(f.read())
172-
173-
return False
174131

175132
# For the lowered barrier to account creation period, we are disabling this kind of failure
176133
# def test_create_account_failure(self):
@@ -223,8 +180,6 @@ def register_and_verify(self, email):
223180
self.assertEqual(Person.objects.filter(user__username=email).count(), 1)
224181
self.assertEqual(Email.objects.filter(person__user__username=email).count(), 1)
225182

226-
self.assertTrue(self.username_in_htpasswd_file(email))
227-
228183

229184
# This also tests new account creation.
230185
def test_create_existing_account(self):
@@ -490,7 +445,6 @@ def test_reset_password(self):
490445
self.assertEqual(r.status_code, 200)
491446
q = PyQuery(r.content)
492447
self.assertEqual(len(q("form .is-invalid")), 0)
493-
self.assertTrue(self.username_in_htpasswd_file(user.username))
494448

495449
# reuse reset url
496450
r = self.client.get(confirm_url)
@@ -614,23 +568,6 @@ def test_review_overview(self):
614568
self.assertEqual(r.status_code, 302)
615569
self.assertEqual(ReviewWish.objects.filter(doc=doc, team=review_req.team).count(), 0)
616570

617-
def test_htpasswd_file_with_python(self):
618-
# make sure we test both Python and call-out to binary
619-
settings.USE_PYTHON_HTDIGEST = True
620-
621-
update_htpasswd_file("foo", "passwd")
622-
self.assertTrue(self.username_in_htpasswd_file("foo"))
623-
624-
@skipIf(skip_htpasswd_command, skip_message)
625-
@skip_coverage
626-
def test_htpasswd_file_with_htpasswd_binary(self):
627-
# make sure we test both Python and call-out to binary
628-
settings.USE_PYTHON_HTDIGEST = False
629-
630-
update_htpasswd_file("foo", "passwd")
631-
self.assertTrue(self.username_in_htpasswd_file("foo"))
632-
633-
634571
def test_change_password(self):
635572
chpw_url = urlreverse("ietf.ietfauth.views.change_password")
636573
prof_url = urlreverse("ietf.ietfauth.views.profile")

ietf/ietfauth/views.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
from ietf.ietfauth.forms import ( RegistrationForm, PasswordForm, ResetPasswordForm, TestEmailForm,
6666
ChangePasswordForm, get_person_form, RoleEmailForm,
6767
NewEmailForm, ChangeUsernameForm, PersonPasswordForm)
68-
from ietf.ietfauth.htpasswd import update_htpasswd_file
6968
from ietf.ietfauth.utils import has_role
7069
from ietf.name.models import ExtResourceName
7170
from ietf.nomcom.models import NomCom
@@ -222,8 +221,6 @@ def confirm_account(request, auth):
222221
user = User.objects.create(username=email, email=email)
223222
user.set_password(password)
224223
user.save()
225-
# password is also stored in htpasswd file
226-
update_htpasswd_file(email, password)
227224

228225
# make sure the rest of the person infrastructure is
229226
# well-connected
@@ -552,8 +549,6 @@ def confirm_password_reset(request, auth):
552549

553550
user.set_password(password)
554551
user.save()
555-
# password is also stored in htpasswd file
556-
update_htpasswd_file(user.username, password)
557552

558553
success = True
559554
else:
@@ -693,8 +688,6 @@ def change_password(request):
693688

694689
user.set_password(new_password)
695690
user.save()
696-
# password is also stored in htpasswd file
697-
update_htpasswd_file(user.username, new_password)
698691
# keep the session
699692
update_session_auth_hash(request, user)
700693

@@ -731,13 +724,10 @@ def change_username(request):
731724
form = ChangeUsernameForm(user, request.POST)
732725
if form.is_valid():
733726
new_username = form.cleaned_data["username"]
734-
password = form.cleaned_data["password"]
735727
assert new_username in emails
736728

737729
user.username = new_username.lower()
738730
user.save()
739-
# password is also stored in htpasswd file
740-
update_htpasswd_file(user.username, password)
741731
# keep the session
742732
update_session_auth_hash(request, user)
743733

ietf/settings.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -979,8 +979,6 @@ def skip_unreadable_post(record):
979979
# Account settings
980980
DAYS_TO_EXPIRE_REGISTRATION_LINK = 3
981981
MINUTES_TO_EXPIRE_RESET_PASSWORD_LINK = 60
982-
HTPASSWD_COMMAND = "/usr/bin/htpasswd"
983-
HTPASSWD_FILE = "/a/www/htpasswd"
984982

985983
# Generation of pdf files
986984
GHOSTSCRIPT_COMMAND = "/usr/bin/gs"

ietf/utils/management/commands/import_htpasswd.py

Lines changed: 0 additions & 63 deletions
This file was deleted.

0 commit comments

Comments
 (0)