Пример #1
0
    def test_layer_permissions(server_iface, dbsession, test_data):
        ogcserver_accesscontrol = OGCServerAccessControl(
            server_iface, 'qgisserver1', 21781, dbsession)

        for user_name, layer_name, expected in (
            ('user1', 'public_layer', {
                'canDelete': False,
                'canInsert': False,
                'canRead': True,
                'canUpdate': False
            }),
            ('user1', 'private_layer1', {
                'canDelete': False,
                'canInsert': False,
                'canRead': True,
                'canUpdate': False
            }),
            ('user12', 'private_layer2', {
                'canDelete': True,
                'canInsert': True,
                'canRead': True,
                'canUpdate': True
            }),
        ):
            user = test_data['users'][user_name]
            set_request_parameters(server_iface, {'USER_ID': str(user.id)})
            layer = QgsProject.instance().mapLayersByName(layer_name)[0]
            permissions = ogcserver_accesscontrol.layerPermissions(layer)
            for key, value in expected.items():
                assert value == getattr(permissions, key)
Пример #2
0
    def test_layer_permissions(self, server_iface, DBSession, test_data):  # noqa: ignore=N803
        dbsession = DBSession()
        ogcserver_accesscontrol = OGCServerAccessControl(
            server_iface, "unavailable", "no_project", 21781, lambda: dbsession
        )

        for user_name, layer_name, expected in (
            (
                "user1",
                "public_layer",
                {"canDelete": False, "canInsert": False, "canRead": False, "canUpdate": False},
            ),
            (
                "user12",
                "private_layer2",
                {"canDelete": False, "canInsert": False, "canRead": False, "canUpdate": False},
            ),
        ):
            user = test_data["users"][user_name]
            set_request_parameters(server_iface, {"USER_ID": str(user["id"])})
            layer = test_data["project"].mapLayersByName(layer_name)[0]

            permissions = ogcserver_accesscontrol.layerPermissions(layer)
            for key, value in expected.items():
                assert value == getattr(permissions, key)
Пример #3
0
    def test_layer_permissions(server_iface, dbsession, test_data):
        ogcserver_accesscontrol = OGCServerAccessControl(
            server_iface, "qgisserver1", 21781, dbsession)

        for user_name, layer_name, expected in (
            (
                "user1",
                "public_layer",
                {
                    "canDelete": False,
                    "canInsert": False,
                    "canRead": True,
                    "canUpdate": False
                },
            ),
            (
                "user1",
                "private_layer1",
                {
                    "canDelete": False,
                    "canInsert": False,
                    "canRead": True,
                    "canUpdate": False
                },
            ),
            (
                "user12",
                "private_layer2",
                {
                    "canDelete": True,
                    "canInsert": True,
                    "canRead": True,
                    "canUpdate": True
                },
            ),
        ):
            user = test_data["users"][user_name]
            set_request_parameters(server_iface, {"USER_ID": str(user.id)})
            layer = QgsProject.instance().mapLayersByName(layer_name)[0]
            permissions = ogcserver_accesscontrol.layerPermissions(layer)
            for key, value in expected.items():
                assert value == getattr(permissions, key)