Projet

Général

Profil

0001-tests_authentic-add-authenticators-manager-role-7086.patch

Valentin Deniaud, 31 octobre 2022 16:37

Télécharger (6,47 ko)

Voir les différences:

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(-)
tests_authentic/data_authentic_export_site.json
68 68
                    "ou": null,
69 69
                    "service": null,
70 70
                    "slug": "_a2-manager-of-users"
71
                },
72
                {
73
                    "name": "Manager of authenticators",
74
                    "ou": null,
75
                    "service": null,
76
                    "slug": "_a2-manager-of-authenticators"
71 77
                }
72 78
            ],
73 79
            "permissions": [
......
271 277
            "service": null,
272 278
            "slug": "_a2-manager-of-users"
273 279
        },
280
        {
281
            "description": "",
282
            "external_id": "",
283
            "name": "Manager of authenticators",
284
            "ou": null,
285
            "permissions": [
286
                {
287
                    "operation": {
288
                        "slug": "admin"
289
                    },
290
                    "ou": null,
291
                    "target": {
292
                        "app_label": "authenticators",
293
                        "model": "baseauthenticator"
294
                    },
295
                    "target_ct": {
296
                        "app_label": "contenttypes",
297
                        "model": "contenttype"
298
                    }
299
                },
300
                {
301
                    "operation": {
302
                        "slug": "search"
303
                    },
304
                    "ou": null,
305
                    "target": {
306
                        "app_label": "a2_rbac",
307
                        "model": "organizationalunit"
308
                    },
309
                    "target_ct": {
310
                        "app_label": "contenttypes",
311
                        "model": "contenttype"
312
                    }
313
                }
314
            ],
315
            "service": null,
316
            "slug": "_a2-manager-of-authenticators"
317
        },
274 318
        {
275 319
            "description": "",
276 320
            "external_id": "",
......
303 347
                    },
304 348
                    "service": null,
305 349
                    "slug": "_a2-manager-of-users-default"
350
                },
351
                {
352
                    "name": "Authenticators - Collectivité par défaut",
353
                    "ou": {
354
                        "name": "Collectivité par défaut",
355
                        "slug": "default"
356
                    },
357
                    "service": null,
358
                    "slug": "_a2-manager-of-authenticators-default"
306 359
                }
307 360
            ],
308 361
            "permissions": [
......
537 590
            ],
538 591
            "service": null,
539 592
            "slug": "_a2-manager-of-users-default"
540
        }
593
        },
594
    {
595
        "description": "",
596
        "external_id": "",
597
        "name": "Authenticators - Collectivité par défaut",
598
        "ou": {
599
            "name": "Collectivité par défaut", "slug": "default"
600
        },
601
        "permissions": [
602
            {
603
                "operation": {
604
                    "slug": "admin"
605
                },
606
                "ou": {
607
                    "name": "Collectivité par défaut",
608
                    "slug": "default"
609
                },
610
                "target": {
611
                    "app_label": "authenticators",
612
                    "model": "baseauthenticator"
613
                },
614
                "target_ct": {
615
                    "app_label": "contenttypes",
616
                    "model": "contenttype"
617
                }
618
            },
619
            {
620
                "operation": {
621
                    "slug": "search"
622
                },
623
                "ou": null,
624
                "target": {
625
                    "name": "Collectivité par défaut",
626
                    "slug": "default"
627
                },
628
                "target_ct": {
629
                    "app_label": "a2_rbac",
630
                    "model": "organizationalunit"
631
                }
632
            }
633
        ],
634
        "service": null,
635
        "slug": "_a2-manager-of-authenticators-default"
636
    }
541 637
    ]
542 638
}
tests_authentic/test_hobo_deploy.py
450 450
        for meta, service in zip(metadatas, other_services):
451 451
            provider = LibertyProvider.objects.get(slug=service['slug'])
452 452
            assert provider.metadata == meta
453
        # Two services loaded roles.json, so there must be 5 roles associated
454
        # to their "ou" excluding their superuser role, 3 admin roles for users,
455
        # roles and services, and 2 loaded roles, petite enfance and état-civil
456
        assert Role.objects.filter(ou__isnull=False, service__isnull=True).count() == 10
453
        # Two services loaded roles.json, so there must be 6 roles associated
454
        # to their "ou" excluding their superuser role, 4 admin roles for users,
455
        # roles, services and authenticators, and 2 loaded roles, petite enfance and état-civil
456
        assert Role.objects.filter(ou__isnull=False, service__isnull=True).count() == 12
457 457
        for service_id in {s['service-id'] for s in other_services}:
458 458
            same_services = [s for s in other_services if s['service-id'] == service_id]
459 459
            for i, service in enumerate(same_services):
......
502 502
                    == 1
503 503
                )
504 504
                if service.get('template_name'):
505
                    assert Role.objects.filter(ou=provider.ou, service__isnull=True).count() == 5
505
                    assert Role.objects.filter(ou=provider.ou, service__isnull=True).count() == 6
506 506
                    assert (
507 507
                        Role.objects.filter(
508 508
                            ou=provider.ou, service__isnull=True, name='Service petite enfance'
509
-