Exemplo n.º 1
0
    def setUp(self):
        import sqlahelper
        import transaction
        from c2cgeoportal.models import DBSession, Role, User, Functionality
        from c2cgeoportal.lib.dbreflection import init

        role1 = Role(name=u'__test_role1')
        user1 = User(
            username=u'__test_user1',
            password=u'__test_user1',
            role=role1
        )
        role2 = Role(name=u'__test_role2')
        user2 = User(
            username=u'__test_user2',
            password=u'__test_user2',
            role=role2
        )

        functionality1 = Functionality(u'__test_s', u'db')
        functionality2 = Functionality(u'__test_a', u'db1')
        functionality3 = Functionality(u'__test_a', u'db2')
        user2.functionalities = [functionality1, functionality2, functionality3]

        DBSession.add(user1)
        DBSession.add(user2)
        transaction.commit()

        engine = sqlahelper.get_engine()
        init(engine)
    def setUp(self):  # noqa
        import sqlahelper
        import transaction
        from c2cgeoportal.models import DBSession, Role, User, Functionality
        from c2cgeoportal.lib.dbreflection import init

        create_default_ogcserver()
        role1 = Role(name=u"__test_role1")
        user1 = User(username=u"__test_user1",
                     password=u"__test_user1",
                     role=role1)
        role2 = Role(name=u"__test_role2")
        user2 = User(username=u"__test_user2",
                     password=u"__test_user2",
                     role=role2)

        functionality1 = Functionality(u"__test_s", u"db")
        functionality2 = Functionality(u"__test_a", u"db1")
        functionality3 = Functionality(u"__test_a", u"db2")
        role2.functionalities = [
            functionality1, functionality2, functionality3
        ]

        DBSession.add_all([user1, user2, role1, role2])
        transaction.commit()

        engine = sqlahelper.get_engine()
        init(engine)
    def setup_method(self, _):
        from c2cgeoportal.models import User, Role, LayerWMS, RestrictionArea, \
            Interface, DBSession

        ogc_server_internal, _ = create_default_ogcserver()

        user1 = User(username="******", password="******")
        role1 = Role(name="__test_role1", description="__test_role1")
        user1.role_name = role1.name
        user1.email = "Tarenpion"

        main = Interface(name="main")

        layer1 = LayerWMS("testpoint_group_name", public=False)
        layer1.layer = "testpoint_group"
        layer1.ogc_server = ogc_server_internal
        layer1.interfaces = [main]

        layer2 = LayerWMS("testpoint_protected_2_name", public=False)
        layer2.layer = "testpoint_protected_2"
        layer2.ogc_server = ogc_server_internal
        layer2.interfaces = [main]

        area = "POLYGON((-100 30, -100 50, 100 50, 100 30, -100 30))"
        area = WKTElement(area, srid=21781)
        restricted_area1 = RestrictionArea("__test_ra1", "", [layer1, layer2],
                                           [role1], area)

        DBSession.add_all([user1, role1, layer1, layer2, restricted_area1])
        DBSession.flush()

        transaction.commit()
    def setUp(self):  # noqa
        from c2cgeoportal.models import User, Role, LayerV1, RestrictionArea, \
            Interface, DBSession

        create_default_ogcserver()

        user1 = User(username=u"__test_user1", password=u"__test_user1")
        role1 = Role(name=u"__test_role1", description=u"__test_role1")
        user1.role_name = role1.name
        user1.email = u"Tarenpion"

        main = Interface(name=u"main")

        layer1 = LayerV1(u"testpoint_group", public=False)
        layer1.interfaces = [main]

        layer2 = LayerV1(u"testpoint_protected_2", public=False)
        layer2.interfaces = [main]

        area = "POLYGON((-100 30, -100 50, 100 50, 100 30, -100 30))"
        area = WKTElement(area, srid=21781)
        restricted_area1 = RestrictionArea(u"__test_ra1", u"", [layer1, layer2], [role1], area)

        DBSession.add_all([user1, role1, layer1, layer2, restricted_area1])
        DBSession.flush()

        transaction.commit()
    def setUp():  # noqa
        import transaction
        from sqlalchemy import func
        from geoalchemy2 import WKTElement
        from c2cgeoportal.models import FullTextSearch, User, Role, Interface
        from c2cgeoportal.models import DBSession

        user1 = User(username=u"__test_user1", password=u"__test_user1")
        role1 = Role(name=u"__test_role1", description=u"__test_role1")
        user1.role_name = role1.name

        user2 = User(username=u"__test_user2", password=u"__test_user2")
        role2 = Role(name=u"__test_role2", description=u"__test_role2")
        user2.role_name = role2.name

        entry1 = FullTextSearch()
        entry1.label = "label1"
        entry1.layer_name = "layer1"
        entry1.ts = func.to_tsvector("french", "soleil travail")
        entry1.the_geom = WKTElement("POINT(-90 -45)", 21781)
        entry1.public = True

        entry2 = FullTextSearch()
        entry2.label = "label2"
        entry2.layer_name = "layer2"
        entry2.ts = func.to_tsvector("french", "pluie semaine")
        entry2.the_geom = WKTElement("POINT(-90 -45)", 21781)
        entry2.public = False

        entry3 = FullTextSearch()
        entry3.label = "label3"
        entry3.layer_name = "layer3"
        entry3.ts = func.to_tsvector("french", "vent neige")
        entry3.the_geom = WKTElement("POINT(-90 -45)", 21781)
        entry3.public = False
        entry3.role = role2

        entry4 = FullTextSearch()
        entry4.label = "label4"
        entry4.layer_name = "layer1"
        entry4.ts = func.to_tsvector("french", "soleil travail")
        entry4.the_geom = WKTElement("POINT(-90 -45)", 21781)
        entry4.public = True

        entry5 = FullTextSearch()
        entry5.label = "label5"
        entry5.ts = func.to_tsvector("french", "params")
        entry5.public = True
        entry5.params = {"floor": 5}
        entry5.actions = [{"action": "add_layer", "data": "layer1"}]

        entry6 = FullTextSearch()
        entry6.label = "label6"
        entry6.ts = func.to_tsvector("french", "params")
        entry6.interface = Interface("main")
        entry6.public = True

        DBSession.add_all([user1, user2, role1, role2, entry1, entry2, entry3, entry4, entry5, entry6])
        transaction.commit()
