def setUpTestData(cls):
        super().setUpTestData()

        cls.task_dict = {
            "topic_name": "send-email",
            "worker_id": "test-worker-id",
            "task_id": "test-task-id",
            "variables": {
                "sender":
                serialize_variable({
                    "email": "*****@*****.**",
                    "name": "Kees Koos"
                }),
                "receiver":
                serialize_variable({
                    "email": "*****@*****.**",
                    "name": "Jan Janssen",
                    "assignee": "user:janjansen",
                }),
                "email":
                serialize_variable({
                    "subject": "Vakantiepret",
                    "content": "Dit is pas leuk."
                }),
                "template":
                serialize_variable("generiek"),
                "context":
                serialize_variable({
                    "deadline": "2020-04-20",
                    "kownslFrontendUrl": "test.com?uuid=123456",
                }),
            },
        }
    def setUpTestData(cls):
        super().setUpTestData()

        mapping = TaskMappingFactory.create(topic_name="some-topic")
        DefaultServiceFactory.create(
            task_mapping=mapping,
            service__api_root=DRC_URL,
            service__api_type="drc",
            alias="drc",
        )

        cls.fetched_task = ExternalTask.objects.create(
            topic_name="some-topic",
            worker_id="test-worker-id",
            task_id="test-task-id",
            variables={
                "informatieobject":
                serialize_variable(DOCUMENT_URL),
                "lockId":
                serialize_variable("bacbaeaf-600d-4b79-9414-3e1a668addd3"),
                "services":
                serialize_variable({
                    "drc": {
                        "jwt": "Bearer 12345"
                    },
                }),
            },
        )
    def test_start_interactive_template(self, m):
        m.post(
            f"{XENTIAL_API_ROOT}auth/whoami",
            json={
                "user": {
                    "uuid": "a4664ccb-259e-4107-b800-d8e5a764b9dd",
                    "userName": "******",
                },
                "XSessionId": "f7f588eb-b7c9-4d23-babd-4a98a9326367",
            },
        )
        m.post(
            f"{XENTIAL_API_ROOT}createTicket",
            json={"ticketId": "b0fdd542-0cc4-44a1-8dfb-808436123ce8"},
        )

        external_task = ExternalTask.objects.create(
            topic_name="xential-topic",
            worker_id="test-worker-id",
            task_id="test-task-id",
            variables={
                "bptlAppId":
                serialize_variable("some-app-id"),
                "templateUuid":
                serialize_variable("3e09b238-0617-47c1-8e6a-f6227b3d542e"),
                "interactive":
                serialize_variable(True),
                "templateVariables":
                serialize_variable({
                    "textq1": "Answer1",
                    "dateq1": "31-12-20"
                }),
                "documentMetadata":
                serialize_variable({
                    "bronorganisatie":
                    "517439943",
                    "creatiedatum":
                    "01-01-2021",
                    "titel":
                    "Test Document",
                    "auteur":
                    "Test Author",
                    "taal":
                    "eng",
                    "informatieobjecttype":
                    "http://openzaak.nl/catalogi/api/v1/informatieobjecttypen/06d3a135-bc20-4fce-9add-f69d8e585917",
                }),
            },
        )

        result = start_xential_template(external_task)

        # Check that the XentialTicket object was created
        xential_ticket = XentialTicket.objects.get()
        token = token_generator.make_token(xential_ticket)
        bptl_ticket_url = f"https://example.com/contrib/api/xential/interactive_document/{xential_ticket.bptl_ticket_uuid}/{token}"

        self.assertEqual("b0fdd542-0cc4-44a1-8dfb-808436123ce8",
                         str(xential_ticket.ticket_uuid))
        self.assertEqual(bptl_ticket_url, result["bptlDocumentUrl"])
Exemple #4
0
    def setUp(self):
        super().setUp()

        mapping = TaskMappingFactory.create(topic_name="some-topic")
        DefaultServiceFactory.create(
            task_mapping=mapping,
            service__api_root=DRC_URL,
            service__api_type="drc",
            alias="drc",
        )
        DefaultServiceFactory.create(
            task_mapping=mapping,
            service__api_root=ZRC_URL,
            service__api_type="zrc",
            alias="ZRC",
        )

        self.fetched_task = ExternalTask.objects.create(
            topic_name="some-topic",
            worker_id="test-worker-id",
            task_id="test-task-id",
            variables={
                "zaakUrl": serialize_variable(ZAAK),
                "bptlAppId": serialize_variable("some-app-id"),
            },
        )
    def test_eigenschap_waarde_is_empty(self, m):
        mock_service_oas_get(m, ZRC_URL, "zrc")
        mock_service_oas_get(m, ZTC_URL, "ztc")

        # https://catalogi-api.vng.cloud/api/v1/schema/#operation/eigenschap_list
        fetched_task = ExternalTask.objects.create(
            topic_name="some-topic",
            worker_id="test-worker-id",
            task_id="test-task-id",
            variables={
                "services":
                serialize_variable({
                    "ZRC": {
                        "jwt": "Bearer 12345"
                    },
                    "ZTC": {
                        "jwt": "Bearer 12345"
                    },
                }),
                "zaakUrl":
                serialize_variable(ZAAK),
                "eigenschap":
                serialize_variable({
                    "naam": "referentie",
                    "waarde": "",
                }),
            },
        )

        task = CreateEigenschap(fetched_task)
        task.perform()

        self.assertTrue(all(req.method == "GET" for req in m.request_history))
    def test_send_email_nen2580_template(self):
        task_dict = copy.deepcopy(self.task_dict)
        task_dict["variables"]["email"] = serialize_variable({
            "subject":
            "Toelichting op niet akkoord",
            "content":
            "Ik kan hier echt niet mee akkoord gaan.",
        })
        task_dict["variables"]["template"] = serialize_variable("nen2580")
        task_dict["variables"]["context"] = serialize_variable({})
        task = ExternalTask.objects.create(**task_dict)
        send_mail = SendEmailTask(task)
        send_mail.perform()

        self.assertEqual(len(mail.outbox), 1)
        email = mail.outbox[0]

        self.assertEqual(
            email.body,
            """Beste Jan Janssen,

Wij hebben de door u aangeleverde documenten bekeken en vragen u onderstaande wijzigingen hier te doen:

Ik kan hier echt niet mee akkoord gaan.

De gewijzigde documenten kunt u opnieuw indienen.

Met vriendelijke groeten,

Kees Koos""",
        )
        self.assertEqual(email.subject, "Toelichting op niet akkoord")
    def setUpTestData(cls):
        super().setUpTestData()

        mapping = TaskMappingFactory.create(topic_name="some-topic")
        DefaultServiceFactory.create(
            task_mapping=mapping,
            service__api_root=ZRC_URL,
            service__api_type="zrc",
            alias="ZRC",
        )
        DefaultServiceFactory.create(
            task_mapping=mapping,
            service__api_root=ZTC_URL,
            service__api_type="ztc",
            alias="ZTC",
        )
        cls.fetched_task = ExternalTask.objects.create(
            topic_name="some-topic",
            worker_id="test-worker-id",
            task_id="test-task-id",
            variables={
                "zaakUrl": serialize_variable(ZAAK),
                "statustype": serialize_variable(STATUSTYPE),
                "services": serialize_variable({"ZRC": {"jwt": "Bearer 12345"}}),
                "toelichting": serialize_variable("some description"),
            },
        )
    def test_create_zaak_cant_find_catalogus(self, m):
        mock_service_oas_get(m, ZTC_URL, "ztc")
        self.fetched_task.variables["zaaktype"] = serialize_variable("")
        self.fetched_task.variables["catalogusDomein"] = serialize_variable(
            "ABR")
        self.fetched_task.variables[
            "zaaktypeIdentificatie"] = serialize_variable("abcd")
        self.fetched_task.save()
        task = CreateZaakTask(self.fetched_task)

        m.get(
            f"{ZTC_URL}catalogussen?domein=ABR&rsin=002220647",
            status_code=200,
            json={
                "count": 0,
                "next": None,
                "previous": None,
                "results": []
            },
        )
        with self.assertRaises(ValueError) as e:
            task.perform()
        self.assertEqual(
            e.exception.__str__(),
            "No catalogus found with domein ABR and RSIN 002220647.",
        )
    def test_execute_fail(self, m, mock_fail_task):
        task = ExternalTaskFactory.create(
            topic_name="zaak-initialize",
            variables={
                "zaaktype":
                serialize_variable(ZAAKTYPE),
                "organisatieRSIN":
                serialize_variable("123456788"),
                "services":
                serialize_variable({
                    "ZRC": {
                        "jwt": "Bearer 12345"
                    },
                    "ZTC": {
                        "jwt": "Bearer 789"
                    },
                }),
            },
        )
        # mock openzaak services
        mock_service_oas_get(m, ZTC_URL, "ztc")
        mock_service_oas_get(m, ZRC_URL, "zrc")
        m.post(f"{ZRC_URL}zaken", exc=ConnectionError("some connection error"))

        stdout = StringIO()
        call_command("execute_task", task_id=task.id, stdout=stdout)

        task.refresh_from_db()
        self.assertEqual(task.status, Statuses.failed)
        self.assertTrue(
            task.execution_error.strip().endswith("some connection error"))

        mock_fail_task.assert_called_once_with(task)
    def setUpTestData(cls):
        super().setUpTestData()

        mapping = TaskMapping.objects.create(
            topic_name="ValidSignReminder",
            callback="bptl.work_units.valid_sign.tasks.CreateValidSignPackage",
        )

        DefaultServiceFactory.create(
            task_mapping=mapping,
            service__api_root=VALIDSIGN_URL,
            service__api_type="orc",
            service__oas=VALIDSIGN_API_DOCS,
            alias="ValidSignAPI",
        )

        cls.fetched_task = ExternalTask.objects.create(
            topic_name="ValidSignReminder",
            worker_id="reminder-worker-id",
            task_id="reminder-task-id",
            variables={
                "packageId": serialize_variable("BW5fsOKyhj48A-fRwjPyYmZ8Mno="),
                "email": serialize_variable("*****@*****.**"),
            },
        )
    def setUpTestData(cls):
        super().setUpTestData()

        mapping = TaskMapping.objects.create(
            topic_name="CreateValidSignPackage",
            callback="bptl.work_units.valid_sign.tasks.CreateValidSignPackage",
        )
        drc_svc = DefaultServiceFactory.create(
            task_mapping=mapping,
            service__api_root=DRC_URL,
            service__api_type="drc",
            alias="drc",
        )
        cls.drc = drc_svc.service
        DefaultServiceFactory.create(
            task_mapping=mapping,
            service__api_root=VALIDSIGN_URL,
            service__api_type="orc",
            service__oas=VALIDSIGN_API_DOCS,
            alias="ValidSignAPI",
        )

        cls.fetched_task = ExternalTask.objects.create(
            topic_name="CreateValidSignPackage",
            worker_id="test-worker-id",
            task_id="test-task-id",
            variables={
                "documents": serialize_variable([DOCUMENT_1, DOCUMENT_2]),
                "signers": serialize_variable([SIGNER_1, SIGNER_2]),
                "packageName": serialize_variable("Test package name"),
                "services": serialize_variable({"drc": {"jwt": "Bearer 12345"}}),
            },
        )
    def test_create_zaak_with_rol(self, m):
        mock_service_oas_get(m, ZTC_URL, "ztc")
        mock_service_oas_get(m, ZRC_URL, "zrc")

        mock_statustypen_get(m)
        m.post(f"{ZRC_URL}zaken", status_code=201, json=RESPONSES[ZAAK])
        mock_status_post(m)

        mock_roltype_get(m)
        mock_rol_post(m)

        task_with_initiator = ExternalTask.objects.create(
            topic_name="some-topic",
            worker_id="test-worker-id",
            task_id="test-task-id",
            variables={
                "zaaktype":
                serialize_variable(ZAAKTYPE),
                "organisatieRSIN":
                serialize_variable("002220647"),
                "NLXProcessId":
                serialize_variable("12345"),
                "services":
                serialize_variable({
                    "ZRC": {
                        "jwt": "Bearer 12345"
                    },
                    "ZTC": {
                        "jwt": "Bearer 789"
                    },
                }),
                "initiator":
                serialize_variable({
                    "betrokkeneType": "natuurlijk_persoon",
                    "roltoelichting": "A test roltoelichting",
                }),
            },
        )

        task = CreateZaakTask(task_with_initiator)
        result = task.perform()

        self.assertEqual(
            result,
            {
                "zaakUrl": ZAAK,
                "zaakIdentificatie": "ZAAK-2020-0000000013",
            },
        )
        # check that the /api/v1/rollen endpoint was called correctly
        self.assertEqual(m.last_request.url,
                         "https://some.zrc.nl/api/v1/rollen")
        self.assertIsInstance(m.last_request.json(), dict)
    def test_close_zaak_with_resultaattype(self, m):
        self._mock_zgw(m)

        fetched_task = ExternalTask.objects.create(
            topic_name="some-topic",
            worker_id="test-worker-id",
            task_id="test-task-id",
            variables={
                "zaak": serialize_variable(ZAAK),
                "resultaattype": serialize_variable(RESULTAATTYPE),
                "services": {
                    "type":
                    "json",
                    "value":
                    json.dumps({
                        "ZRC": {
                            "jwt": "Bearer 12345"
                        },
                        "ZTC": {
                            "jwt": "Bearer 789"
                        },
                    }),
                },
            },
        )

        task = CloseZaakTask(fetched_task)

        result = task.perform()

        self.assertEqual(
            result,
            {
                "einddatum": "2020-01-20",
                "archiefnominatie": "blijvend_bewaren",
                "archiefactiedatum": "2025-01-20",
            },
        )
        history_resultaat = list(
            filter(
                lambda x: x.method == "POST" and x.url ==
                f"{ZRC_URL}resultaten",
                m.request_history,
            ))
        self.assertEqual(len(history_resultaat), 1)
        self.assertEqual(
            history_resultaat[0].json(),
            {
                "zaak": ZAAK,
                "resultaattype": RESULTAATTYPE,
                "toelichting": ""
            },
        )
    def setUpTestData(cls):
        super().setUpTestData()

        mapping = TaskMapping.objects.create(topic_name="xential-topic", )

        xential = Service.objects.create(
            label="xential",
            api_type=APITypes.orc,
            api_root=XENTIAL_API_ROOT,
            auth_type=AuthTypes.api_key,
            oas="",
        )
        DefaultServiceFactory.create(
            task_mapping=mapping,
            service=xential,
            alias="xential",
        )

        cls.external_task = ExternalTask.objects.create(
            topic_name="xential-topic",
            worker_id="test-worker-id",
            task_id="test-task-id",
            variables={
                "bptlAppId":
                serialize_variable("some-app-id"),
                "templateUuid":
                serialize_variable("3e09b238-0617-47c1-8e6a-f6227b3d542e"),
                "interactive":
                serialize_variable(False),
                "templateVariables":
                serialize_variable({
                    "textq1": "Answer1",
                    "dateq1": "31-12-20"
                }),
                "documentMetadata":
                serialize_variable({
                    "bronorganisatie":
                    "517439943",
                    "creatiedatum":
                    "01-01-2021",
                    "titel":
                    "Test Document",
                    "auteur":
                    "Test Author",
                    "taal":
                    "eng",
                    "informatieobjecttype":
                    "http://openzaak.nl/catalogi/api/v1/informatieobjecttypen/06d3a135-bc20-4fce-9add-f69d8e585917",
                }),
            },
        )
Exemple #15
0
    def test_interactive_document_redirect_with_expired_token(self, m):
        bptl_ticket_uuid = "f7f588eb-b7c9-4d23-babd-4a98a9326367"
        ticket_uuid = "99e6189a-e081-448b-a280-ca5bcde21d4e"

        external_task = ExternalTask.objects.create(
            topic_name="xential-topic",
            worker_id="test-worker-id",
            task_id="test-task-id",
            variables={
                "bptlAppId":
                serialize_variable("some-app-id"),
                "templateUuid":
                serialize_variable("3e09b238-0617-47c1-8e6a-f6227b3d542e"),
                "interactive":
                serialize_variable("True"),
                "templateVariables":
                serialize_variable({}),
                "documentMetadata":
                serialize_variable({
                    "bronorganisatie":
                    "517439943",
                    "creatiedatum":
                    "01-01-2021",
                    "titel":
                    "Test Document",
                    "auteur":
                    "Test Author",
                    "taal":
                    "eng",
                    "informatieobjecttype":
                    "http://openzaak.nl/catalogi/api/v1/informatieobjecttypen/06d3a135-bc20-4fce-9add-f69d8e585917",
                }),
            },
        )

        xential_ticket = XentialTicket.objects.create(
            task=external_task,
            bptl_ticket_uuid=bptl_ticket_uuid,
            ticket_uuid=ticket_uuid,
        )

        token = token_generator.make_token(xential_ticket)

        path = reverse("Xential:interactive-document",
                       args=[bptl_ticket_uuid, token])
        bptl_interactive_url = get_absolute_url(path)

        with freeze_time(timedelta(days=8)):
            response = self.client.get(bptl_interactive_url)
            self.assertEqual(status.HTTP_403_FORBIDDEN, response.status_code)
    def test_get_email_details(self, m):
        mock_service_oas_get(m, KOWNSL_API_ROOT, "kownsl")
        rr_response = {
            "id": "1",
            "forZaak": "https://zaken.nl/api/v1/zaak/123",
            "reviewType": "advice",
            "requester": {
                "username": "******",
            },
        }
        m.get(
            f"{KOWNSL_API_ROOT}api/v1/review-requests/1",
            json=rr_response,
        )

        task_dict = copy.deepcopy(self.task_dict)
        task_dict["variables"].update({
            "kownslFrontendUrl":
            serialize_variable("a-url.test"),
            "deadline":
            serialize_variable("2020-04-01"),
        })

        task = ExternalTask.objects.create(**task_dict, )

        email_details = get_email_details(task)
        self.assertTrue("email" in email_details)
        self.assertEqual(
            email_details["email"],
            {
                "subject": "Uw advies wordt gevraagd",
                "content": "",
            },
        )

        self.assertEqual(
            email_details["context"],
            {
                "deadline": "2020-04-01",
                "kownslFrontendUrl": "a-url.test",
            },
        )

        self.assertTrue("template" in email_details)
        self.assertEqual(email_details["template"], "advies")

        self.assertTrue("senderUsername" in email_details)
        self.assertEqual(email_details["senderUsername"], ["user:Pietje"])
    def test_extra_variables(self, m):
        self.fetched_task.variables["zaakDetails"] = serialize_variable({
            "omschrijving":
            "foo",
        })
        self.fetched_task.save(0)

        mock_service_oas_get(m, ZTC_URL, "ztc")
        mock_service_oas_get(m, ZRC_URL, "zrc")

        mock_statustypen_get(m)
        response = RESPONSES[ZAAK].copy()
        response["omschrijving"] = "foo"
        m.post(f"{ZRC_URL}zaken", status_code=201, json=response)
        mock_status_post(m)
        task = CreateZaakTask(self.fetched_task)

        task.perform()

        request_zaak = next(
            filter(
                lambda x: x.url == f"{ZRC_URL}zaken" and x.method == "POST",
                m.request_history,
            ))

        self.assertEqual(request_zaak.json()["omschrijving"], "foo")
    def test_send_email_review_template(self):
        task_dict = copy.deepcopy(self.task_dict)
        task_dict["variables"]["template"] = serialize_variable("advies")
        task = ExternalTask.objects.create(**task_dict)
        send_mail = SendEmailTask(task)
        send_mail.perform()

        self.assertEqual(len(mail.outbox), 1)
        email = mail.outbox[0]

        self.assertEqual(
            email.body,
            """Beste Jan Janssen,

Uw advies is vereist. U heeft tot 20 april 2020 om te reageren.

Ga alstublieft hierheen: test.com?uuid=123456&assignee=user%3Ajanjansen

Dit is pas leuk.

Met vriendelijke groeten,

Kees Koos""",
        )
        self.assertEqual(email.subject, "Vakantiepret")
        self.assertEqual(email.to, ["*****@*****.**"])
    def test_send_email_missing_variable(self):
        task_dict = copy.deepcopy(self.task_dict)
        task_dict["variables"].pop("receiver")
        task = ExternalTask.objects.create(**task_dict)
        send_mail = SendEmailTask(task)

        with self.assertRaises(Exception) as e:
            send_mail.perform()
        self.assertEqual(type(e.exception), MissingVariable)
        self.assertTrue("receiver" in e.exception.args[0])
        self.assertTrue(
            "Dit veld is vereist." in e.exception.args[0]["receiver"][0])

        task_dict = copy.deepcopy(self.task_dict)
        task_dict["variables"]["sender"] = serialize_variable({
            "email":
            "",
            "name":
            "Kees Koos"
        })
        task = ExternalTask.objects.create(**task_dict)
        send_mail = SendEmailTask(task)
        with self.assertRaises(Exception) as e:
            send_mail.perform()

        self.assertEqual(type(e.exception), MissingVariable)
        self.assertTrue("sender" in e.exception.args[0])
        self.assertTrue("email" in e.exception.args[0]["sender"])
        self.assertTrue("Dit veld mag niet leeg zijn." in e.exception.args[0]
                        ["sender"]["email"][0])
    def test_relateer_zaak_bijdrage_aard_omgekeerde_richting_invalid(self, m):
        mock_service_oas_get(m, ZRC_URL, "zrc")
        m.get(
            ZAAK,
            json={
                "url": ZAAK,
                "relevanteAndereZaken": [],
            },
        )
        m.patch(
            ZAAK,
            status_code=200,
            json={
                "url":
                ZAAK,
                "relevanteAndereZaken": [
                    {
                        "url": BIJDRAGE_ZAAK,
                        "aardRelatie": "bijdrage",
                    },
                ],
            },
        )

        self.fetched_task.variables[
            "bijdrageAardOmgekeerdeRichting"] = serialize_variable("niks")
        self.fetched_task.save()
        task = RelateerZaak(self.fetched_task)

        with self.assertRaises(ValueError) as e:
            task.perform()
        self.assertEqual(e.exception.__str__(),
                         "Unknown 'bijdrageAardOmgekeerdeRichting': 'niks'")
Exemple #21
0
    def test_task_without_instance_id(self, m):
        task = ExternalTaskFactory.create()
        XentialTicket.objects.create(
            task=task,
            bptl_ticket_uuid="2d30f19b-8666-4f45-a8da-78ad7ed0ef4d",
            ticket_uuid="f15aceb4-b316-45bc-8353-7906ae125557",
        )
        task.variables = {"messageId": serialize_variable("Document created!")}
        task.save()

        m.post("https://camunda.example.com/engine-rest/message")
        m.get(
            f"https://camunda.example.com/engine-rest/history/external-task-log/{task.task_id}",
            json={"process_instance_id": "some-instance-id"},
        )

        on_document_created(task, "http://example.com/doc/doc-uuid")

        self.assertEqual(m.call_count, 2)
        self.assertEqual(m.last_request.method, "POST")
        self.assertEqual(
            m.last_request.json(),
            {
                "messageName": "Document created!",
                "processInstanceId": "some-instance-id",
                "processVariables": {
                    "url": {
                        "type": "String",
                        "value": "http://example.com/doc/doc-uuid",
                    }
                },
            },
        )
    def setUpTestData(cls):
        super().setUpTestData()

        mapping = TaskMapping.objects.create(topic_name="some-topic", )

        cls.service = Service.objects.create(
            label="Kownsl",
            api_type=APITypes.orc,
            api_root=KOWNSL_API_ROOT,
            auth_type=AuthTypes.api_key,
            header_key="Authorization",
            header_value="Token foobarbaz",
            oas=f"{KOWNSL_API_ROOT}schema/openapi.yaml",
        )

        DefaultServiceFactory.create(
            task_mapping=mapping,
            service=cls.service,
            alias="kownsl",
        )

        cls.task_dict = {
            "topic_name": "some-topic",
            "worker_id": "test-worker-id",
            "task_id": "test-task-id",
            "variables": {
                "kownslReviewRequestId": serialize_variable("1"),
            },
        }
    def test_get_review_request_reminder_date(self, m):
        mock_service_oas_get(m, KOWNSL_API_ROOT, "kownsl")
        rr_response = {
            "id": "1",
            "forZaak": "https://zaken.nl/api/v1/zaak/123",
            "reviewType": "advice",
            "userDeadlines": {
                "user:zeus": "2020-04-20",
                "user:poseidon": "2020-04-20",
                "user:hades": "2020-04-20",
                "user:hera": "2021-04-20",
                "user:demeter": "2021-04-20",
            },
        }
        m.get(
            f"{KOWNSL_API_ROOT}api/v1/review-requests/1",
            json=rr_response,
        )

        task_dict = copy.deepcopy(self.task_dict)
        task_dict["variables"]["kownslUsers"] = serialize_variable(
            ["user:zeus", "user:poseidon", "user:hades"])

        task = ExternalTask.objects.create(**task_dict, )

        reminderDate = get_review_request_reminder_date(task)
        self.assertEqual(reminderDate["reminderDate"], "2020-04-19")
    def test_create_zaak_cant_find_valid_zaaktype(self, m):
        mock_service_oas_get(m, ZTC_URL, "ztc")
        self.fetched_task.variables["zaaktype"] = serialize_variable("")
        self.fetched_task.variables["catalogusDomein"] = serialize_variable(
            "ABR")
        self.fetched_task.variables[
            "zaaktypeIdentificatie"] = serialize_variable("abcd")
        self.fetched_task.save()
        task = CreateZaakTask(self.fetched_task)

        catalogus = generate_oas_component(
            "ztc",
            "schemas/Catalogus",
            url=CATALOGUS,
        )
        m.get(
            f"{ZTC_URL}catalogussen?domein=ABR&rsin=002220647",
            status_code=200,
            json={
                "count": 1,
                "next": None,
                "previous": None,
                "results": [catalogus]
            },
        )
        zaaktype_1 = generate_oas_component("ztc",
                                            "schemas/ZaakType",
                                            beginGeldigheid="2021-08-05")
        zaaktype_2 = generate_oas_component("ztc",
                                            "schemas/ZaakType",
                                            beginGeldigheid="2021-08-03")
        m.get(
            f"{ZTC_URL}zaaktypen?catalogus=https%3A%2F%2Fsome.ztc.nl%2Fapi%2Fv1%2F%2Fcatalogussen%2F7022a89e-0dd1-4074-9c3a-1a990e6c18ab&identificatie=abcd",
            status_code=200,
            json={
                "count": 2,
                "next": None,
                "previous": None,
                "results": [zaaktype_1, zaaktype_2],
            },
        )
        with self.assertRaises(ValueError) as e:
            task.perform()
        self.assertEqual(
            e.exception.__str__(),
            "No zaaktype was found with catalogus https://some.ztc.nl/api/v1//catalogussen/7022a89e-0dd1-4074-9c3a-1a990e6c18ab, identificatie abcd with begin_geldigheid <= 2021-08-02 <= einde_geldigheid.",
        )
    def test_start_template_with_missing_document_properties(self, m):
        m.post(
            f"{XENTIAL_API_ROOT}auth/whoami",
            json={
                "user": {
                    "uuid": "a4664ccb-259e-4107-b800-d8e5a764b9dd",
                    "userName": "******",
                },
                "XSessionId": "f7f588eb-b7c9-4d23-babd-4a98a9326367",
            },
        )

        external_task = ExternalTask.objects.create(
            topic_name="xential-topic",
            worker_id="test-worker-id",
            task_id="test-task-id",
            variables={
                "bptlAppId":
                serialize_variable("some-app-id"),
                "templateUuid":
                serialize_variable("3e09b238-0617-47c1-8e6a-f6227b3d542e"),
                "interactive":
                serialize_variable("True"),
                "templateVariables":
                serialize_variable({
                    "textq1": "Answer1",
                    "dateq1": "31-12-20"
                }),
                "documentMetadata":
                serialize_variable({
                    "bronorganisatie":
                    "517439943",
                    "creatiedatum":
                    "01-01-2021",
                    "taal":
                    "eng",
                    "informatieobjecttype":
                    "http://openzaak.nl/catalogi/api/v1/informatieobjecttypen/06d3a135-bc20-4fce-9add-f69d8e585917",
                }),
            },
        )

        expected_error_message = (
            "The Documenten API expects the following properties to be provided: titel, auteur. "
            "Please add them to the documentMetadata process variable.")
        with self.assertRaisesMessage(MissingVariable, expected_error_message):
            start_xential_template(external_task)
    def test_no_create_rol_empty_omschrijving(self, m):
        self.fetched_task.variables["omschrijving"] = serialize_variable("")
        task = CreateRolTask(self.fetched_task)

        result = task.perform()

        self.assertIsNone(result)
        self.assertEqual(len(m.request_history), 0)
