def test_default_is_secret(settings):
result = settings.SECRET_KEY
assert result == '__SECRET_KEY__'
def test_settings_not_updated(api_client, url, user, settings):
"""
When settings are updated using pytest's settings fixture, the
``state.token_backend`` instance has already been created with the old
value of the setting and is not updated.
"""
settings.SIMPLE_JWT = {
'SIGNING_KEY': '__SIGNING_KEY__',
}
data = {
'username': 'a_user',
'password': '__PASSWORD__',
}
result = api_client.post(url, data=data)
assert result.status_code == 200
assert sorted(result.data) == ['access', 'refresh']
jwt.decode(result.data['access'], key='__SECRET_KEY__', algorithms=['HS256'])
My experience here is probably just an edge case, but if a fix is on the cards, then my suggestion would be to change token_backend
from being statically created to using some kind of function like get_token_backend()
to generate the TokenBackend
instance when required rather when loaded.