Exemplo n.º 6
0
    def setUp(self):
        from c2cgeoportal.models import DBSession, User, Role, Layer, \
            RestrictionArea, Theme, LayerGroup

        role1 = Role(name=u'__test_role1')
        user1 = User(username=u'__test_user1',
                     password=u'__test_user1',
                     role=role1)

        role2 = Role(name=u'__test_role2',
                     extent=WKTSpatialElement(
                         "POLYGON((1 2, 1 4, 3 4, 3 2, 1 2))", srid=21781))
        user2 = User(username=u'__test_user2',
                     password=u'__test_user2',
                     role=role2)

        public_layer = Layer(name=u'__test_public_layer',
                             order=40,
                             public=True)
        public_layer.isChecked = False

        private_layer = Layer(name=u'__test_private_layer',
                              order=40,
                              public=False)
        private_layer.geoTable = 'a_schema.a_geo_table'

        layer_in_group = Layer(name=u'__test_layer_in_group')
        layer_group = LayerGroup(name=u'__test_layer_group')
        layer_group.children = [layer_in_group]

        layer_wmsgroup = Layer(name=u'test_wmsfeaturesgroup')
        layer_wmsgroup.isChecked = False

        theme = Theme(name=u'__test_theme')
        theme.children = [
            public_layer, private_layer, layer_group, layer_wmsgroup
        ]

        poly = "POLYGON((-100 0, -100 20, 100 20, 100 0, -100 0))"

        area = WKTSpatialElement(poly, srid=21781)
        RestrictionArea(name=u'__test_ra1',
                        description=u'',
                        layers=[private_layer],
                        roles=[role1],
                        area=area)

        area = WKTSpatialElement(poly, srid=21781)
        RestrictionArea(name=u'__test_ra2',
                        description=u'',
                        layers=[private_layer],
                        roles=[role2],
                        area=area,
                        readwrite=True)

        DBSession.add_all([user1, user2, public_layer, private_layer])

        transaction.commit()
Exemplo n.º 7
0
    def setUp(self):
        import transaction
        from sqlalchemy import func
        from geoalchemy import WKTSpatialElement
        from c2cgeoportal.models import FullTextSearch, User, Role
        from c2cgeoportal.models import DBSession

        user1 = User(username=u'__test_user1', password=u'__test_user1')
        role1 = Role(name=u'__test_role1', description=u'__test_role1')
        user1.role = role1

        user2 = User(username=u'__test_user2', password=u'__test_user2')
        role2 = Role(name=u'__test_role2', description=u'__test_role2')
        user2.role = role2

        entry1 = FullTextSearch()
        entry1.label = 'label1'
        entry1.layer_name = 'layer1'
        entry1.ts = func.to_tsvector('french', 'soleil travail')
        entry1.the_geom = WKTSpatialElement("POINT(-90 -45)")
        entry1.public = True

        entry2 = FullTextSearch()
        entry2.label = 'label2'
        entry2.layer_name = 'layer2'
        entry2.ts = func.to_tsvector('french', 'pluie semaine')
        entry2.the_geom = WKTSpatialElement("POINT(-90 -45)")
        entry2.public = False

        entry3 = FullTextSearch()
        entry3.label = 'label3'
        entry3.layer_name = 'layer3'
        entry3.ts = func.to_tsvector('french', 'vent neige')
        entry3.the_geom = WKTSpatialElement("POINT(-90 -45)")
        entry3.public = False
        entry3.role = role2

        entry4 = FullTextSearch()
        entry4.label = 'label4'
        entry4.layer_name = 'layer1'
        entry4.ts = func.to_tsvector('french', 'soleil travail')
        entry4.the_geom = WKTSpatialElement("POINT(-90 -45)")
        entry4.public = True

        entry5 = FullTextSearch()
        entry5.label = 'label5'
        entry5.layer_name = 'layer1'
        entry5.ts = func.to_tsvector('french', 'params')
        entry5.the_geom = WKTSpatialElement("POINT(-90 -45)")
        entry5.public = True
        entry5.params = {'floor': 5}

        DBSession.add_all([user1, user2, entry1, entry2, entry3, entry4, entry5])
        transaction.commit()
Exemplo n.º 8
0
        def setter(request):
            class User(object):
                pass

            class Role(object):
                pass

            u = User()
            u.username = u'__foo'
            u.role = Role()
            u.role.name = u'__bar'
            return u
Exemplo n.º 9
0
        def setter(request):
            class User(object):
                pass

            class Role(object):
                pass

            u = User()
            u.username = u"__foo"
            u.role = Role()
            u.role.name = u"__bar"
            return u
Exemplo n.º 10
0
        def setter(request):
            class User:
                pass

            class Role:
                pass

            u = User()
            u.username = "******"
            u.role = Role()
            u.role.name = "__bar"
            return u
Exemplo n.º 11
0
    def setUp(self):
        from c2cgeoportal.models import User, Role, Layer, RestrictionArea, \
            Functionality, DBSession

        TestPoint.__table__.create(bind=DBSession.bind, checkfirst=True)

        geom = WKTSpatialElement("MULTIPOINT((-90 -45))", srid=21781)
        p1 = TestPoint(the_geom=geom, name=u'foo', city=u'Lausanne', country=u'Swiss')
        geom = WKTSpatialElement("MULTIPOINT((-90 45))", srid=21781)
        p2 = TestPoint(the_geom=geom, name=u'bar', city=u'Chambéry', country=u'France')
        geom = WKTSpatialElement("MULTIPOINT((90 45))", srid=21781)
        p3 = TestPoint(the_geom=geom, name=u'éàè', city="Paris", country=u'France')
        geom = WKTSpatialElement("MULTIPOINT((90 -45))", srid=21781)
        p4 = TestPoint(the_geom=geom, name=u'123', city='Londre', country=u'UK')

        pt1 = Functionality(name=u'print_template', value=u'1 Wohlen A4 portrait')
        pt2 = Functionality(name=u'print_template', value=u'2 Wohlen A3 landscape')
        user1 = User(username=u'__test_user1', password=u'__test_user1')
        role1 = Role(name=u'__test_role1', description=u'__test_role1', functionalities=[pt1, pt2])
        user1.role = role1
        user1.email = u'Tarenpion'

        user2 = User(username=u'__test_user2', password=u'__test_user2')
        role2 = Role(name=u'__test_role2', description=u'__test_role2', functionalities=[pt1, pt2])
        user2.role = role2
        user2.email = u'Tarenpion'

        user3 = User(username=u'__test_user3', password=u'__test_user3')
        role3 = Role(name=u'__test_role3', description=u'__test_role3', functionalities=[pt1, pt2])
        user3.role = role3
        user3.email = u'Tarenpion'

        layer2 = Layer(u'testpoint_protected', 400, public=False)
        layer3 = Layer(u'testpoint_protected_query_with_collect', public=False)

        area = "POLYGON((-100 30, -100 50, 100 50, 100 30, -100 30))"
        area = WKTSpatialElement(area, srid=21781)
        restricted_area1 = RestrictionArea(u'__test_ra1', u'', [layer2, layer3], [role1], area)

        area = "POLYGON((-100 0, -100 20, 100 20, 100 0, -100 0))"
        area = WKTSpatialElement(area, srid=21781)
        restricted_area2 = RestrictionArea(u'__test_ra2', u'', [layer2, layer3], [role2, role3], area)

        area = "POLYGON((-95 43, -95 47, 95 47, 95 43, -95 43))"
        area = WKTSpatialElement(area, srid=21781)
        restricted_area3 = RestrictionArea(u'__test_ra3', u'', [layer3], [role3], area, readwrite=True)

        DBSession.add_all([
            p1, p2, p3, p4, user1, user2, user3,
            restricted_area1, restricted_area2, restricted_area3
        ])
        DBSession.flush()

        self.id_lausanne = p1.id
        self.id_paris = p3.id

        transaction.commit()