Exemple #27
0
 def test_get_user_details_from_usernames_email_notifications(self, m):
     zac_mock_data = {
         "count":
         1,
         "results": [
             {
                 "id": "3",
                 "username": "******",
                 "firstName": "Loki",
                 "lastName": "Laufeyson",
                 "email": "*****@*****.**",
                 "isLiar": "true",
             },
         ],
     }
     m.get(ZAC_USERS_URL, json=zac_mock_data)
     task_notifications = {
         "topic_name": "send-email",
         "worker_id": "test-worker-id",
         "task_id": "test-task-id",
         "variables": {
             "usernames":
             serialize_variable(["user:thor", "user:loki"]),
             "emailNotificationList":
             serialize_variable({
                 "user:thor": False,
                 "user:loki": True
             }),
         },
     }
     task_notifications = ExternalTask.objects.create(
         **task_notifications, )
     task = UserDetailsTask(task_notifications)
     response = task.get_client_response()
     expected_response = [{
         "id": "3",
         "username": "******",
         "firstName": "Loki",
         "lastName": "Laufeyson",
         "email": "*****@*****.**",
         "isLiar": "true",
         "assignee": "user:loki",
     }]
     self.assertEqual(response, expected_response)
     self.assertEqual(m.last_request.url,
                      f"{ZAC_USERS_URL}?include_username=loki")
