Exemplo n.º 1
0
    def test_proxy_not_auth(self):
        from pyramid.httpexceptions import HTTPUnauthorized

        from c2cgeoportal_geoportal.views.tinyowsproxy import TinyOWSProxy

        request = _create_dummy_request()

        with pytest.raises(HTTPUnauthorized):
            TinyOWSProxy(request).proxy()
Exemplo n.º 2
0
    def test_proxy_get_capabilities_post_invalid_body(self):
        from pyramid.httpexceptions import HTTPBadRequest

        from c2cgeoportal_geoportal.views.tinyowsproxy import TinyOWSProxy

        request = _create_dummy_request(username="******")
        request.method = "POST"
        request.body = "This is not XML"

        # proxy = self.get_fake_proxy_(request, "", None)
        with pytest.raises(HTTPBadRequest):
            TinyOWSProxy(request).proxy()
Exemplo n.º 3
0
    def test_proxy_get_capabilities_user2(self):
        from c2cgeoportal_geoportal.views.tinyowsproxy import TinyOWSProxy

        request = _create_dummy_request(username="******")

        responses.get(
            url="http://mapserver:8080/",
            body=load_file(self.capabilities_response_file),
        )

        response = TinyOWSProxy(request).proxy()

        self.assertEqual(
            load_file(self.capabilities_response_filtered_file2).strip(),
            response.body.decode().replace("  \n", "").strip(),
        )
        self.assertEqual("200 OK", response.status)
Exemplo n.º 4
0
    def test_proxy_get_capabilities_get(self):
        from c2cgeoportal_geoportal.views.tinyowsproxy import TinyOWSProxy

        request = _create_dummy_request(username="******")
        request.params.update(
            dict(service="wfs", version="1.1.0", request="GetCapabilities"))

        responses.get(
            url="http://mapserver:8080/",
            body=load_file(self.capabilities_response_file),
        )

        response = TinyOWSProxy(request).proxy()

        self.assertEqual(
            load_file(self.capabilities_response_filtered_file1).strip(),
            response.body.decode().replace("  \n", "").strip(),
        )
        self.assertEqual("200 OK", response.status)
Exemplo n.º 5
0
    def test_proxy_describe_feature_type_get(self):
        from c2cgeoportal_geoportal.views.tinyowsproxy import TinyOWSProxy

        request = _create_dummy_request(username="******")
        request.registry.settings["tinyowsproxy"].update({
            "tinyows_host":
            "demo.gmf.org",
            "tinyows_url":
            "http://example.com",
        })
        request.params.update(
            dict(service="wfs",
                 version="1.1.0",
                 request="DescribeFeatureType",
                 typename="tows:layer_1"))

        responses.get(
            url="http://mapserver:8080/",
            body="unfiltered response",
        )

        response = TinyOWSProxy(request).proxy()

        self.assertEqual("200 OK", response.status)