Exemplo n.º 12
0
    def setUp(self):  # noqa
        # Always see the diff
        # https://docs.python.org/2/library/unittest.html#unittest.TestCase.maxDiff
        self.maxDiff = None

        functionality.FUNCTIONALITIES_TYPES = None

        from c2cgeoportal.models import DBSession, User, Role, \
            RestrictionArea, Theme, LayerGroup, Interface, LayerWMS

        ogcserver, ogcserver_external = create_default_ogcserver()

        role1 = Role(name=u"__test_role1")
        role1.id = 999
        user1 = User(username=u"__test_user1", password=u"__test_user1", role=role1)
        user1.email = "*****@*****.**"

        role2 = Role(name=u"__test_role2", extent=WKTElement(
            "POLYGON((1 2, 1 4, 3 4, 3 2, 1 2))", srid=21781
        ))
        user2 = User(username=u"__test_user2", password=u"__test_user2", role=role2)

        main = Interface(name=u"main")

        private_layer = LayerWMS(name=u"__test_private_layer", public=False)
        private_layer.layer = "__test_private_layer"
        private_layer.geo_table = "a_schema.a_geo_table"
        private_layer.interfaces = [main]
        private_layer.ogc_server = ogcserver

        group = LayerGroup(name=u"__test_layer_group")
        group.children = [private_layer]

        theme = Theme(name=u"__test_theme")
        theme.children = [group]
        theme.interfaces = [main]

        DBSession.add(RestrictionArea(
            name=u"__test_ra1", description=u"", layers=[private_layer],
            roles=[role1],
        ))
        DBSession.add(RestrictionArea(
            name=u"__test_ra2", description=u"", layers=[private_layer],
            roles=[role2], readwrite=True,
        ))

        DBSession.add_all([
            user1, user2, role1, role2, theme, group, private_layer,
        ])

        transaction.commit()
Exemplo n.º 13
0
    def setUp(self):  # noqa
        import sqlahelper
        import transaction
        from c2cgeoportal.models import DBSession, Role, User, Interface, TreeItem
        from c2cgeoportal.lib.dbreflection import init

        for treeitem in DBSession.query(TreeItem).all():
            DBSession.delete(treeitem)

        self.metadata = None
        self.layer_ids = []

        self.role = Role(name=u"__test_role")
        self.user = User(username=u"__test_user",
                         password=u"__test_user",
                         role=self.role)
        self.main = Interface(name=u"main")

        DBSession.add(self.user)
        DBSession.add(self.role)
        DBSession.add(self.main)
        transaction.commit()

        engine = sqlahelper.get_engine()
        init(engine)
Exemplo n.º 14
0
    def setup_method(self, _):
        import transaction
        from c2cgeoportal.models import DBSession, User, Role

        r = Role(name="__test_role")
        u = User(username="******", password="******", role=r)

        DBSession.add_all([r, u])
        transaction.commit()
Exemplo n.º 15
0
    def setUp(self):
        self.config = testing.setUp()

        import transaction
        from c2cgeoportal.models import DBSession, User, Role

        r = Role(name=u'__test_role')
        u = User(username=u'__test_user', password=u'__test_user', role=r)

        DBSession.add(u)
        transaction.commit()
Exemplo n.º 16
0
    def setUp(self):  # noqa
        self.config = testing.setUp()

        import transaction
        from c2cgeoportal.models import DBSession, User, Role

        r = Role(name=u"__test_role")
        u = User(username=u"__test_user", password=u"__test_user", role=r)

        DBSession.add_all([u, r])
        transaction.commit()
Exemplo n.º 17
0
    def setUp(self):  # noqa
        from c2cgeoportal.models import User, Role, LayerV1, RestrictionArea, Interface, DBSession

        user1 = User(username=u"__test_user1", password=u"__test_user1")
        role1 = Role(name=u"__test_role1", description=u"__test_role1")
        user1.role_name = role1.name
        user1.email = u"Tarenpion"

        user2 = User(username=u"__test_user2", password=u"__test_user2")
        role2 = Role(name=u"__test_role2", description=u"__test_role2")
        user2.role_name = role2.name
        user2.email = u"Tarenpion"

        main = Interface(name=u"main")

        layer1 = LayerV1(u"layer_1", public=False)
        layer1.interfaces = [main]
        layer2 = LayerV1(u"layer_2", public=False)
        layer2.interfaces = [main]
        layer3 = LayerV1(u"layer_3", public=False)
        layer3.interfaces = [main]

        area = "POLYGON((-100 30, -100 50, 100 50, 100 30, -100 30))"
        area = WKTElement(area, srid=21781)
        restricted_area1 = RestrictionArea(u"__test_ra1", u"", [layer1, layer2], [role1], area, readwrite=True)

        area = "POLYGON((-100 0, -100 20, 100 20, 100 0, -100 0))"
        area = WKTElement(area, srid=21781)
        restricted_area2 = RestrictionArea(u"__test_ra2", u"", [layer1, layer2, layer3], [role2], area)

        DBSession.add_all([user1, user2, role1, role2, restricted_area1, restricted_area2])
        DBSession.flush()

        transaction.commit()
