Пример #1
0
    def test_zaaktype_notify_on_create(self, m):
        mock_oas_get(m)
        mock_resource_list(m, "procestypen")
        mock_nrc_oas_get(m)
        m.post("https://notificaties-api.vng.cloud/api/v1/notificaties",
               status_code=201)

        url = reverse("admin:catalogi_zaaktype_add")

        response = self.app.get(url)

        form = response.forms["zaaktype_form"]
        form["zaaktype_omschrijving"] = "test"
        form["doel"] = "test"
        form["aanleiding"] = "test"
        form["indicatie_intern_of_extern"].select("intern")
        form["handeling_initiator"] = "test"
        form["onderwerp"] = "test"
        form["handeling_behandelaar"] = "test"
        form["doorlooptijd_behandeling_days"] = 12
        form["opschorting_en_aanhouding_mogelijk"].select(False)
        form["verlenging_mogelijk"].select(False)
        form["vertrouwelijkheidaanduiding"].select("openbaar")
        form["producten_of_diensten"] = "https://example.com/foobarbaz"
        form["referentieproces_naam"] = "test"
        form["catalogus"] = self.catalogus.pk
        form["datum_begin_geldigheid"] = "21-11-2019"

        with capture_on_commit_callbacks(execute=True):
            form.submit("_save")

        called_urls = [item.url for item in m.request_history]
        self.assertIn("https://notificaties-api.vng.cloud/api/v1/notificaties",
                      called_urls)
Пример #2
0
    def test_new_zt_all_current_and_future_send_notifications(self, m):
        mock_nrc_oas_get(m)
        m.post("https://notificaties-api.vng.cloud/api/v1/notificaties",
               status_code=201)
        data = {
            # management form
            "form-TOTAL_FORMS":
            1,
            "form-INITIAL_FORMS":
            0,
            "form-MIN_NUM_FORMS":
            0,
            "form-MAX_NUM_FORMS":
            1000,
            "form-0-component":
            ComponentTypes.zrc,
            "form-0-scopes": ["zaken.lezen"],
            "form-0-related_type_selection":
            RelatedTypeSelectionMethods.all_current_and_future,
            "form-0-vertrouwelijkheidaanduiding":
            VertrouwelijkheidsAanduiding.beperkt_openbaar,
        }

        response = self.client.post(self.url, data)

        self.assertEqual(response.status_code, 302)
        self.assertFalse(Autorisatie.objects.exists())
        self.assertFalse(m.called)

        # create a ZaakType - this should trigger a new autorisatie being installed
        ZaakTypeFactory.create()
        self.assertEqual(self.applicatie.autorisaties.count(), 1)
        self.assertTrue(m.called)
Пример #3
0
    def test_zaaktype_no_notify_on_no_change(self, m):
        procestype_url = ("https://selectielijst.openzaak.nl/api/v1/"
                          "procestypen/e1b73b12-b2f6-4c4e-8929-94f84dd2a57d")
        mock_oas_get(m)
        mock_resource_list(m, "procestypen")
        mock_resource_get(m, "procestypen", procestype_url)
        mock_nrc_oas_get(m)
        m.post("https://notificaties-api.vng.cloud/api/v1/notificaties",
               status_code=201)

        zaaktype = ZaakTypeFactory.create(
            concept=True,
            zaaktype_omschrijving="test",
            vertrouwelijkheidaanduiding="openbaar",
            trefwoorden=["test"],
            verantwoordingsrelatie=["bla"],
            selectielijst_procestype=procestype_url,
        )
        url = reverse("admin:catalogi_zaaktype_change", args=(zaaktype.pk, ))

        response = self.app.get(url)
        form = response.forms["zaaktype_form"]

        with capture_on_commit_callbacks(execute=True):
            form.submit("_save")

        called_urls = [item.url for item in m.request_history]
        self.assertNotIn(
            "https://notificaties-api.vng.cloud/api/v1/notificaties",
            called_urls)
    def test_notification_body_current_and_future(self, m):
        mock_nrc_oas_get(m)
        m.post(
            "https://notificaties-api.vng.cloud/api/v1/notificaties", status_code=201
        )
        applicatie = ApplicatieFactory.create()
        AutorisatieSpecFactory.create(
            applicatie=applicatie,
            component=ComponentTypes.drc,
            scopes=["documenten.lezen"],
            max_vertrouwelijkheidaanduiding=VertrouwelijkheidsAanduiding.zeer_geheim,
        )
        InformatieObjectTypeFactory.create()

        self.assertTrue(m.called)
        body = m.last_request.json()
        del body["aanmaakdatum"]

        path = reverse(
            "applicatie-detail", kwargs={"version": 1, "uuid": applicatie.uuid}
        )
        expected = {
            "kanaal": "autorisaties",
            "hoofdObject": f"https://testserver{path}",
            "resource": "applicatie",
            "resourceUrl": f"https://testserver{path}",
            "actie": "update",
            "kenmerken": {},
        }
        self.assertEqual(body, expected)
    def test_changes_send_notifications(self, m):
        mock_nrc_oas_get(m)
        m.post(
            "https://notificaties-api.vng.cloud/api/v1/notificaties", status_code=201
        )
        zt = ZaakTypeFactory.create()
        Autorisatie.objects.create(
            applicatie=self.applicatie,
            component=ComponentTypes.zrc,
            scopes=["zaken.lezen"],
            zaaktype=f"http://testserver{zt.get_absolute_api_url()}",
            max_vertrouwelijkheidaanduiding=VertrouwelijkheidsAanduiding.beperkt_openbaar,
        )
        data = {
            # management form
            "form-TOTAL_FORMS": 1,
            "form-INITIAL_FORMS": 0,
            "form-MIN_NUM_FORMS": 0,
            "form-MAX_NUM_FORMS": 1000,
            "form-0-component": ComponentTypes.zrc,
            "form-0-scopes": ["zaken.lezen", "zaken.bijwerken"],  # modified
            "form-0-related_type_selection": RelatedTypeSelectionMethods.manual_select,
            "form-0-zaaktypen": [zt.id],
            "form-0-vertrouwelijkheidaanduiding": VertrouwelijkheidsAanduiding.beperkt_openbaar,
        }

        response = self.client.post(self.url, data)

        self.assertEqual(response.status_code, 302)
        self.assertTrue(m.called)
