From 9813a3ee82c349f2a157c994df5427ce3d435e17 Mon Sep 17 00:00:00 2001 From: Valentin Deniaud Date: Mon, 31 Oct 2022 15:26:44 +0100 Subject: [PATCH] tests_authentic: add authenticators manager role (#70866) --- .../data_authentic_export_site.json | 98 ++++++++++++++++++- tests_authentic/test_hobo_deploy.py | 10 +- 2 files changed, 102 insertions(+), 6 deletions(-) diff --git a/tests_authentic/data_authentic_export_site.json b/tests_authentic/data_authentic_export_site.json index 8a064e5..495c784 100644 --- a/tests_authentic/data_authentic_export_site.json +++ b/tests_authentic/data_authentic_export_site.json @@ -68,6 +68,12 @@ "ou": null, "service": null, "slug": "_a2-manager-of-users" + }, + { + "name": "Manager of authenticators", + "ou": null, + "service": null, + "slug": "_a2-manager-of-authenticators" } ], "permissions": [ @@ -271,6 +277,44 @@ "service": null, "slug": "_a2-manager-of-users" }, + { + "description": "", + "external_id": "", + "name": "Manager of authenticators", + "ou": null, + "permissions": [ + { + "operation": { + "slug": "admin" + }, + "ou": null, + "target": { + "app_label": "authenticators", + "model": "baseauthenticator" + }, + "target_ct": { + "app_label": "contenttypes", + "model": "contenttype" + } + }, + { + "operation": { + "slug": "search" + }, + "ou": null, + "target": { + "app_label": "a2_rbac", + "model": "organizationalunit" + }, + "target_ct": { + "app_label": "contenttypes", + "model": "contenttype" + } + } + ], + "service": null, + "slug": "_a2-manager-of-authenticators" + }, { "description": "", "external_id": "", @@ -303,6 +347,15 @@ }, "service": null, "slug": "_a2-manager-of-users-default" + }, + { + "name": "Authenticators - Collectivité par défaut", + "ou": { + "name": "Collectivité par défaut", + "slug": "default" + }, + "service": null, + "slug": "_a2-manager-of-authenticators-default" } ], "permissions": [ @@ -537,6 +590,49 @@ ], "service": null, "slug": "_a2-manager-of-users-default" - } + }, + { + "description": "", + "external_id": "", + "name": "Authenticators - Collectivité par défaut", + "ou": { + "name": "Collectivité par défaut", "slug": "default" + }, + "permissions": [ + { + "operation": { + "slug": "admin" + }, + "ou": { + "name": "Collectivité par défaut", + "slug": "default" + }, + "target": { + "app_label": "authenticators", + "model": "baseauthenticator" + }, + "target_ct": { + "app_label": "contenttypes", + "model": "contenttype" + } + }, + { + "operation": { + "slug": "search" + }, + "ou": null, + "target": { + "name": "Collectivité par défaut", + "slug": "default" + }, + "target_ct": { + "app_label": "a2_rbac", + "model": "organizationalunit" + } + } + ], + "service": null, + "slug": "_a2-manager-of-authenticators-default" + } ] } diff --git a/tests_authentic/test_hobo_deploy.py b/tests_authentic/test_hobo_deploy.py index e842ff8..ea2c2e5 100644 --- a/tests_authentic/test_hobo_deploy.py +++ b/tests_authentic/test_hobo_deploy.py @@ -450,10 +450,10 @@ def test_hobo_deploy(monkeypatch, tenant_base, mocker, skeleton_dir, tmp_path): for meta, service in zip(metadatas, other_services): provider = LibertyProvider.objects.get(slug=service['slug']) assert provider.metadata == meta - # Two services loaded roles.json, so there must be 5 roles associated - # to their "ou" excluding their superuser role, 3 admin roles for users, - # roles and services, and 2 loaded roles, petite enfance and état-civil - assert Role.objects.filter(ou__isnull=False, service__isnull=True).count() == 10 + # Two services loaded roles.json, so there must be 6 roles associated + # to their "ou" excluding their superuser role, 4 admin roles for users, + # roles, services and authenticators, and 2 loaded roles, petite enfance and état-civil + assert Role.objects.filter(ou__isnull=False, service__isnull=True).count() == 12 for service_id in {s['service-id'] for s in other_services}: same_services = [s for s in other_services if s['service-id'] == service_id] for i, service in enumerate(same_services): @@ -502,7 +502,7 @@ def test_hobo_deploy(monkeypatch, tenant_base, mocker, skeleton_dir, tmp_path): == 1 ) if service.get('template_name'): - assert Role.objects.filter(ou=provider.ou, service__isnull=True).count() == 5 + assert Role.objects.filter(ou=provider.ou, service__isnull=True).count() == 6 assert ( Role.objects.filter( ou=provider.ou, service__isnull=True, name='Service petite enfance' -- 2.35.1