Exemplo n.º 18
0
    def test_loginchange(self):
        from c2cgeoportal.views.entry import Entry
        from c2cgeoportal.models import User
        from pyramid.httpexceptions import HTTPBadRequest, HTTPUnauthorized
        try:
            from hashlib import sha1
            sha1  # suppress pyflakes warning
        except ImportError:  # pragma: nocover
            from sha import new as sha1  # flake8: noqa

        request = self._create_request_obj()
        entry = Entry(request)
        self.assertRaises(HTTPBadRequest, entry.loginchange)

        request = self._create_request_obj(params={
            'lang': 'en',
            'newPassword': '******',
            'confirmNewPassword': '******',
        })
        entry = Entry(request)
        self.assertRaises(HTTPUnauthorized, entry.loginchange)

        request.user = User()
        self.assertEquals(request.user.is_password_changed, False)
        self.assertEquals(request.user._password,
                          unicode(sha1('').hexdigest()))
        self.assertRaises(HTTPBadRequest, entry.loginchange)

        request = self._create_request_obj(params={
            'lang': 'en',
            'newPassword': '******',
            'confirmNewPassword': '******'
        })
        request.user = User()
        entry = Entry(request)
        self.assertNotEqual(entry.loginchange(), None)
        self.assertEqual(request.user.is_password_changed, True)
        self.assertEqual(request.user._password,
                         unicode(sha1('1234').hexdigest()))
Exemplo n.º 19
0
    def setUp(self):  # noqa
        import transaction
        from sqlalchemy import func
        from geoalchemy2 import WKTElement
        from c2cgeoportal.models import FullTextSearch, User, Role, Interface
        from c2cgeoportal.models import DBSession

        user1 = User(username=u"__test_user1", password=u"__test_user1")
        role1 = Role(name=u"__test_role1", description=u"__test_role1")
        user1.role_name = role1.name

        user2 = User(username=u"__test_user2", password=u"__test_user2")
        role2 = Role(name=u"__test_role2", description=u"__test_role2")
        user2.role_name = role2.name

        entry1 = FullTextSearch()
        entry1.label = "label1"
        entry1.layer_name = "layer1"
        entry1.ts = func.to_tsvector("french", "soleil travail")
        entry1.the_geom = WKTElement("POINT(-90 -45)", 21781)
        entry1.public = True

        entry2 = FullTextSearch()
        entry2.label = "label2"
        entry2.layer_name = "layer2"
        entry2.ts = func.to_tsvector("french", "pluie semaine")
        entry2.the_geom = WKTElement("POINT(-90 -45)", 21781)
        entry2.public = False

        entry3 = FullTextSearch()
        entry3.label = "label3"
        entry3.layer_name = "layer3"
        entry3.ts = func.to_tsvector("french", "vent neige")
        entry3.the_geom = WKTElement("POINT(-90 -45)", 21781)
        entry3.public = False
        entry3.role = role2

        entry4 = FullTextSearch()
        entry4.label = "label4"
        entry4.layer_name = "layer1"
        entry4.ts = func.to_tsvector("french", "soleil travail")
        entry4.the_geom = WKTElement("POINT(-90 -45)", 21781)
        entry4.public = True

        entry5 = FullTextSearch()
        entry5.label = "label5"
        entry5.ts = func.to_tsvector("french", "params")
        entry5.public = True
        entry5.params = {"floor": 5}
        entry5.actions = [{"action": "add_layer", "data": "layer1"}]

        entry6 = FullTextSearch()
        entry6.label = "label6"
        entry6.ts = func.to_tsvector("french", "params")
        entry6.interface = Interface("main")
        entry6.public = True

        DBSession.add_all([user1, user2, role1, role2, entry1, entry2, entry3, entry4, entry5, entry6])
        transaction.commit()
Exemplo n.º 20
0
    def setup_method(self, _):
        import transaction
        from c2cgeoportal.models import DBSession, Role, User, Functionality

        create_default_ogcserver()
        role1 = Role(name="__test_role1")
        user1 = User(username="******",
                     password="******",
                     role=role1)
        role2 = Role(name="__test_role2")
        user2 = User(username="******",
                     password="******",
                     role=role2)

        functionality1 = Functionality("__test_s", "db")
        functionality2 = Functionality("__test_a", "db1")
        functionality3 = Functionality("__test_a", "db2")
        role2.functionalities = [
            functionality1, functionality2, functionality3
        ]

        DBSession.add_all([user1, user2, role1, role2])
        transaction.commit()
Exemplo n.º 21
0
    def setUp(self):
        import transaction
        from sqlalchemy import func
        from geoalchemy import WKTSpatialElement
        from c2cgeoportal.models import FullTextSearch, User, Role
        from c2cgeoportal.models import DBSession

        user1 = User(username=u'__test_user1', password=u'__test_user1')
        role1 = Role(name=u'__test_role1', description=u'__test_role1')
        user1.role = role1

        user2 = User(username=u'__test_user2', password=u'__test_user2')
        role2 = Role(name=u'__test_role2', description=u'__test_role2')
        user2.role = role2

        entry1 = FullTextSearch()
        entry1.label = 'label1'
        entry1.layer_name = 'layer1'
        entry1.ts = func.to_tsvector('french', 'soleil travail')
        entry1.the_geom = WKTSpatialElement("POINT(-90 -45)")
        entry1.public = True

        entry2 = FullTextSearch()
        entry2.label = 'label2'
        entry2.layer_name = 'layer2'
        entry2.ts = func.to_tsvector('french', 'pluie semaine')
        entry2.the_geom = WKTSpatialElement("POINT(-90 -45)")
        entry2.public = False

        entry3 = FullTextSearch()
        entry3.label = 'label3'
        entry3.layer_name = 'layer3'
        entry3.ts = func.to_tsvector('french', 'vent neige')
        entry3.the_geom = WKTSpatialElement("POINT(-90 -45)")
        entry3.public = False
        entry3.role = role2

        entry4 = FullTextSearch()
        entry4.label = 'label4'
        entry4.layer_name = 'layer1'
        entry4.ts = func.to_tsvector('french', 'soleil travail')
        entry4.the_geom = WKTSpatialElement("POINT(-90 -45)")
        entry4.public = True

        entry5 = FullTextSearch()
        entry5.label = 'label5'
        entry5.layer_name = 'layer1'
        entry5.ts = func.to_tsvector('french', 'params')
        entry5.the_geom = WKTSpatialElement("POINT(-90 -45)")
        entry5.public = True
        entry5.params = {'floor': 5}

        DBSession.add_all(
            [user1, user2, entry1, entry2, entry3, entry4, entry5])
        transaction.commit()
Exemplo n.º 22
0
    def setup_method(self, _):
        self.maxDiff = None

        from c2cgeoportal.models import User, DBSession

        user = User(username="******", password="******")
        DBSession.add(user)
        DBSession.flush()

        self.old_remember = pyramid.security.remember
        self.user = None

        def remember(request, user=None):
            self.user = user

        pyramid.security.remember = remember