Пример #6
0
    def test_publish_zaaktype(self, m):
        procestype_url = ("https://selectielijst.openzaak.nl/api/v1/"
                          "procestypen/e1b73b12-b2f6-4c4e-8929-94f84dd2a57d")
        mock_oas_get(m)
        mock_resource_list(m, "procestypen")
        mock_resource_get(m, "procestypen", procestype_url)
        mock_nrc_oas_get(m)
        m.post("https://notificaties-api.vng.cloud/api/v1/notificaties",
               status_code=201)

        zaaktype = ZaakTypeFactory.create(
            concept=True,
            zaaktype_omschrijving="test",
            vertrouwelijkheidaanduiding="openbaar",
            trefwoorden=["test"],
            verantwoordingsrelatie=["bla"],
            selectielijst_procestype=procestype_url,
        )
        url = reverse("admin:catalogi_zaaktype_change", args=(zaaktype.pk, ))

        response = self.app.get(url)

        # Verify that the publish button is visible and enabled
        publish_button = response.html.find("input", {"name": "_publish"})
        self.assertIsNotNone(publish_button)
        publish_button = response.html.find("input", {
            "name": "_publish",
            "disabled": "disabled"
        })
        self.assertIsNone(publish_button)

        form = response.forms["zaaktype_form"]

        with capture_on_commit_callbacks(execute=True):
            response = form.submit("_publish").follow()

        zaaktype.refresh_from_db()
        self.assertFalse(zaaktype.concept)

        # Verify that the publish button is disabled
        publish_button = response.html.find("input", {
            "name": "_publish",
            "disabled": "disabled"
        })
        self.assertIsNotNone(publish_button)

        # Verify notification is sent
        called_urls = [item.url for item in m.request_history]
        self.assertIn("https://notificaties-api.vng.cloud/api/v1/notificaties",
                      called_urls)
Пример #7
0
    def test_besluit_no_notify_on_no_change(self, m):
        mock_nrc_oas_get(m)
        m.post("https://notificaties-api.vng.cloud/api/v1/notificaties",
               status_code=201)

        besluit = BesluitTypeFactory.create(concept=True, omschrijving="test")
        url = reverse("admin:catalogi_besluittype_change", args=(besluit.pk, ))

        response = self.app.get(url)
        form = response.forms["besluittype_form"]

        with capture_on_commit_callbacks(execute=True):
            form.submit("_save")

        self.assertFalse(m.called)
Пример #8
0
    def test_besluit_notify_on_change(self, m):
        mock_nrc_oas_get(m)
        m.post("https://notificaties-api.vng.cloud/api/v1/notificaties",
               status_code=201)

        besluit = BesluitTypeFactory.create(concept=True, omschrijving="test")
        url = reverse("admin:catalogi_besluittype_change", args=(besluit.pk, ))

        response = self.app.get(url)
        form = response.forms["besluittype_form"]
        form["omschrijving"] = "different-test"

        with capture_on_commit_callbacks(execute=True):
            form.submit("_save")

        called_urls = [item.url for item in m.request_history]
        self.assertIn("https://notificaties-api.vng.cloud/api/v1/notificaties",
                      called_urls)
Пример #9
0
    def test_no_informatieobjecttype_notify_on_no_change(self, m):
        mock_nrc_oas_get(m)
        m.post("https://notificaties-api.vng.cloud/api/v1/notificaties",
               status_code=201)

        informatieobjecttype = InformatieObjectTypeFactory.create(
            concept=True,
            omschrijving="test",
            vertrouwelijkheidaanduiding="openbaar")
        url = reverse(
            "admin:catalogi_informatieobjecttype_change",
            args=(informatieobjecttype.pk, ),
        )

        response = self.app.get(url)
        form = response.forms["informatieobjecttype_form"]

        with capture_on_commit_callbacks(execute=True):
            form.submit("_save")

        self.assertFalse(m.called)
