Skip to content

Commit

Permalink
[#2076] Upgrade dependencies and fix tests
Browse files Browse the repository at this point in the history
    * upgrade mayin-2fa to 1.0.0
    * upgrade django-otp to 1.3.0
    * upgrade django-two-factor-auth to 1.16.0
  • Loading branch information
pi-sigma committed Feb 6, 2024
1 parent 4d8dc1a commit e7a0507
Show file tree
Hide file tree
Showing 24 changed files with 108 additions and 75 deletions.
27 changes: 13 additions & 14 deletions requirements/base.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#
# This file is autogenerated by pip-compile with python 3.11
# To update, run:
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# ./bin/compile_dependencies.sh
#
Expand Down Expand Up @@ -204,7 +204,7 @@ django-ordered-model==3.4.3
# via
# -r requirements/base.in
# django-admin-index
django-otp==1.1.1
django-otp==1.3.0
# via django-two-factor-auth
django-phonenumber-field==5.2.0
# via django-two-factor-auth
Expand Down Expand Up @@ -252,7 +252,7 @@ django-treebeard==4.4
# -r requirements/base.in
# django-cms
# djangocms-attributes-field
django-two-factor-auth[phonenumberslite,webauthn]==1.15.5
django-two-factor-auth[phonenumberslite,webauthn]==1.16.0
# via maykin-2fa
django-view-breadcrumbs==2.2.4
# via -r requirements/base.in
Expand Down Expand Up @@ -304,7 +304,9 @@ face==20.1.1
fontawesomefree==6.4.2
# via -r requirements/base.in
fonttools[woff]==4.29.1
# via weasyprint
# via
# fonttools
# weasyprint
furl==2.1.3
# via
# -r requirements/base.in
Expand Down Expand Up @@ -358,7 +360,7 @@ markdown==3.3.6
# via -r requirements/base.in
markuppy==1.14
# via tablib
maykin-2fa==0.2.0
maykin-2fa==1.0.0
# via -r requirements/base.in
maykin-python3-saml==1.14.0.post0
# via
Expand All @@ -382,7 +384,7 @@ orderedmultidict==1.0.1
# via furl
packaging==23.0
# via djangocms-text-ckeditor
phonenumbers==8.12.33
phonenumbers==8.13.29
# via -r requirements/base.in
phonenumberslite==8.13.29
# via django-two-factor-auth
Expand All @@ -403,10 +405,6 @@ psycopg2==2.9.9
# via -r requirements/base.in
pycparser==2.20
# via cffi
pydantic==1.10.14
# via
# django-two-factor-auth
# webauthn
pydyf==0.1.2
# via weasyprint
pyee==11.0.1
Expand Down Expand Up @@ -494,7 +492,9 @@ sqlparse==0.4.4
svglib==1.5.1
# via easy-thumbnails
tablib[html,ods,xls,xlsx,yaml]==3.1.0
# via django-import-export
# via
# django-import-export
# tablib
tinycss2==1.1.1
# via
# -r requirements/base.in
Expand All @@ -503,7 +503,6 @@ tinycss2==1.1.1
# weasyprint
typing-extensions==4.4.0
# via
# pydantic
# pyee
# xsdata
uritemplate==4.1.1
Expand All @@ -525,7 +524,7 @@ wcwidth==0.2.5
# via prompt-toolkit
weasyprint==54.2
# via -r requirements/base.in
webauthn==1.11.1
webauthn==2.0.0
# via django-two-factor-auth
webencodings==0.5.1
# via
Expand Down
25 changes: 11 additions & 14 deletions requirements/ci.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#
# This file is autogenerated by pip-compile with python 3.11
# To update, run:
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# ./bin/compile_dependencies.sh
#
Expand Down Expand Up @@ -335,7 +335,7 @@ django-ordered-model==3.4.3
# -c requirements/base.txt
# -r requirements/base.txt
# django-admin-index
django-otp==1.1.1
django-otp==1.3.0
# via
# -c requirements/base.txt
# -r requirements/base.txt
Expand Down Expand Up @@ -417,10 +417,11 @@ django-treebeard==4.4
# -r requirements/base.txt
# django-cms
# djangocms-attributes-field
django-two-factor-auth[phonenumberslite,webauthn]==1.15.5
django-two-factor-auth[phonenumberslite,webauthn]==1.16.0
# via
# -c requirements/base.txt
# -r requirements/base.txt
# django-two-factor-auth
# maykin-2fa
django-view-breadcrumbs==2.2.4
# via
Expand Down Expand Up @@ -482,6 +483,7 @@ easy-thumbnails[svg]==2.8.5
# -r requirements/base.txt
# django-filer
# djangocms-picture
# easy-thumbnails
ecs-logging==2.1.0
# via
# -c requirements/base.txt
Expand Down Expand Up @@ -523,6 +525,7 @@ fonttools[woff]==4.29.1
# via
# -c requirements/base.txt
# -r requirements/base.txt
# fonttools
# weasyprint
freezegun==1.1.0
# via -r requirements/test-tools.in
Expand Down Expand Up @@ -633,7 +636,7 @@ markuppy==1.14
# -c requirements/base.txt
# -r requirements/base.txt
# tablib
maykin-2fa==0.2.0
maykin-2fa==1.0.0
# via
# -c requirements/base.txt
# -r requirements/base.txt
Expand Down Expand Up @@ -687,7 +690,7 @@ packaging==23.0
# djangocms-text-ckeditor
pep8==1.7.1
# via -r requirements/test-tools.in
phonenumbers==8.12.33
phonenumbers==8.13.29
# via
# -c requirements/base.txt
# -r requirements/base.txt
Expand Down Expand Up @@ -729,12 +732,6 @@ pycparser==2.20
# -c requirements/base.txt
# -r requirements/base.txt
# cffi
pydantic==1.10.14
# via
# -c requirements/base.txt
# -r requirements/base.txt
# django-two-factor-auth
# webauthn
pydyf==0.1.2
# via
# -c requirements/base.txt
Expand Down Expand Up @@ -892,6 +889,7 @@ tablib[html,ods,xls,xlsx,yaml]==3.1.0
# -c requirements/base.txt
# -r requirements/base.txt
# django-import-export
# tablib
tblib==1.7.0
# via -r requirements/test-tools.in
text-unidecode==1.3
Expand All @@ -909,7 +907,6 @@ typing-extensions==4.4.0
# via
# -c requirements/base.txt
# -r requirements/base.txt
# pydantic
# pyee
# xsdata
uritemplate==4.1.1
Expand Down Expand Up @@ -947,7 +944,7 @@ weasyprint==54.2
# via
# -c requirements/base.txt
# -r requirements/base.txt
webauthn==1.11.1
webauthn==2.0.0
# via
# -c requirements/base.txt
# -r requirements/base.txt
Expand Down
25 changes: 11 additions & 14 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#
# This file is autogenerated by pip-compile with python 3.11
# To update, run:
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# ./bin/compile_dependencies.sh
#
Expand Down Expand Up @@ -374,7 +374,7 @@ django-ordered-model==3.4.3
# -c requirements/ci.txt
# -r requirements/ci.txt
# django-admin-index
django-otp==1.1.1
django-otp==1.3.0
# via
# -c requirements/ci.txt
# -r requirements/ci.txt
Expand Down Expand Up @@ -456,10 +456,11 @@ django-treebeard==4.4
# -r requirements/ci.txt
# django-cms
# djangocms-attributes-field
django-two-factor-auth[phonenumberslite,webauthn]==1.15.5
django-two-factor-auth[phonenumberslite,webauthn]==1.16.0
# via
# -c requirements/ci.txt
# -r requirements/ci.txt
# django-two-factor-auth
# maykin-2fa
django-view-breadcrumbs==2.2.4
# via
Expand Down Expand Up @@ -527,6 +528,7 @@ easy-thumbnails[svg]==2.8.5
# -r requirements/ci.txt
# django-filer
# djangocms-picture
# easy-thumbnails
ecs-logging==2.1.0
# via
# -c requirements/ci.txt
Expand Down Expand Up @@ -584,6 +586,7 @@ fonttools[woff]==4.29.1
# via
# -c requirements/ci.txt
# -r requirements/ci.txt
# fonttools
# weasyprint
freezegun==1.1.0
# via
Expand Down Expand Up @@ -728,7 +731,7 @@ markupsafe==2.1.3
# via
# jinja2
# werkzeug
maykin-2fa==0.2.0
maykin-2fa==1.0.0
# via
# -c requirements/ci.txt
# -r requirements/ci.txt
Expand Down Expand Up @@ -800,7 +803,7 @@ pep8==1.7.1
# via
# -c requirements/ci.txt
# -r requirements/ci.txt
phonenumbers==8.12.33
phonenumbers==8.13.29
# via
# -c requirements/ci.txt
# -r requirements/ci.txt
Expand Down Expand Up @@ -852,12 +855,6 @@ pycparser==2.20
# -c requirements/ci.txt
# -r requirements/ci.txt
# cffi
pydantic==1.10.14
# via
# -c requirements/ci.txt
# -r requirements/ci.txt
# django-two-factor-auth
# webauthn
pydyf==0.1.2
# via
# -c requirements/ci.txt
Expand Down Expand Up @@ -1060,6 +1057,7 @@ tablib[html,ods,xls,xlsx,yaml]==3.1.0
# -c requirements/ci.txt
# -r requirements/ci.txt
# django-import-export
# tablib
tblib==1.7.0
# via
# -c requirements/ci.txt
Expand Down Expand Up @@ -1087,7 +1085,6 @@ typing-extensions==4.4.0
# via
# -c requirements/ci.txt
# -r requirements/ci.txt
# pydantic
# pyee
# xsdata
uritemplate==4.1.1
Expand Down Expand Up @@ -1128,7 +1125,7 @@ weasyprint==54.2
# via
# -c requirements/ci.txt
# -r requirements/ci.txt
webauthn==1.11.1
webauthn==2.0.0
# via
# -c requirements/ci.txt
# -r requirements/ci.txt
Expand Down
2 changes: 2 additions & 0 deletions src/open_inwoner/accounts/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from django.utils.translation import ugettext as _

from django_webtest import WebTest
from maykin_2fa.test import disable_admin_mfa
from webtest import Upload

from open_inwoner.utils.tests.helpers import create_image_bytes
Expand All @@ -11,6 +12,7 @@
from .factories import UserFactory


@disable_admin_mfa()
class TestAdminUser(WebTest):
def setUp(self):
self.user = UserFactory(
Expand Down
8 changes: 7 additions & 1 deletion src/open_inwoner/accounts/tests/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

from django_webtest import WebTest
from freezegun import freeze_time
from maykin_2fa.test import disable_admin_mfa
from privates.test import temp_private_root
from timeline_logger.models import TimelineLog

Expand All @@ -30,6 +31,7 @@
)


@disable_admin_mfa()
@freeze_time("2021-10-18 13:00:00")
@override_settings(ROOT_URLCONF="open_inwoner.cms.tests.urls")
class TestProfile(WebTest):
Expand Down Expand Up @@ -115,7 +117,11 @@ def test_user_notifications_update_is_logged(self, mock_cms_page_display):
)

