handle long attribute truncate variations between django2 & 3 (#64309)
This commit is contained in:
parent
dedd924f99
commit
e27bafd8cb
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue