Пример #1
0
    def handle_wsdl(self, request, *args, **kwargs):
        """Return services WSDL."""
        ctx = HttpMethodContext(self, request, 'text/xml; charset=utf-8')

        if self.doc.wsdl11 is None:
            raise Http404('WSDL is not available')

        if self._wsdl is None:
            # Interface document building is not thread safe so we don't use
            # server interface document shared between threads. Instead we
            # create and build interface documents in current thread. This
            # section can be safely repeated in another concurrent thread.
            doc = AllYourInterfaceDocuments(self.app.interface)
            doc.wsdl11.build_interface_document(request.build_absolute_uri())
            wsdl = doc.wsdl11.get_interface_document()

            if self._cache_wsdl:
                self._wsdl = wsdl
        else:
            wsdl = self._wsdl

        ctx.transport.wsdl = wsdl

        response = HttpResponse(ctx.transport.wsdl)
        return self.response(response, ctx, ())
Пример #2
0
    def setUp(self):
        super().setUp()

        # Reset the cached WSDL since it might contain the URL of
        # the other LiveServerTestCase (which uses a different port)
        from zaakmagazijn.api import views
        from spyne.interface import AllYourInterfaceDocuments

        # TODO [TECH]: Find a proper way to get all the WSDLs
        for view in [views.ontvangasynchroon_view]:
            view.__wrapped__._wsdl = None
            view.__wrapped__.doc = AllYourInterfaceDocuments(
                view.__wrapped__.app.interface)

        self.ontvanger = ApplicationFactory(name='TTA',
                                            organisation__name='ORG')

        # Basically, we communicate with ourselves... (we implemented DI01 just for testing).
        self.ontvanger.endpoint_set.create(
            type=EndpointTypeChoices.ontvang_asynchroon,
            url='{}/{}/?WSDL'.format(self.live_server_url,
                                     'OntvangAsynchroon'))

        self.consumer = Consumer(self.ontvanger)
        self.zaak = ZaakFactory.create(
            zaaktype__archiefclassificatiecode='123')
Пример #3
0
    def __init__(self, app):
        self.app = app
        self.app.transport = self.transport  # FIXME: this is weird
        self.appinit()

        self.event_manager = EventManager(self)
        self.doc = AllYourInterfaceDocuments(app.interface)
Пример #4
0
    def _get_client(self, soap_port, **kwargs):
        # Reset the cached WSDL since it might contain the URL of
        # the other LiveServerTestCase (which uses a different port)
        from zaakmagazijn.api import views
        from spyne.interface import AllYourInterfaceDocuments

        # TODO [TECH]: Find a proper way to get all the WSDLs
        for view in [
                views.verwerksynchroonvrijbericht_view,
                views.beantwoordvraag_view, views.ontvangasynchroon_view
        ]:
            view.__wrapped__._wsdl = None
            view.__wrapped__.doc = AllYourInterfaceDocuments(
                view.__wrapped__.app.interface)

        return Client('{}/{}/?WSDL'.format(self.live_server_url, soap_port),
                      **kwargs)
Пример #5
0
 def __init__(self, app):
     self.app = app
     self.app.transport = self.transport
     self.event_manager = EventManager(self)
     self.doc = AllYourInterfaceDocuments(app.interface)
Пример #6
0
    def _do_request(self,
                    soap_port,
                    template_name,
                    extra_context=None,
                    stp_syntax=False):
        """
        Calls the Zaakmagazijn SOAP endpoint with the given request.

        soap_port: 'OntvangAsynchroon', 'BeantwoordVraag' etc
        template_name: the template's filename in the tests/files/ directory, used to build the request
        extra_context: any additional context for processing the template
        """

        if extra_context is None:
            extra_context = {}

        # Full request I intercepted was:
        #
        # POST /VerwerkSynchroonVrijBericht HTTP/1.0
        # X-Real-IP: 87.250.154.26
        # X-Forwarded-For: 87.250.154.26
        # X-Forwarded-Proto: https
        # X-Scheme: https
        # Host: haarlem-zaakmagazijn.maykin.nl
        # Connection: close
        # Content-Length: 1011
        # content-type: text/xml; charset=utf-8
        # appId: 50583302
        # partyId: 00000000000000000000041
        # SOAPAction:
        # Cache-Control: no-cache
        # Pragma: no-cache
        # User-Agent: Java/1.7.0_75
        # Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2

        # <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
        #     <soapenv:Header/>
        #     <soapenv:Body><ZDS:genereerZaakIdentificatie_Di02 xmlns:StUF="http://www.egem.nl/StUF/StUF0301" xmlns:ZDS="http://www.stufstandaarden.nl/koppelvlak/zds0120" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.stufstandaarden.nl/koppelvlak/zds0120 zds0120_msg_zs-dms.xsd">
        #     <ZDS:stuurgegevens>
        #         <StUF:berichtcode>Di02</StUF:berichtcode>
        #         <StUF:zender>
        #             <StUF:organisatie>KING</StUF:organisatie>
        #             <StUF:applicatie>STP</StUF:applicatie>
        #             <StUF:gebruiker/>
        #         </StUF:zender>
        #         <StUF:ontvanger>
        #             <StUF:organisatie>ORG</StUF:organisatie>
        #             <StUF:applicatie>TTA</StUF:applicatie>
        #             <StUF:gebruiker/>
        #         </StUF:ontvanger>
        #         <StUF:tijdstipBericht>20170627161630</StUF:tijdstipBericht>
        #         <StUF:functie>genereerZaakidentificatie</StUF:functie>
        #     </ZDS:stuurgegevens>
        # </ZDS:genereerZaakIdentificatie_Di02></soapenv:Body>
        # </soapenv:Envelope>

        # Reset the cached WSDL since it might contain the URL of
        # the other LiveServerTestCase (which uses a different port)
        from zaakmagazijn.api import views
        from spyne.interface import AllYourInterfaceDocuments

        # TODO [TECH]: Find a proper way to get all the WSDLs
        for view in [
                views.verwerksynchroonvrijbericht_view,
                views.beantwoordvraag_view
        ]:
            view.__wrapped__._wsdl = None
            view.__wrapped__.doc = AllYourInterfaceDocuments(
                view.__wrapped__.app.interface)

        # Maybe a bit too overkill.
        headers = {
            'SOAPAction': '',
            'User-Agent': 'Java/1.7.0_75',
            'partyId': '00000000000000000000041',
            'appId': '50583302'
        }

        context = self.get_context_data(**extra_context)
        rendered_envelope = self._build_template(template_name,
                                                 context,
                                                 stp_syntax=stp_syntax)
        logger.debug(rendered_envelope.decode(encoding='utf-8'))
        self._validate_xml(rendered_envelope)
        response = requests.post('{}/{}'.format(self.live_server_url,
                                                soap_port),
                                 rendered_envelope,
                                 headers=headers)
        logger.debug(
            etree.tostring(etree.fromstring(response.content),
                           xml_declaration=True,
                           encoding="UTF-8",
                           pretty_print=True).decode(encoding='utf-8'))
        return response