diff options
author | Paul Marillonnet <pmarillonnet@entrouvert.com> | 2022-04-19 09:27:54 (GMT) |
---|---|---|
committer | Paul Marillonnet <pmarillonnet@entrouvert.com> | 2022-04-20 13:01:59 (GMT) |
commit | e27bafd8cb1fb4de97c15e1fa2c5659cb8daa4f0 (patch) | |
tree | 28d839c0038b6d2ac6b1b58b32c31aaf3f1ac896 | |
parent | dedd924f992e38d43c492fc916a57e3a9c4b1598 (diff) | |
download | django-mellon-e27bafd8cb1fb4de97c15e1fa2c5659cb8daa4f0.zip django-mellon-e27bafd8cb1fb4de97c15e1fa2c5659cb8daa4f0.tar.gz django-mellon-e27bafd8cb1fb4de97c15e1fa2c5659cb8daa4f0.tar.bz2 |
handle long attribute truncate variations between django2 & 3 (#64309)
-rw-r--r-- | tests/test_default_adapter.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/tests/test_default_adapter.py b/tests/test_default_adapter.py index b3fd37a..dbadcac 100644 --- a/tests/test_default_adapter.py +++ b/tests/test_default_adapter.py @@ -196,6 +196,8 @@ def test_provision_absent_attribute(settings, django_user_model, idp, saml_attri def test_provision_long_attribute(settings, django_user_model, idp, saml_attributes, caplog): + from django import VERSION + settings.MELLON_IDENTITY_PROVIDERS = [idp] settings.MELLON_ATTRIBUTE_MAPPING = { 'email': '{attributes[email][0]}', @@ -205,11 +207,16 @@ def test_provision_long_attribute(settings, django_user_model, idp, saml_attribu local_saml_attributes = saml_attributes.copy() local_saml_attributes['first_name'] = [('y' * 32)] user = SAMLBackend().authenticate(saml_attributes=local_saml_attributes) - assert user.first_name == 'y' * 30 assert len(caplog.records) == 4 assert 'created new user' in caplog.text assert 'set field first_name' in caplog.text - assert 'to value %r ' % ('y' * 30) in caplog.text + if VERSION[0] <= 2: + assert user.first_name == 'y' * 30 + assert 'to value %r ' % ('y' * 30) in caplog.text + else: + # django users' first name attribute longer from django3 onwards + assert user.first_name == 'y' * 32 + assert 'to value %r ' % ('y' * 32) in caplog.text assert 'set field last_name' in caplog.text assert 'set field email' in caplog.text |