Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
Signed-off-by: Aurélien Bompard <aurelien@bompard.org>
  • Loading branch information
abompard committed Dec 13, 2021
1 parent 6820439 commit 12ae954
Show file tree
Hide file tree
Showing 8 changed files with 417 additions and 434 deletions.
1 change: 1 addition & 0 deletions news/PR828.dependency
@@ -0,0 +1 @@
Update to Flask 2.0, and update other dependencies
5 changes: 2 additions & 3 deletions noggin/form/base.py
@@ -1,10 +1,9 @@
from flask_wtf import FlaskForm
from markupsafe import escape, Markup
from wtforms import Field, SubmitField
from wtforms.fields.core import FieldList, SelectField, StringField
from wtforms.fields import FieldList, SelectField, StringField
from wtforms.utils import unset_value
from wtforms.widgets import TextInput
from wtforms.widgets.core import html_params
from wtforms.widgets import html_params, TextInput


class BaseForm(FlaskForm):
Expand Down
10 changes: 7 additions & 3 deletions noggin/form/edit_user.py
Expand Up @@ -3,16 +3,17 @@

from flask_babel import lazy_gettext as _
from pyotp import TOTP
from wtforms import (
from wtforms.fields import (
BooleanField,
EmailField,
FieldList,
HiddenField,
PasswordField,
SelectField,
StringField,
TextAreaField,
URLField,
)
from wtforms.fields.html5 import EmailField, URLField
from wtforms.validators import (
AnyOf,
DataRequired,
Expand Down Expand Up @@ -187,7 +188,10 @@ class UserSettingsConfirmOTPForm(ModestForm):
"secret",
validators=[DataRequired(message=_('Could not find the token secret'))],
)
description = HiddenField("description", validators=[Optional()],)
description = HiddenField(
"description",
validators=[Optional()],
)
code = StringField(
_("Verification Code"),
validators=[DataRequired(message=_('You must provide a verification code'))],
Expand Down
9 changes: 7 additions & 2 deletions noggin/form/register_user.py
@@ -1,6 +1,11 @@
from flask_babel import lazy_gettext as _
from wtforms import BooleanField, HiddenField, PasswordField, StringField
from wtforms.fields.html5 import EmailField
from wtforms.fields import (
BooleanField,
EmailField,
HiddenField,
PasswordField,
StringField,
)
from wtforms.validators import DataRequired, EqualTo, Length

from noggin.form.validators import Email, PasswordLength, StopOnError, username_format
Expand Down
15 changes: 12 additions & 3 deletions noggin/tests/unit/controller/test_root.py
Expand Up @@ -116,15 +116,17 @@ def test_healthz_liveness(client):
"""Test the /healthz/live check endpoint"""
result = client.get('/healthz/live')
assert result.status_code == 200
assert result.data == b'OK\n'
assert result.json == {"status": 200, "title": "OK"}
assert result.data == b'{"status": 200, "title": "OK"}'


@pytest.mark.vcr()
def test_healthz_readiness_ok(client):
"""Test the /healthz/ready check endpoint"""
result = client.get('/healthz/ready')
assert result.status_code == 200
assert result.data == b'OK\n'
assert result.json == {"status": 200, "title": "OK"}
assert result.data == b'{"status": 200, "title": "OK"}'


@pytest.mark.vcr()
Expand All @@ -134,7 +136,14 @@ def test_healthz_readiness_not_ok(client):
ipaping.side_effect = Exception()
result = client.get('/healthz/ready')
assert result.status_code == 503
assert result.data == b"Can't connect to the FreeIPA Server\n"
assert result.json == {
"status": 503,
"title": "Can't connect to the FreeIPA Server",
}
assert (
result.data
== b'{"status": 503, "title": "Can\'t connect to the FreeIPA Server"}'
)


@pytest.mark.vcr()
Expand Down
5 changes: 3 additions & 2 deletions noggin/utility/token.py
Expand Up @@ -24,7 +24,7 @@ def make_token(data, audience, ttl=None):
if ttl is not None:
data["exp"] = datetime.utcnow() + timedelta(minutes=ttl)
token = jwt.encode(data, current_app.config["SECRET_KEY"], algorithm="HS256")
return str(token, "ascii")
return token


def read_token(token, audience=None):
Expand All @@ -41,5 +41,6 @@ def make_password_change_token(user):
if lpc is not None:
lpc = lpc.isoformat()
return make_token(
{"sub": user.username, "lpc": lpc}, audience=Audience.password_reset,
{"sub": user.username, "lpc": lpc},
audience=Audience.password_reset,
)

0 comments on commit 12ae954

Please sign in to comment.