Exemplo n.º 23
0
    def setUp(self):  # noqa
        from c2cgeoportal.models import User, Role, LayerV1, RestrictionArea, \
            Interface, DBSession

        user1 = User(username=u"__test_user1", password=u"__test_user1")
        role1 = Role(name=u"__test_role1", description=u"__test_role1")
        user1.role_name = role1.name
        user1.email = u"Tarenpion"

        user2 = User(username=u"__test_user2", password=u"__test_user2")
        role2 = Role(name=u"__test_role2", description=u"__test_role2")
        user2.role_name = role2.name
        user2.email = u"Tarenpion"

        main = Interface(name=u"main")

        layer1 = LayerV1(u"layer_1", public=False)
        layer1.interfaces = [main]
        layer2 = LayerV1(u"layer_2", public=False)
        layer2.interfaces = [main]
        layer3 = LayerV1(u"layer_3", public=False)
        layer3.interfaces = [main]

        area = "POLYGON((-100 30, -100 50, 100 50, 100 30, -100 30))"
        area = WKTElement(area, srid=21781)
        restricted_area1 = RestrictionArea(u"__test_ra1",
                                           u"", [layer1, layer2], [role1],
                                           area,
                                           readwrite=True)

        area = "POLYGON((-100 0, -100 20, 100 20, 100 0, -100 0))"
        area = WKTElement(area, srid=21781)
        restricted_area2 = RestrictionArea(u"__test_ra2", u"",
                                           [layer1, layer2, layer3], [role2],
                                           area)

        DBSession.add_all(
            [user1, user2, role1, role2, restricted_area1, restricted_area2])
        DBSession.flush()

        transaction.commit()
Exemplo n.º 24
0
    def setUp(self):
        import sqlahelper
        import transaction
        from c2cgeoportal.models import DBSession, Role, User
        from c2cgeoportal.lib.dbreflection import init

        self.metadata = None
        self.layer_ids = []

        self.role = Role(name=u'__test_role')
        self.user = User(username=u'__test_user',
                         password=u'__test_user',
                         role=self.role)

        DBSession.add(self.user)
        transaction.commit()

        engine = sqlahelper.get_engine()
        init(engine)
Exemplo n.º 25
0
    def setup_method(self, _):
        # Always see the diff
        # https://docs.python.org/2/library/unittest.html#unittest.TestCase.maxDiff
        self.maxDiff = None

        cleanup_db()

        self._tables = []

        import transaction
        from c2cgeoportal.models import DBSession, Role, User, Interface, TreeItem, Theme, \
            LayerGroup, OGCSERVER_AUTH_NOAUTH

        for treeitem in DBSession.query(TreeItem).all():
            DBSession.delete(treeitem)

        self.role = Role(name="__test_role")
        self.user = User(
            username="******",
            password="******",
            role=self.role
        )
        self.main = Interface(name="main")

        self.ogc_server, external_ogc_server = create_default_ogcserver()
        self.ogc_server.auth = OGCSERVER_AUTH_NOAUTH
        external_ogc_server.auth = OGCSERVER_AUTH_NOAUTH

        self.metadata = None
        self.layer_ids = []

        self.layer_group_1 = LayerGroup(name="__test_layer_group_1")

        theme = Theme(name="__test_theme")
        theme.interfaces = [self.main]
        theme.children = [self.layer_group_1]

        DBSession.add_all([self.main, self.user, self.role, theme, self.layer_group_1])

        transaction.commit()
Exemplo n.º 26
0
    def setup_method(self, _):
        import transaction
        from c2cgeoportal.models import DBSession, Role, User, Interface

        cleanup_db()

        self.metadata = None
        self.layer_ids = []

        DBSession.query(User).delete()
        DBSession.query(User).filter(User.username == "__test_user").delete()

        self.role = Role(name="__test_role")
        self.user = User(username="******",
                         password="******",
                         role=self.role)
        self.main = Interface(name="main")

        DBSession.add(self.user)
        DBSession.add(self.role)
        DBSession.add(self.main)
        transaction.commit()
Exemplo n.º 27
0
    def setup_method(self, _):
        # Always see the diff
        # https://docs.python.org/2/library/unittest.html#unittest.TestCase.maxDiff
        self.maxDiff = None
        self._tables = []

        functionality.FUNCTIONALITIES_TYPES = None

        from c2cgeoportal.models import DBSession, User, Role, \
            RestrictionArea, TreeItem, Theme, LayerGroup, Interface, LayerWMS

        from sqlalchemy import Column, Table, types
        from sqlalchemy.ext.declarative import declarative_base
        from geoalchemy2 import Geometry

        for o in DBSession.query(RestrictionArea).all():
            DBSession.delete(o)
        for o in DBSession.query(Role).all():
            DBSession.delete(o)
        for o in DBSession.query(User).all():
            DBSession.delete(o)
        for o in DBSession.query(TreeItem).all():
            DBSession.delete(o)
        ogcserver, ogcserver_external = create_default_ogcserver()

        role1 = Role(name="__test_role1")
        role1.id = 999
        user1 = User(username="******", password="******", role=role1)
        user1.email = "*****@*****.**"

        role2 = Role(name="__test_role2", extent=WKTElement(
            "POLYGON((1 2, 1 4, 3 4, 3 2, 1 2))", srid=21781
        ))
        user2 = User(username="******", password="******", role=role2)

        main = Interface(name="main")

        engine = DBSession.c2c_rw_bind
        engine.connect()
        a_geo_table = Table(
            "a_geo_table", declarative_base(bind=engine).metadata,
            Column("id", types.Integer, primary_key=True),
            Column("geom", Geometry("POINT", srid=21781)),
            schema="geodata"
        )

        self._tables = [a_geo_table]
        a_geo_table.drop(checkfirst=True)
        a_geo_table.create()

        private_layer = LayerWMS(name="__test_private_layer", public=False)
        private_layer.layer = "__test_private_layer"
        private_layer.geo_table = "geodata.a_geo_table"
        private_layer.interfaces = [main]
        private_layer.ogc_server = ogcserver

        group = LayerGroup(name="__test_layer_group")
        group.children = [private_layer]

        theme = Theme(name="__test_theme")
        theme.children = [group]
        theme.interfaces = [main]

        DBSession.add(RestrictionArea(
            name="__test_ra1", description="", layers=[private_layer],
            roles=[role1],
        ))
        DBSession.add(RestrictionArea(
            name="__test_ra2", description="", layers=[private_layer],
            roles=[role2], readwrite=True,
        ))

        DBSession.add_all([
            user1, user2, role1, role2, theme, group, private_layer,
        ])

        transaction.commit()