def test_login_via_admin_is_logged(self):
self.app.post(reverse("admin:login"), user=self.user)
login_page = self.app.get(reverse("admin:login"))
login_page.form["auth-username"] = self.user.email
login_page.form["auth-password"] = "secret"
login_page.form.submit()

log_entry = TimelineLog.objects.get()

self.assertEqual(
Expand Down
7 changes: 4 additions & 3 deletions src/open_inwoner/cms/tests/test_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
from django.test import TestCase, override_settings
from django.urls import reverse

from maykin_2fa.test import disable_admin_mfa
from pyquery import PyQuery as pq

from open_inwoner.cms.tests import cms_tools
from open_inwoner.cms.utils.middleware import DropToolbarMiddleware
from open_inwoner.utils.tests.helpers import TwoFactorUserTestMixin


@override_settings(TWO_FACTOR_FORCE_OTP_ADMIN=False)
class TestDropToolbarMiddleware(TwoFactorUserTestMixin, TestCase):
@classmethod
def setUpTestData(cls):
Expand All @@ -28,29 +28,30 @@ def test_anon_shows_no_toolbar(self):

self.assertNotHasToolbar(response)

@disable_admin_mfa()
def test_not_staff_not_verified_no_2fa_shows_no_toolbar(self):
self.create_user()
self.login_user()
response = self.client.get(self.url)

self.assertNotHasToolbar(response)

@disable_admin_mfa()
def test_staff_not_verified_no_2fa_shows_toolbar(self):
self.create_user(is_staff=True)
self.login_user()
response = self.client.get(self.url)

self.assertHasToolbar(response)

@override_settings(TWO_FACTOR_FORCE_OTP_ADMIN=True)
@override_settings(MAYKIN_2FA_ALLOW_MFA_BYPASS_BACKENDS=[])
def test_staff_not_verified_with_2fa_shows_no_toolbar(self):
self.create_user(is_staff=True)
self.login_user()
response = self.client.get(self.url)

self.assertNotHasToolbar(response)

@override_settings(TWO_FACTOR_FORCE_OTP_ADMIN=True)
def test_staff_verified_with_2fa_shows_toolbar(self):
self.create_user(is_staff=True)
self.enable_otp()
Expand Down
Loading

0 comments on commit e7a0507

Please sign in to comment.