Exemple #28
0
 def test_get_user_details_from_groups_with_email_notifications(self, m):
     zac_mock_data_group = {
         "count":
         1,
         "results": [
             {
                 "id": "1",
                 "username": "******",
                 "firstName": "",
                 "lastName": "Odinson",
                 "email": "*****@*****.**",
                 "isAwesome": "true",
             },
         ],
     }
     m.get(ZAC_USERS_URL, json=zac_mock_data_group)
     task = {
         "topic_name": "send-email",
         "worker_id": "test-worker-id",
         "task_id": "test-task-id",
         "variables": {
             "usernames":
             serialize_variable(["group:norse-gods", "user:loki"]),
             "emailNotificationList":
             serialize_variable({
                 "user:thor": False,
                 "group:norse-gods": True
             }),
         },
     }
     task = ExternalTask.objects.create(**task, )
     task = UserDetailsTask(task)
     response = task.get_client_response()
     expected_response = [{
         "id": "1",
         "username": "******",
         "firstName": "",
         "lastName": "Odinson",
         "email": "*****@*****.**",
         "isAwesome": "true",
         "assignee": "group:norse-gods",
     }]
     self.assertEqual(response, expected_response)
     self.assertEqual(m.last_request.url,
                      f"{ZAC_USERS_URL}?include_groups=norse-gods")
    def test_relateer_zaak_no_hoofdzaak(self, m):
        self.fetched_task.variables["hoofdZaakUrl"] = serialize_variable("")
        self.fetched_task.save()
        task = RelateerZaak(self.fetched_task)

        result = task.perform()

        self.assertIsNone(result)
        self.assertEqual(len(m.request_history), 0)
Exemple #30
0
    def test_no_default_services(self):
        variant_variables = {
            "old": {"services": serialize_variable({"ZRC": {"jwt": "Bearer 12345"}})},
            "new": {"bptlAppId": serialize_variable("some-app-id")},
        }

        for variant, variables in variant_variables.items():
            with self.subTest(variant=variant):
                self.task.variables = variables
                self.task.save()

                with self.assertRaises(NoService) as exc:
                    self.work_unit.get_client(APITypes.zrc)

                self.assertEqual(
                    str(exc.exception),
                    "No zrc service is configured for topic 'some-topic'",
                )