Exemplo n.º 28
0
    def setUp(self):  # noqa
        self.maxDiff = None

        from c2cgeoportal.models import User, Role, LayerV1, RestrictionArea, \
            Functionality, Interface, DBSession, management, OGCServer, \
            OGCSERVER_TYPE_GEOSERVER, OGCSERVER_AUTH_GEOSERVER

        if management:
            TestPoint.__table__.c.the_geom.type.management = True

        create_default_ogcserver()
        ogcserver_geoserver = OGCServer(name="__test_ogc_server_geoserver")
        ogcserver_geoserver.url = mapserv_url
        ogcserver_geoserver.type = OGCSERVER_TYPE_GEOSERVER
        ogcserver_geoserver.auth = OGCSERVER_AUTH_GEOSERVER

        TestPoint.__table__.create(bind=DBSession.bind, checkfirst=True)

        geom = WKTElement("MULTIPOINT((-90 -45))", srid=21781)
        p1 = TestPoint(the_geom=geom, name=u"foo", city=u"Lausanne", country=u"Swiss")
        geom = WKTElement("MULTIPOINT((-90 45))", srid=21781)
        p2 = TestPoint(the_geom=geom, name=u"bar", city=u"Chambéry", country=u"France")
        geom = WKTElement("MULTIPOINT((90 45))", srid=21781)
        p3 = TestPoint(the_geom=geom, name=u"éàè", city="Paris", country=u"France")
        geom = WKTElement("MULTIPOINT((90 -45))", srid=21781)
        p4 = TestPoint(the_geom=geom, name=u"123", city="Londre", country=u"UK")

        pt1 = Functionality(name=u"print_template", value=u"1 Wohlen A4 portrait")
        pt2 = Functionality(name=u"print_template", value=u"2 Wohlen A3 landscape")
        user1 = User(username=u"__test_user1", password=u"__test_user1")
        role1 = Role(name=u"__test_role1", description=u"__test_role1", functionalities=[pt1, pt2])
        user1.role_name = role1.name
        user1.email = u"Tarenpion"

        user2 = User(username=u"__test_user2", password=u"__test_user2")
        role2 = Role(name=u"__test_role2", description=u"__test_role2", functionalities=[pt1, pt2])
        user2.role_name = role2.name
        user2.email = u"Tarenpion"

        user3 = User(username=u"__test_user3", password=u"__test_user3")
        role3 = Role(name=u"__test_role3", description=u"__test_role3", functionalities=[pt1, pt2])
        user3.role_name = role3.name
        user3.email = u"Tarenpion"

        main = Interface(name=u"main")

        layer2 = LayerV1(u"testpoint_protected", public=False)
        layer2.interfaces = [main]
        layer3 = LayerV1(u"testpoint_protected_query_with_collect", public=False)
        layer3.interfaces = [main]

        area = "POLYGON((-100 30, -100 50, 100 50, 100 30, -100 30))"
        area = WKTElement(area, srid=21781)
        restricted_area1 = RestrictionArea(u"__test_ra1", u"", [layer2, layer3], [role1], area)

        area = "POLYGON((-100 0, -100 20, 100 20, 100 0, -100 0))"
        area = WKTElement(area, srid=21781)
        restricted_area2 = RestrictionArea(u"__test_ra2", u"", [layer2, layer3], [role2, role3], area)

        area = "POLYGON((-95 43, -95 47, 95 47, 95 43, -95 43))"
        area = WKTElement(area, srid=21781)
        restricted_area3 = RestrictionArea(u"__test_ra3", u"", [layer3], [role3], area, readwrite=True)

        DBSession.add_all([
            p1, p2, p3, p4, user1, user2, user3, role1, role2, role3,
            restricted_area1, restricted_area2, restricted_area3, ogcserver_geoserver
        ])
        DBSession.flush()

        self.id_lausanne = p1.id
        self.id_paris = p3.id

        transaction.commit()
Exemplo n.º 29
0
    def setUp(self):
        from c2cgeoportal.models import User, Role, Layer, RestrictionArea, \
                Functionality, DBSession

        TestPoint.__table__.create(bind=DBSession.bind, checkfirst=True)

        geom = WKTSpatialElement("MULTIPOINT((-90 -45))", srid=21781)
        p1 = TestPoint(the_geom=geom,
                       name=u'foo',
                       city=u'Lausanne',
                       country=u'Swiss')
        geom = WKTSpatialElement("MULTIPOINT((-90 45))", srid=21781)
        p2 = TestPoint(the_geom=geom,
                       name=u'bar',
                       city=u'Chambéry',
                       country=u'France')
        geom = WKTSpatialElement("MULTIPOINT((90 45))", srid=21781)
        p3 = TestPoint(the_geom=geom,
                       name=u'éàè',
                       city="Paris",
                       country=u'France')
        geom = WKTSpatialElement("MULTIPOINT((90 -45))", srid=21781)
        p4 = TestPoint(the_geom=geom,
                       name=u'123',
                       city='Londre',
                       country=u'UK')

        pt1 = Functionality(name=u'print_template',
                            value=u'1 Wohlen A4 portrait')
        pt2 = Functionality(name=u'print_template',
                            value=u'2 Wohlen A3 landscape')
        user1 = User(username=u'__test_user1', password=u'__test_user1')
        role1 = Role(name=u'__test_role1',
                     description=u'__test_role1',
                     functionalities=[pt1, pt2])
        user1.role = role1
        user1.email = u'Tarenpion'

        user2 = User(username=u'__test_user2', password=u'__test_user2')
        role2 = Role(name=u'__test_role2',
                     description=u'__test_role2',
                     functionalities=[pt1, pt2])
        user2.role = role2
        user2.email = u'Tarenpion'

        user3 = User(username=u'__test_user3', password=u'__test_user3')
        role3 = Role(name=u'__test_role3',
                     description=u'__test_role3',
                     functionalities=[pt1, pt2])
        user3.role = role3
        user3.email = u'Tarenpion'

        layer1 = Layer(u'testpoint_unprotected', 300, public=True)
        layer2 = Layer(u'testpoint_protected', 400, public=False)
        layer3 = Layer(u'testpoint_protected_query_with_collect', public=False)

        area = "POLYGON((-100 30, -100 50, 100 50, 100 30, -100 30))"
        area = WKTSpatialElement(area, srid=21781)
        restricted_area1 = RestrictionArea(u'__test_ra1', u'',
                                           [layer2, layer3], [role1], area)

        area = "POLYGON((-100 0, -100 20, 100 20, 100 0, -100 0))"
        area = WKTSpatialElement(area, srid=21781)
        restricted_area2 = RestrictionArea(u'__test_ra2', u'',
                                           [layer2, layer3], [role2, role3],
                                           area)

        area = "POLYGON((-95 43, -95 47, 95 47, 95 43, -95 43))"
        area = WKTSpatialElement(area, srid=21781)
        restricted_area3 = RestrictionArea(u'__test_ra3',
                                           u'', [layer3], [role3],
                                           area,
                                           readwrite=True)

        DBSession.add_all([
            p1, p2, p3, p4, user1, user2, user3, restricted_area1,
            restricted_area2, restricted_area3
        ])
        DBSession.flush()

        self.id_lausanne = p1.id
        self.id_paris = p3.id

        transaction.commit()
