Projet

Général

Profil

0001-misc-fix-log-visibility-for-users-with-dispatched-fu.patch

Frédéric Péters, 17 juillet 2017 22:06

Télécharger (3,78 ko)

Voir les différences:

Subject: [PATCH] misc: fix log visibility for users with dispatched functions
 (#17672)

 tests/test_backoffice_pages.py | 58 ++++++++++++++++++++++++++++++++++++++++++
 wcs/formdef.py                 |  2 ++
 2 files changed, 60 insertions(+)
tests/test_backoffice_pages.py
3632 3632
    FormDef.wipe()
3633 3633
    resp = resp2.click('ZeroDivisionError')
3634 3634
    assert not 'href="http://example.net/backoffice/management/test/' in resp.body
3635

  
3636
def test_backoffice_private_status_and_history(pub):
3637
    create_user(pub)
3638
    create_environment(pub)
3639
    formdef = FormDef.get_by_urlname('form-title')
3640
    formdef.private_status_and_history = True
3641
    formdef.store()
3642
    form_class = FormDef.get_by_urlname('form-title').data_class()
3643
    number31 = [x for x in form_class.select() if x.data['1'] == 'FOO BAR 30'][0]
3644
    app = login(get_app(pub))
3645
    resp = app.get('/backoffice/management/form-title/')
3646
    assert re.findall('<tbody.*\/tbody>', resp.body, re.DOTALL)[0].count('<tr') == 17
3647

  
3648
    # click on a formdata
3649
    resp = resp.click(href='%s/' % number31.id)
3650
    assert (' with the number %s.' % number31.get_display_id()) in resp.body
3651
    resp.forms[0]['comment'] = 'HELLO WORLD'
3652
    resp = resp.forms[0].submit('button_accept')
3653
    resp = resp.follow()
3654
    assert FormDef.get_by_urlname('form-title').data_class().get(number31.id).status == 'wf-accepted'
3655
    assert 'HELLO WORLD' in resp.body
3656

  
3657
    assert 'id="evolution-log"' in resp.body
3658

  
3659
def test_backoffice_private_status_and_history_with_assigned_function(pub):
3660
    create_user(pub)
3661
    create_environment(pub, set_receiver=False)
3662

  
3663
    formdef = FormDef.get_by_urlname('form-title')
3664
    formdef.private_status_and_history = True
3665
    formdef.store()
3666

  
3667
    form_class = FormDef.get_by_urlname('form-title').data_class()
3668
    number31 = [x for x in form_class.select() if x.data['1'] == 'FOO BAR 30'][0]
3669

  
3670
    app = login(get_app(pub))
3671
    resp = app.get('/backoffice/management/form-title/', status=403)
3672

  
3673
    # fake function assignment
3674
    number31.workflow_roles = {'_receiver': '1'}
3675
    number31.store()
3676
    resp = app.get('/backoffice/management/form-title/', status=200)
3677
    assert re.findall('<tbody.*\/tbody>', resp.body, re.DOTALL)[0].count('<tr') == 1
3678

  
3679
    # click on a formdata
3680
    resp = resp.click(href='%s/' % number31.id)
3681
    assert (' with the number %s.' % number31.get_display_id()) in resp.body
3682

  
3683
    # history is visible
3684
    assert 'id="evolution-log"' in resp.body
3685
    resp.forms[0]['comment'] = 'HELLO WORLD'
3686
    resp = resp.forms[0].submit('button_accept')
3687
    resp = resp.follow()
3688
    assert FormDef.get_by_urlname('form-title').data_class().get(number31.id).status == 'wf-accepted'
3689

  
3690
    # history is still visible
3691
    assert 'HELLO WORLD' in resp.body
3692
    assert 'id="evolution-log"' in resp.body
wcs/formdef.py
1217 1217
        if not self.workflow_roles:
1218 1218
            self.workflow_roles = {}
1219 1219
        form_roles = [x for x in self.workflow_roles.values() if x]
1220
        if formdata and formdata.workflow_roles:
1221
            form_roles.extend([x for x in formdata.workflow_roles.values() if x])
1220 1222
        if user and self.private_status_and_history and not user_roles.intersection(form_roles):
1221 1223
            return False
1222 1224
        return self.is_user_allowed_read(user, formdata=formdata)
1223
-