From 9075fbf73bf4fe31d94191fe2a652d8675eb6082 Mon Sep 17 00:00:00 2001 From: LeandroRoberto Date: Sun, 9 Oct 2016 01:49:03 -0300 Subject: [PATCH] =?UTF-8?q?Adiciona=20urls=20que=20seu=20m=C3=A9todo=20get?= =?UTF-8?q?=20=C3=A9=20exce=C3=A7=C3=A3o=20p=C3=BAblica?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapl/test_urls.py | 45 +++++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/sapl/test_urls.py b/sapl/test_urls.py index bdb45125b..fbb030a32 100644 --- a/sapl/test_urls.py +++ b/sapl/test_urls.py @@ -72,7 +72,7 @@ def create_perms_post_migrate(app): ] Permission.objects.bulk_create(perms) -btn_login = ('') @@ -256,13 +256,31 @@ def test_urlpatterns(url_item, admin_client): %s """ % (url, app_name, prefixs) -urls_publicas_sem_permission_required = [ - '/login', - '/logout', - '/comissao/1/materias-em-tramitacao', - '/materia/confirmar/1/1', +urls_publicas_excecoes = { + 'get': [ + '/materia/confirmar/1/1', + '/materia/pesquisar-materia', + '/mesa-diretora/', + '/norma/pesquisa', + '/sessao/1/expediente', + '/sessao/1/mesa', + '/sessao/1/presenca', + '/sessao/1/presencaordemdia', + '/sessao/1/resumo', + '/sessao/pauta-sessao', + '/sessao/pauta-sessao/1', + + + + '/materia/proposicao/1/ta', # FIXME Compilação deverá tratar + '/materia/1/ta', + '/norma/1/ta', + ], + 'post': [ + '/norma/pesquisa-resultado', -] + ] +} @pytest.mark.parametrize('url_item', _lista_urls) @@ -270,9 +288,6 @@ def test_permissions_urls_for_users_by_apps(url_item, client): key, url, var, app_name = url_item url = '/' + (url % {v: 1 for v in var}) - if url in urls_publicas_sem_permission_required: - return - if not get_user_model().objects.exists(): for app in sapl_appconfs: # readequa permissões dos models adicionando @@ -327,7 +342,7 @@ def test_permissions_urls_for_users_by_apps(url_item, client): o teste to py.test adicionar sua url representativa na variavel externa ao teste: - urls_publicas_sem_permission_required, logo acima do teste + urls_publicas_excecoes, logo acima do teste """ pass @@ -354,13 +369,15 @@ def test_permissions_urls_for_users_by_apps(url_item, client): rg = None try: - rg = client.get(url, {}, follow=True) + if url not in urls_publicas_excecoes['get']: + rg = client.get(url, {}, follow=True) except: pass rp = None try: - rp = client.post(url, {}, follow=True) + if url not in urls_publicas_excecoes['post']: + rp = client.post(url, {}, follow=True) except: pass @@ -403,7 +420,7 @@ def test_permissions_urls_for_users_by_apps(url_item, client): abaixo localizada no arquivo que se encontra este teste: - urls_publicas_sem_permission_required + urls_publicas_excecoes """ % (_type, url, app, username)