Exemplo n.º 30
0
    def setUp(self):  # noqa
        # Always see the diff
        # https://docs.python.org/2/library/unittest.html#unittest.TestCase.maxDiff
        self.maxDiff = None

        functionality.FUNCTIONALITIES_TYPES = None

        from c2cgeoportal.models import DBSession, User, Role, \
            RestrictionArea, Theme, LayerGroup, Interface, LayerWMS

        ogcserver, ogcserver_external = create_default_ogcserver()

        role1 = Role(name=u"__test_role1")
        role1.id = 999
        user1 = User(username=u"__test_user1",
                     password=u"__test_user1",
                     role=role1)
        user1.email = "*****@*****.**"

        role2 = Role(name=u"__test_role2",
                     extent=WKTElement("POLYGON((1 2, 1 4, 3 4, 3 2, 1 2))",
                                       srid=21781))
        user2 = User(username=u"__test_user2",
                     password=u"__test_user2",
                     role=role2)

        main = Interface(name=u"main")

        private_layer = LayerWMS(name=u"__test_private_layer", public=False)
        private_layer.layer = "__test_private_layer"
        private_layer.geo_table = "a_schema.a_geo_table"
        private_layer.interfaces = [main]
        private_layer.ogc_server = ogcserver

        group = LayerGroup(name=u"__test_layer_group")
        group.children = [private_layer]

        theme = Theme(name=u"__test_theme")
        theme.children = [group]
        theme.interfaces = [main]

        DBSession.add(
            RestrictionArea(
                name=u"__test_ra1",
                description=u"",
                layers=[private_layer],
                roles=[role1],
            ))
        DBSession.add(
            RestrictionArea(
                name=u"__test_ra2",
                description=u"",
                layers=[private_layer],
                roles=[role2],
                readwrite=True,
            ))

        DBSession.add_all([
            user1,
            user2,
            role1,
            role2,
            theme,
            group,
            private_layer,
        ])

        transaction.commit()
    def setup_method(self, _):
        self.maxDiff = None

        from c2cgeoportal.models import User, Role, LayerWMS, RestrictionArea, \
            Interface, DBSession, OGCServer, \
            OGCSERVER_TYPE_MAPSERVER, OGCSERVER_AUTH_STANDARD

        cleanup_db()
        create_default_ogcserver()

        ogcserver_jpeg = OGCServer(name="__test_ogc_server_jpeg")
        ogcserver_jpeg.url = mapserv_url
        ogcserver_jpeg.image_type = "image/jpeg"
        ogcserver_jpeg.type = OGCSERVER_TYPE_MAPSERVER
        ogcserver_jpeg.auth = OGCSERVER_AUTH_STANDARD

        ogcserver_png = OGCServer(name="__test_ogc_server_png")
        ogcserver_png.url = mapserv_url
        ogcserver_png.image_type = "image/png"
        ogcserver_png.type = OGCSERVER_TYPE_MAPSERVER
        ogcserver_png.auth = OGCSERVER_AUTH_STANDARD

        ogcserver_wfs1 = OGCServer(name="__test_ogc_server_wfs1")
        ogcserver_wfs1.url = mapserv_url
        ogcserver_wfs1.url_wfs = "config://srv"
        ogcserver_wfs1.image_type = "image/png"
        ogcserver_wfs1.type = OGCSERVER_TYPE_MAPSERVER
        ogcserver_wfs1.auth = OGCSERVER_AUTH_STANDARD

        ogcserver_wfs2 = OGCServer(name="__test_ogc_server_wfs2")
        ogcserver_wfs2.url = "config://srv"
        ogcserver_wfs2.url_wfs = mapserv_url
        ogcserver_wfs2.image_type = "image/png"
        ogcserver_wfs2.type = OGCSERVER_TYPE_MAPSERVER
        ogcserver_wfs2.auth = OGCSERVER_AUTH_STANDARD

        role = Role(name="__test_role", description="__test_role")
        user = User(username="******", password="******")
        user.role_name = "__test_role"

        main = Interface(name="main")

        layer1 = LayerWMS("__test_layer1", public=False)
        layer1.layer = "__test_private_layer1"
        layer1.ogc_server = ogcserver_jpeg
        layer1.interfaces = [main]

        layer2 = LayerWMS("__test_layer2", public=False)
        layer2.layer = "__test_private_layer2"
        layer2.ogc_server = ogcserver_png
        layer2.interfaces = [main]

        layer3 = LayerWMS("__test_layer3", public=False)
        layer3.layer = "__test_private_layer3"
        layer3.ogc_server = ogcserver_wfs1
        layer3.interfaces = [main]

        layer4 = LayerWMS("__test_layer4", public=False)
        layer4.layer = "__test_private_layer4"
        layer4.ogc_server = ogcserver_wfs2
        layer4.interfaces = [main]

        restricted_area = RestrictionArea("__test_ra", "",
                                          [layer1, layer2, layer3, layer4],
                                          [role])

        DBSession.add_all([user, restricted_area])
        transaction.commit()
