Projet

Général

Profil

0004-handle-long-attribute-truncate-variations-between-dj.patch

Paul Marillonnet, 20 avril 2022 10:14

Télécharger (1,68 ko)

Voir les différences:

Subject: [PATCH 4/6] handle long attribute truncate variations between django2
 & 3 (#64309)

 tests/test_default_adapter.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
tests/test_default_adapter.py
196 196

  
197 197

  
198 198
def test_provision_long_attribute(settings, django_user_model, idp, saml_attributes, caplog):
199
    from django import VERSION
200

  
199 201
    settings.MELLON_IDENTITY_PROVIDERS = [idp]
200 202
    settings.MELLON_ATTRIBUTE_MAPPING = {
201 203
        'email': '{attributes[email][0]}',
......
205 207
    local_saml_attributes = saml_attributes.copy()
206 208
    local_saml_attributes['first_name'] = [('y' * 32)]
207 209
    user = SAMLBackend().authenticate(saml_attributes=local_saml_attributes)
208
    assert user.first_name == 'y' * 30
210
    assert user.first_name in 'y' * 32
209 211
    assert len(caplog.records) == 4
210 212
    assert 'created new user' in caplog.text
211 213
    assert 'set field first_name' in caplog.text
212
    assert 'to value %r ' % ('y' * 30) in caplog.text
214
    if VERSION[0] <= 2:
215
        assert 'to value %r ' % ('y' * 30) in caplog.text
216
    else:
217
        assert 'to value %r ' % ('y' * 32) in caplog.text
213 218
    assert 'set field last_name' in caplog.text
214 219
    assert 'set field email' in caplog.text
215 220

  
216
-