Пример #10
0
    def test_informatieobjecttype_notify_on_create(self, m):
        mock_nrc_oas_get(m)
        m.post("https://notificaties-api.vng.cloud/api/v1/notificaties",
               status_code=201)

        url = reverse("admin:catalogi_informatieobjecttype_add")

        response = self.app.get(url)

        form = response.forms["informatieobjecttype_form"]
        form["omschrijving"] = "different-test"
        form["datum_begin_geldigheid"] = "2019-01-01"
        form["catalogus"] = self.catalogus.pk
        form["vertrouwelijkheidaanduiding"].select("openbaar")

        with capture_on_commit_callbacks(execute=True):
            form.submit("_save")

        called_urls = [item.url for item in m.request_history]
        self.assertIn("https://notificaties-api.vng.cloud/api/v1/notificaties",
                      called_urls)
Пример #11
0
    def test_create_new_version(self, m):
        mock_oas_get(m)
        mock_resource_list(m, "procestypen")
        mock_nrc_oas_get(m)
        m.post("https://notificaties-api.vng.cloud/api/v1/notificaties",
               status_code=201)

        zaaktype_old = ZaakTypeFactory.create(
            zaaktype_omschrijving="test",
            vertrouwelijkheidaanduiding="openbaar",
            trefwoorden=["test"],
            verantwoordingsrelatie=["bla"],
        )
        # reverse fk relations
        statustype_old = StatusTypeFactory.create(zaaktype=zaaktype_old)
        resultaattypeomschrijving = "https://example.com/resultaattypeomschrijving/1"
        m.register_uri("GET",
                       resultaattypeomschrijving,
                       json={"omschrijving": "init"})
        resultaattype_old = ResultaatTypeFactory.create(
            zaaktype=zaaktype_old,
            resultaattypeomschrijving=resultaattypeomschrijving)
        roltype_old = RolTypeFactory.create(zaaktype=zaaktype_old)
        eigenschap_old = EigenschapFactory.create(zaaktype=zaaktype_old)
        zaaktypenrelatie_old = ZaakTypenRelatieFactory.create(
            zaaktype=zaaktype_old)
        # m2m relations
        besluittype = BesluitTypeFactory.create(zaaktypen=[zaaktype_old])
        informatieobjecttype = ZaakTypeInformatieObjectTypeFactory.create(
            zaaktype=zaaktype_old).informatieobjecttype
        # not copied
        ZaakFactory.create(zaaktype=zaaktype_old)
        url = reverse("admin:catalogi_zaaktype_change",
                      args=(zaaktype_old.pk, ))

        get_response = self.app.get(url)

        form = get_response.form
        form["datum_einde_geldigheid"] = "2019-01-01"

        with capture_on_commit_callbacks(execute=True):
            post_response = form.submit("_addversion")

        zaaktype_old.refresh_from_db()

        self.assertEqual(zaaktype_old.datum_einde_geldigheid, date(2019, 1, 1))

        zaaktype_new = ZaakType.objects.exclude(pk=zaaktype_old.pk).get()

        # check that the new zaak has the same identificator
        self.assertEqual(zaaktype_new.identificatie,
                         zaaktype_old.identificatie)
        # check version dates
        self.assertEqual(zaaktype_new.datum_einde_geldigheid, None)
        self.assertEqual(zaaktype_new.datum_begin_geldigheid,
                         date(2019, 11, 1))
        self.assertEqual(zaaktype_new.versiedatum, date(2019, 11, 1))
        self.assertTrue(zaaktype_new.concept)
        # response redirect to correct page
        self.assertEqual(
            post_response.location,
            reverse("admin:catalogi_zaaktype_change",
                    args=(zaaktype_new.pk, )),
        )

        # assert the new relations are created
        self.assertNotEqual(zaaktype_new.statustypen.get().id,
                            statustype_old.id)
        self.assertNotEqual(zaaktype_new.resultaattypen.get().id,
                            resultaattype_old.id)
        self.assertNotEqual(zaaktype_new.roltype_set.get().id, roltype_old.id)
        self.assertNotEqual(zaaktype_new.eigenschap_set.get().id,
                            eigenschap_old.id)
        self.assertNotEqual(zaaktype_new.zaaktypenrelaties.get().id,
                            zaaktypenrelatie_old.id)
        # assert m2m relations are saved
        self.assertEqual(zaaktype_new.besluittypen.get().id, besluittype.id)
        self.assertEqual(zaaktype_new.informatieobjecttypen.get().id,
                         informatieobjecttype.id)
        # assert new zaken are not created
        self.assertEqual(zaaktype_new.zaak_set.count(), 0)

        # Verify notification is sent
        called_urls = [item.url for item in m.request_history]
        self.assertIn("https://notificaties-api.vng.cloud/api/v1/notificaties",
                      called_urls)