Exemplo n.º 32
0
    def setUp(self):  # noqa
        self.maxDiff = None

        from c2cgeoportal.models import User, Role, LayerV1, RestrictionArea, \
            Functionality, Interface, DBSession, management, OGCServer, \
            OGCSERVER_TYPE_GEOSERVER, OGCSERVER_AUTH_GEOSERVER

        if management:
            TestPoint.__table__.c.the_geom.type.management = True

        create_default_ogcserver()
        ogcserver_geoserver = OGCServer(name="__test_ogc_server_geoserver")
        ogcserver_geoserver.url = mapserv
        ogcserver_geoserver.type = OGCSERVER_TYPE_GEOSERVER
        ogcserver_geoserver.auth = OGCSERVER_AUTH_GEOSERVER

        TestPoint.__table__.create(bind=DBSession.bind, checkfirst=True)

        geom = WKTElement("MULTIPOINT((-90 -45))", srid=21781)
        p1 = TestPoint(the_geom=geom,
                       name=u"foo",
                       city=u"Lausanne",
                       country=u"Swiss")
        geom = WKTElement("MULTIPOINT((-90 45))", srid=21781)
        p2 = TestPoint(the_geom=geom,
                       name=u"bar",
                       city=u"Chambéry",
                       country=u"France")
        geom = WKTElement("MULTIPOINT((90 45))", srid=21781)
        p3 = TestPoint(the_geom=geom,
                       name=u"éàè",
                       city="Paris",
                       country=u"France")
        geom = WKTElement("MULTIPOINT((90 -45))", srid=21781)
        p4 = TestPoint(the_geom=geom,
                       name=u"123",
                       city="Londre",
                       country=u"UK")

        pt1 = Functionality(name=u"print_template",
                            value=u"1 Wohlen A4 portrait")
        pt2 = Functionality(name=u"print_template",
                            value=u"2 Wohlen A3 landscape")
        user1 = User(username=u"__test_user1", password=u"__test_user1")
        role1 = Role(name=u"__test_role1",
                     description=u"__test_role1",
                     functionalities=[pt1, pt2])
        user1.role_name = role1.name
        user1.email = u"Tarenpion"

        user2 = User(username=u"__test_user2", password=u"__test_user2")
        role2 = Role(name=u"__test_role2",
                     description=u"__test_role2",
                     functionalities=[pt1, pt2])
        user2.role_name = role2.name
        user2.email = u"Tarenpion"

        user3 = User(username=u"__test_user3", password=u"__test_user3")
        role3 = Role(name=u"__test_role3",
                     description=u"__test_role3",
                     functionalities=[pt1, pt2])
        user3.role_name = role3.name
        user3.email = u"Tarenpion"

        main = Interface(name=u"main")

        layer2 = LayerV1(u"testpoint_protected", public=False)
        layer2.interfaces = [main]
        layer3 = LayerV1(u"testpoint_protected_query_with_collect",
                         public=False)
        layer3.interfaces = [main]

        area = "POLYGON((-100 30, -100 50, 100 50, 100 30, -100 30))"
        area = WKTElement(area, srid=21781)
        restricted_area1 = RestrictionArea(u"__test_ra1", u"",
                                           [layer2, layer3], [role1], area)

        area = "POLYGON((-100 0, -100 20, 100 20, 100 0, -100 0))"
        area = WKTElement(area, srid=21781)
        restricted_area2 = RestrictionArea(u"__test_ra2", u"",
                                           [layer2, layer3], [role2, role3],
                                           area)

        area = "POLYGON((-95 43, -95 47, 95 47, 95 43, -95 43))"
        area = WKTElement(area, srid=21781)
        restricted_area3 = RestrictionArea(u"__test_ra3",
                                           u"", [layer3], [role3],
                                           area,
                                           readwrite=True)

        DBSession.add_all([
            p1, p2, p3, p4, user1, user2, user3, role1, role2, role3,
            restricted_area1, restricted_area2, restricted_area3,
            ogcserver_geoserver
        ])
        DBSession.flush()

        self.id_lausanne = p1.id
        self.id_paris = p3.id

        transaction.commit()
Exemplo n.º 33
0
    def setup_method(self, _):
        # Always see the diff
        # https://docs.python.org/2/library/unittest.html#unittest.TestCase.maxDiff
        self.maxDiff = None

        from c2cgeoportal.models import User, Role, LayerWMS, RestrictionArea, \
            Functionality, Interface, DBSession, OGCServer, \
            OGCSERVER_TYPE_GEOSERVER, OGCSERVER_AUTH_GEOSERVER

        cleanup_db()

        ogc_server_internal, _ = create_default_ogcserver()
        ogcserver_geoserver = OGCServer(name="__test_ogc_server_geoserver")
        ogcserver_geoserver.url = mapserv_url
        ogcserver_geoserver.type = OGCSERVER_TYPE_GEOSERVER
        ogcserver_geoserver.auth = OGCSERVER_AUTH_GEOSERVER

        PointTest.__table__.create(bind=DBSession.bind, checkfirst=True)

        geom = WKTElement("POINT(599910 199955)", srid=21781)
        p1 = PointTest(geom=geom, name="foo", city="Lausanne", country="Swiss")
        geom = WKTElement("POINT(599910 200045)", srid=21781)
        p2 = PointTest(geom=geom, name="bar", city="Chambéry", country="France")
        geom = WKTElement("POINT(600090 200045)", srid=21781)
        p3 = PointTest(geom=geom, name="éàè", city="Paris", country="France")
        geom = WKTElement("POINT(600090 199955)", srid=21781)
        p4 = PointTest(geom=geom, name="123", city="Londre", country="UK")

        pt1 = Functionality(name="print_template", value="1 Wohlen A4 portrait")
        pt2 = Functionality(name="print_template", value="2 Wohlen A3 landscape")
        user1 = User(username="******", password="******")
        role1 = Role(name="__test_role1", description="__test_role1", functionalities=[pt1, pt2])
        user1.role_name = role1.name
        user1.email = "Tarenpion"

        user2 = User(username="******", password="******")
        role2 = Role(name="__test_role2", description="__test_role2", functionalities=[pt1, pt2])
        user2.role_name = role2.name
        user2.email = "Tarenpion"

        user3 = User(username="******", password="******")
        role3 = Role(name="__test_role3", description="__test_role3", functionalities=[pt1, pt2])
        user3.role_name = role3.name

        main = Interface(name="main")

        layer2 = LayerWMS("testpoint_protected", public=False)
        layer2.layer = "testpoint_protected"
        layer2.ogc_server = ogc_server_internal
        layer2.interfaces = [main]

        layer3 = LayerWMS("testpoint_protected_query_with_collect", public=False)
        layer3.layer = "testpoint_protected_query_with_collect"
        layer3.ogc_server = ogc_server_internal
        layer3.interfaces = [main]

        area = "POLYGON((599900 200030, 599900 200050, 600100 200050, 600100 200030, 599900 200030))"
        area = WKTElement(area, srid=21781)
        restricted_area1 = RestrictionArea("__test_ra1", "", [layer2, layer3], [role1], area)

        area = "POLYGON((599900 200000, 599900 200020, 600100 200020, 600100 200000, 599900 200000))"
        area = WKTElement(area, srid=21781)
        restricted_area2 = RestrictionArea("__test_ra2", "", [layer2, layer3], [role2, role3], area)

        area = "POLYGON((599905 200043, 599905 200047, 600095 200047, 600095 200043, 599905 200043))"
        area = WKTElement(area, srid=21781)
        restricted_area3 = RestrictionArea("__test_ra3", "", [layer3], [role3], area, readwrite=True)

        DBSession.add_all([
            p1, p2, p3, p4, user1, user2, user3, role1, role2, role3,
            restricted_area1, restricted_area2, restricted_area3, ogcserver_geoserver
        ])
        DBSession.flush()

        self.id_lausanne = p1.id
        self.id_paris = p3.id
        self.ogc_server_id = ogc_server_internal.id
        self.role1_id = role1.id
        self.role2_id = role2.id
        self.role3_id = role3.id

        transaction.commit()