Exemple #1
0
    def test_it_assigns_admin_permissions_to_requests_with_staff_role(
            self, set_permissions, pyramid_request, permission):
        set_permissions("acct:adminuser@foo", principals=[role.Staff])

        context = Root(pyramid_request)

        assert pyramid_request.has_permission(permission, context)
Exemple #2
0
    def test_it_denies_all_permissions_for_unauthed_request(
            self, set_permissions, pyramid_request, permission):
        set_permissions(None, principals=None)

        context = Root(pyramid_request)

        assert not pyramid_request.has_permission(permission, context)
Exemple #3
0
    def test_it_assigns_all_permissions_to_requests_with_admin_role(
            self, set_permissions, pyramid_request):
        set_permissions("acct:adminuser@foo", principals=[role.Admin])

        context = Root(pyramid_request)

        assert pyramid_request.has_permission(pyramid.security.ALL_PERMISSIONS,
                                              context)
Exemple #4
0
    def test_it_denies_all_permissions_for_unauthed_request(
            self, pyramid_config, pyramid_request, permission):
        policy = pyramid.authorization.ACLAuthorizationPolicy()
        pyramid_config.testing_securitypolicy(None)
        pyramid_config.set_authorization_policy(policy)

        context = Root(pyramid_request)

        assert not pyramid_request.has_permission(permission, context)
Exemple #5
0
    def test_it_assigns_admin_permissions_to_requests_with_staff_role(
            self, pyramid_config, pyramid_request, permission):
        policy = pyramid.authorization.ACLAuthorizationPolicy()
        pyramid_config.testing_securitypolicy('acct:adminuser@foo',
                                              groupids=[role.Staff])
        pyramid_config.set_authorization_policy(policy)

        context = Root(pyramid_request)

        assert pyramid_request.has_permission(permission, context)
Exemple #6
0
    def test_it_assigns_all_permissions_to_requests_with_admin_role(
            self, pyramid_config, pyramid_request):
        policy = pyramid.authorization.ACLAuthorizationPolicy()
        pyramid_config.testing_securitypolicy('acct:adminuser@foo',
                                              groupids=[role.Admin])
        pyramid_config.set_authorization_policy(policy)

        context = Root(pyramid_request)

        assert pyramid_request.has_permission(pyramid.security.ALL_PERMISSIONS,
                                              context)