|
3 | 3 |
|
4 | 4 |
|
5 | 5 | import datetime |
6 | | -import io |
7 | 6 | import logging # pyflakes:ignore |
8 | | -import os |
9 | 7 | import re |
10 | 8 | import requests |
11 | 9 | import requests_mock |
12 | | -import shutil |
13 | 10 | import time |
14 | 11 | import urllib |
15 | 12 |
|
|
21 | 18 | from oic.utils.authn.client import CLIENT_AUTHN_METHOD |
22 | 19 | from oidc_provider.models import RSAKey |
23 | 20 | from pyquery import PyQuery |
24 | | -from unittest import skipIf |
25 | 21 | from urllib.parse import urlsplit |
26 | 22 |
|
27 | 23 | import django.core.signing |
|
35 | 31 |
|
36 | 32 | from ietf.group.factories import GroupFactory, RoleFactory |
37 | 33 | from ietf.group.models import Group, Role, RoleName |
38 | | -from ietf.ietfauth.htpasswd import update_htpasswd_file |
39 | 34 | from ietf.ietfauth.utils import has_role |
40 | 35 | from ietf.meeting.factories import MeetingFactory |
41 | 36 | from ietf.nomcom.factories import NomComFactory |
|
45 | 40 | from ietf.review.factories import ReviewRequestFactory, ReviewAssignmentFactory |
46 | 41 | from ietf.review.models import ReviewWish, UnavailablePeriod |
47 | 42 | from ietf.stats.models import MeetingRegistration |
48 | | -from ietf.utils.decorators import skip_coverage |
49 | 43 | from ietf.utils.mail import outbox, empty_outbox, get_payload_text |
50 | 44 | from ietf.utils.test_utils import TestCase, login_testing_unauthorized |
51 | 45 | from ietf.utils.timezone import date_today |
52 | 46 |
|
53 | 47 |
|
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 | | - |
63 | 48 | 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() |
83 | 49 |
|
84 | 50 | def test_index(self): |
85 | 51 | self.assertEqual(self.client.get(urlreverse("ietf.ietfauth.views.index")).status_code, 200) |
@@ -162,15 +128,6 @@ def extract_confirm_url(self, confirm_email): |
162 | 128 |
|
163 | 129 | return confirm_url |
164 | 130 |
|
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 |
174 | 131 |
|
175 | 132 | # For the lowered barrier to account creation period, we are disabling this kind of failure |
176 | 133 | # def test_create_account_failure(self): |
@@ -223,8 +180,6 @@ def register_and_verify(self, email): |
223 | 180 | self.assertEqual(Person.objects.filter(user__username=email).count(), 1) |
224 | 181 | self.assertEqual(Email.objects.filter(person__user__username=email).count(), 1) |
225 | 182 |
|
226 | | - self.assertTrue(self.username_in_htpasswd_file(email)) |
227 | | - |
228 | 183 |
|
229 | 184 | # This also tests new account creation. |
230 | 185 | def test_create_existing_account(self): |
@@ -490,7 +445,6 @@ def test_reset_password(self): |
490 | 445 | self.assertEqual(r.status_code, 200) |
491 | 446 | q = PyQuery(r.content) |
492 | 447 | self.assertEqual(len(q("form .is-invalid")), 0) |
493 | | - self.assertTrue(self.username_in_htpasswd_file(user.username)) |
494 | 448 |
|
495 | 449 | # reuse reset url |
496 | 450 | r = self.client.get(confirm_url) |
@@ -614,23 +568,6 @@ def test_review_overview(self): |
614 | 568 | self.assertEqual(r.status_code, 302) |
615 | 569 | self.assertEqual(ReviewWish.objects.filter(doc=doc, team=review_req.team).count(), 0) |
616 | 570 |
|
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 | | - |
634 | 571 | def test_change_password(self): |
635 | 572 | chpw_url = urlreverse("ietf.ietfauth.views.change_password") |
636 | 573 | prof_url = urlreverse("ietf.ietfauth.views.profile") |
|
0 commit comments