示例#1
0
    def test_update_authorization_incorrect(self):
        url = get_operation_url('applicatie_partial_update',
                                uuid=self.applicatie.uuid)

        response = self.client.patch(url, {'heeftAlleAutorisaties': True})

        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)

        error = get_validation_errors(response, 'nonFieldErrors')
        self.assertEqual(error['code'], 'ambiguous-authorizations-specified')
示例#2
0
    def test_validate_unknown_query_params(self):
        GebruiksrechtenFactory.create_batch(2)
        url = get_operation_url("gebruiksrechten_list")

        response = self.client.get(url, {"someparam": "somevalue"})

        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)

        error = get_validation_errors(response, "nonFieldErrors")
        self.assertEqual(error["code"], "unknown-parameters")
    def test_is_eindstatus(self):
        zaaktype = ZaakTypeFactory.create()

        rol_type = RolTypeFactory.create(zaaktype=zaaktype)

        status_type_1 = StatusTypeFactory.create(zaaktype=zaaktype,
                                                 roltypen=[
                                                     rol_type,
                                                 ],
                                                 statustypevolgnummer=1)
        status_type_2 = StatusTypeFactory.create(zaaktype=zaaktype,
                                                 roltypen=[
                                                     rol_type,
                                                 ],
                                                 statustypevolgnummer=2)

        # Volgnummer 1
        url = get_operation_url(
            'statustype_read',
            catalogus_uuid=zaaktype.catalogus.uuid,
            zaaktype_uuid=zaaktype.uuid,
            uuid=status_type_1.uuid,
        )

        response = self.client.get(url)

        self.assertEqual(response.status_code, status.HTTP_200_OK)
        response_data = response.json()

        self.assertFalse(response_data['isEindstatus'])

        # Volgnummer 2
        url = get_operation_url('statustype_read',
                                catalogus_uuid=zaaktype.catalogus.uuid,
                                zaaktype_uuid=zaaktype.uuid,
                                uuid=status_type_2.uuid)

        response = self.client.get(url)

        self.assertEqual(response.status_code, status.HTTP_200_OK)
        response_data = response.json()

        self.assertTrue(response_data['isEindstatus'])
    def test_delete_informatieobjecttype(self):
        informatieobjecttype = InformatieObjectTypeFactory.create()
        informatieobjecttypee_url = get_operation_url(
            "informatieobjecttype_read", uuid=informatieobjecttype.uuid)

        response = self.client.delete(informatieobjecttypee_url)

        self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
        self.assertFalse(
            InformatieObjectType.objects.filter(id=informatieobjecttype.id))
示例#5
0
    def test_list_page(self):
        KlantContactFactory.create_batch(2)
        url = get_operation_url("klantcontact_list")

        response = self.client.get(url, {"page": 1}, HTTP_HOST="testserver.com")

        self.assertEqual(response.status_code, status.HTTP_200_OK)

        data = response.json()["results"]
        self.assertEqual(len(data), 2)
    def test_filter_informatieobjecttype_status_definitief(self):
        informatieobjecttype1 = InformatieObjectTypeFactory.create(
            concept=True)
        informatieobjecttype2 = InformatieObjectTypeFactory.create(
            concept=False)
        informatieobjecttype_list_url = get_operation_url(
            "informatieobjecttype_list")
        informatieobjecttype2_url = get_operation_url(
            "informatieobjecttype_read", uuid=informatieobjecttype2.uuid)

        response = self.client.get(informatieobjecttype_list_url,
                                   {"status": "definitief"})
        self.assertEqual(response.status_code, 200)

        data = response.json()["results"]

        self.assertEqual(len(data), 1)
        self.assertEqual(data[0]["url"],
                         f"http://testserver{informatieobjecttype2_url}")
    def test_lock_fail_locked_doc(self):
        eio = EnkelvoudigInformatieObjectCanonicalFactory.create(lock=uuid.uuid4().hex)

        url = get_operation_url('enkelvoudiginformatieobject_lock', uuid=eio.latest_version.uuid)
        response = self.client.post(url)

        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST, response.data)

        error = get_validation_errors(response, 'nonFieldErrors')
        self.assertEqual(error['code'], 'existing-lock')
    def test_validate_unknown_query_params(self):
        EnkelvoudigInformatieObjectFactory.create_batch(2)
        url = get_operation_url("enkelvoudiginformatieobject_list")

        response = self.client.get(url, {"someparam": "somevalue"})

        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)

        error = get_validation_errors(response, "nonFieldErrors")
        self.assertEqual(error["code"], "unknown-parameters")
    def test_can_set_archiefactiedatum(self):
        zaak = ZaakFactory.create()
        zaak_patch_url = get_operation_url('zaak_partial_update',
                                           uuid=zaak.uuid)

        data = {'archiefactiedatum': date(2019, 1, 1)}

        response = self.client.patch(zaak_patch_url, data, **ZAAK_WRITE_KWARGS)
        self.assertEqual(response.status_code, status.HTTP_200_OK,
                         response.data)
示例#10
0
    def test_unknown_query_params_give_error(self):
        BesluitTypeFactory.create_batch(2)
        besluittype_list_url = get_operation_url("besluittype_list")

        response = self.client.get(besluittype_list_url, {"someparam": "somevalue"})

        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)

        error = get_validation_errors(response, "nonFieldErrors")
        self.assertEqual(error["code"], "unknown-parameters")
    def test_add_resultaat_on_zaak_with_zaakobject_causes_archiefactiedatum_to_be_set(
            self):
        """
        Add RESULTAAT that causes `archiefactiedatum` to be set.
        """
        zaak = ZaakFactory.create()
        zaak_url = get_operation_url('zaak_read', uuid=zaak.uuid)

        zaak_object = ZaakObjectFactory.create(zaak=zaak)

        resultaat_create_url = get_operation_url('resultaat_create')
        data = {
            'zaak': zaak_url,
            'resultaatType': RESULTAATTYPE,
            'toelichting': '',
        }

        responses = {
            zaak_object.object: {
                'einddatum': isodatetime(2019, 1, 1)
            },
            RESULTAATTYPE: {
                'url': RESULTAATTYPE,
                'archiefactietermijn': 'P10Y',
                'archiefnominatie': Archiefnominatie.blijvend_bewaren,
                'brondatumArchiefprocedure': {
                    'afleidingswijze':
                    BrondatumArchiefprocedureAfleidingswijze.zaakobject,
                    'datumkenmerk': 'einddatum',
                    'objecttype': zaak_object.object_type,
                    'procestermijn': None,
                }
            }
        }

        with mock_client(responses):
            response = self.client.post(resultaat_create_url, data)

        self.assertEqual(response.status_code, status.HTTP_201_CREATED,
                         response.data)

        zaak.refresh_from_db()
        self.assertEqual(zaak.archiefactiedatum, date(2029, 1, 1))
示例#12
0
    def test_read_rol_np(self):
        zaak = ZaakFactory.create()
        rol = RolFactory.create(
            zaak=zaak,
            betrokkene_type=RolTypes.natuurlijk_persoon,
            betrokkene=
            'http://www.zamora-silva.org/api/betrokkene/8768c581-2817-4fe5-933d-37af92d819dd',
            rolomschrijving='Beslisser')
        NatuurlijkPersoon.objects.create(
            rol=rol,
            nummer_ander_natuurlijk_persoon='12345',
        )
        zaak_url = get_operation_url('zaak_read', uuid=zaak.uuid)
        url = get_operation_url('rol_read', uuid=rol.uuid)

        response = self.client.get(url)

        self.assertEqual(response.status_code, status.HTTP_200_OK)

        data = response.json()

        self.assertEqual(
            data, {
                'url': f'http://testserver{url}',
                'zaak': f'http://testserver{zaak_url}',
                'betrokkene': BETROKKENE,
                'betrokkeneType': RolTypes.natuurlijk_persoon,
                'rolomschrijving': 'Beslisser',
                'roltoelichting': '',
                'betrokkeneIdentificatie': {
                    'burgerservicenummer': '',
                    'nummerAnderNatuurlijkPersoon': '12345',
                    'aNummer': '',
                    'geslachtsnaam': '',
                    'voorvoegselGeslachtsnaam': '',
                    'voorletters': '',
                    'voornamen': '',
                    'geslachtsaanduiding': '',
                    'geboortedatum': '',
                    'verblijfsadres': '',
                    'subVerblijfBuitenland': ''
                }
            })
示例#13
0
 def registreer_klantcontact(self):
     url = get_operation_url("klantcontact_create")
     self.client.post(
         url,
         {
             "zaak": self.references["zaak_url"],
             "datumtijd": self.data["datetime"],
             "kanaal": self.data["source"],
         },
     )
示例#14
0
    def test_zet_behandelaar(self, *mocks):
        zaak = ZaakFactory.create(zaaktype=ZAAKTYPE)
        zaak_url = get_operation_url("zaak_read", uuid=zaak.uuid)
        url = get_operation_url("rol_create")

        with requests_mock.Mocker() as m:
            m.get(ROLTYPE, json=ROLTYPE_RESPONSE)

            with mock_client({ROLTYPE: ROLTYPE_RESPONSE}):
                response = self.client.post(
                    url,
                    {
                        "zaak": zaak_url,
                        "betrokkene": WATERNET,
                        "betrokkeneType": RolTypes.organisatorische_eenheid,
                        "roltype": ROLTYPE,
                        "roltoelichting": "Verantwoordelijke behandelaar voor de melding",
                    },
                )

        self.assertEqual(response.status_code, status.HTTP_201_CREATED, response.json())

        response_data = response.json()

        self.assertIn("url", response_data)
        del response_data["url"]
        del response_data["uuid"]
        self.assertEqual(
            response_data,
            {
                "zaak": f"http://testserver{zaak_url}",
                "betrokkene": WATERNET,
                "betrokkeneType": RolTypes.organisatorische_eenheid,
                "roltype": ROLTYPE,
                "omschrijving": RolOmschrijving.behandelaar,
                "omschrijvingGeneriek": RolOmschrijving.behandelaar,
                "roltoelichting": "Verantwoordelijke behandelaar voor de melding",
                "registratiedatum": "2018-01-01T00:00:00Z",
                "indicatieMachtiging": "",
                "betrokkeneIdentificatie": None,
            },
        )
    def test_validate_unknown_query_params(self):
        ZaakObjectFactory.create_batch(2,
                                       object="http://example.com/objects/1")
        url = get_operation_url("zaakobject_list")

        response = self.client.get(url, {"someparam": "somevalue"})

        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)

        error = get_validation_errors(response, "nonFieldErrors")
        self.assertEqual(error["code"], "unknown-parameters")
示例#16
0
    def test_filter_zaaktype_status_alles(self):
        ZaakTypeFactory.create(concept=True)
        ZaakTypeFactory.create(concept=False)
        zaaktype_list_url = get_operation_url('zaaktype_list')

        response = self.client.get(zaaktype_list_url, {'status': 'alles'})
        self.assertEqual(response.status_code, 200)

        data = response.json()['results']

        self.assertEqual(len(data), 2)
示例#17
0
    def test_deprecated(self):
        url = get_operation_url("klantcontact_list")

        response = self.client.get(url)

        self.assertIn("Warning", response)
        msg = (
            "Deze endpoint is verouderd en zal binnenkort uit dienst worden genomen. "
            "Maak gebruik van de vervangende contactmomenten API."
        )
        self.assertEqual(response["Warning"], f'299 "http://testserver{url}" "{msg}"')
示例#18
0
    def test_list_file(self):
        self.autorisatie.scopes = [SCOPE_DOCUMENTEN_ALLES_LEZEN]
        self.autorisatie.save()

        eio = EnkelvoudigInformatieObjectCanonicalFactory.create(
            latest_version__informatieobjecttype=INFORMATIEOBJECTTYPE
        )
        list_url = get_operation_url('enkelvoudiginformatieobject_list')

        response = self.client.get(list_url)

        self.assertEqual(response.status_code, status.HTTP_200_OK)

        data = response.data['results']
        download_url = urlparse(data[0]['inhoud'])

        self.assertEqual(
            download_url.path,
            get_operation_url('enkelvoudiginformatieobject_download', uuid=eio.latest_version.uuid)
        )
    def test_read(self):
        test_object = EnkelvoudigInformatieObjectFactory.create(
            informatieobjecttype=INFORMATIEOBJECTTYPE
        )

        # Retrieve from the API
        detail_url = reverse(
            "enkelvoudiginformatieobject-detail",
            kwargs={"version": "1", "uuid": test_object.uuid},
        )

        response = self.client.get(detail_url)

        # Test response
        self.assertEqual(response.status_code, status.HTTP_200_OK)

        file_url = get_operation_url(
            "enkelvoudiginformatieobject_download", uuid=test_object.uuid
        )
        expected = {
            "url": f"http://testserver{detail_url}",
            "identificatie": test_object.identificatie,
            "bronorganisatie": test_object.bronorganisatie,
            "creatiedatum": "2018-06-27",
            "titel": "some titel",
            "auteur": "some auteur",
            "status": "",
            "formaat": "some formaat",
            "taal": "nld",
            "beginRegistratie": test_object.begin_registratie.isoformat().replace(
                "+00:00", "Z"
            ),
            "versie": 1,
            "bestandsnaam": "",
            "inhoud": f"http://testserver{file_url}?versie=1",
            "bestandsomvang": test_object.inhoud.size,
            "link": "",
            "beschrijving": "",
            "ontvangstdatum": None,
            "verzenddatum": None,
            "ondertekening": {"soort": "", "datum": None},
            "indicatieGebruiksrecht": None,
            "vertrouwelijkheidaanduiding": "openbaar",
            "integriteit": {"algoritme": "", "waarde": "", "datum": None},
            "informatieobjecttype": INFORMATIEOBJECTTYPE,
            "locked": False,
            "bestandsdelen": [],
        }
        response_data = response.json()
        self.assertEqual(sorted(response_data.keys()), sorted(expected.keys()))

        for key in response_data.keys():
            with self.subTest(field=key):
                self.assertEqual(response_data[key], expected[key])
示例#20
0
    def test_read_detail_file(self):
        self.autorisatie.scopes = [SCOPE_DOCUMENTEN_ALLES_LEZEN]
        self.autorisatie.save()

        eio = EnkelvoudigInformatieObjectFactory.create(informatieobjecttype=INFORMATIEOBJECTTYPE)
        file_url = get_operation_url('enkelvoudiginformatieobject_download', uuid=eio.uuid)

        response = self.client.get(file_url)

        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.content.decode("utf-8"), 'some data')
    def test_eio_download_with_accept_application_octet_stream_header(self):
        eio = EnkelvoudigInformatieObjectFactory.create(
            beschrijving="beschrijving1", inhoud__data=b"inhoud1"
        )

        eio_url = get_operation_url(
            "enkelvoudiginformatieobject_download", uuid=eio.uuid
        )

        response = self.client.get(eio_url, HTTP_ACCEPT="application/octet-stream")
        self.assertEqual(response.status_code, status.HTTP_200_OK)
    def test_abonnement_destroy(self):
        """
        test /abonnementen DELETE:
        check if destroy action is supported
        """
        abonnement = AbonnementFactory.create(client_id="testsuite")
        abonnement_url = get_operation_url("abonnement_read", uuid=abonnement.uuid)

        response = self.client.delete(abonnement_url)

        self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
示例#23
0
    def test_delete_zaaktype_fail_not_concept(self):
        zaaktype = ZaakTypeFactory.create(concept=False)
        zaaktype_url = get_operation_url('zaaktype_read', uuid=zaaktype.uuid)

        response = self.client.delete(zaaktype_url)

        self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)

        data = response.json()
        self.assertEqual(data['detail'],
                         'Alleen concepten kunnen worden verwijderd.')
    def test_filter_informatieobjecttype_status_alles(self):
        InformatieObjectTypeFactory.create(concept=True)
        InformatieObjectTypeFactory.create(concept=False)
        informatieobjecttype_list_url = get_operation_url('informatieobjecttype_list')

        response = self.client.get(informatieobjecttype_list_url, {'status': 'alles'})
        self.assertEqual(response.status_code, 200)

        data = response.json()['results']

        self.assertEqual(len(data), 2)
    def test_publish_informatieobjecttype(self):
        informatieobjecttype = InformatieObjectTypeFactory.create()
        informatieobjecttypee_url = get_operation_url('informatieobjecttype_publish', uuid=informatieobjecttype.uuid)

        response = self.client.post(informatieobjecttypee_url)

        self.assertEqual(response.status_code, status.HTTP_200_OK)

        informatieobjecttype.refresh_from_db()

        self.assertEqual(informatieobjecttype.concept, False)
示例#26
0
    def test_replace_authorizations(self):
        url = get_operation_url("applicatie_partial_update",
                                uuid=self.applicatie.uuid)
        data = {
            "autorisaties": [
                {
                    "component":
                    ComponentTypes.zrc,
                    "scopes":
                    ["zds.scopes.zaken.lezen", "zds.scopes.zaken.aanmaken"],
                    "maxVertrouwelijkheidaanduiding":
                    VertrouwelijkheidsAanduiding.beperkt_openbaar,
                    "zaaktype":
                    "https://ref.tst.vng.cloud/zrc/api/v1/catalogus/1/zaaktypen/1",
                },
                {
                    "component":
                    ComponentTypes.zrc,
                    "scopes": [
                        "zds.scopes.zaken.lezen",
                        "zds.scopes.zaken.aanmaken",
                        "zds.scopes.zaken.verwijderen",
                    ],
                    "zaaktype":
                    "https://ref.tst.vng.cloud/zrc/api/v1/catalogus/2/zaaktypen/1",
                    "maxVertrouwelijkheidaanduiding":
                    VertrouwelijkheidsAanduiding.zeer_geheim,
                },
            ]
        }

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

        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(self.applicatie.autorisaties.count(), 2)

        auth1, auth2 = self.applicatie.autorisaties.order_by("zaaktype").all()

        self.assertEqual(
            auth1.zaaktype,
            "https://ref.tst.vng.cloud/zrc/api/v1/catalogus/1/zaaktypen/1",
        )
        self.assertEqual(
            auth1.max_vertrouwelijkheidaanduiding,
            VertrouwelijkheidsAanduiding.beperkt_openbaar,
        )
        self.assertEqual(
            auth2.zaaktype,
            "https://ref.tst.vng.cloud/zrc/api/v1/catalogus/2/zaaktypen/1",
        )
        self.assertEqual(
            auth2.max_vertrouwelijkheidaanduiding,
            VertrouwelijkheidsAanduiding.zeer_geheim,
        )
示例#27
0
    def test_update_client_ids(self):
        url = get_operation_url("applicatie_partial_update",
                                uuid=self.applicatie.uuid)

        response = self.client.patch(url, {"client_ids": ["id1"]})

        self.assertEqual(response.status_code, status.HTTP_200_OK,
                         response.data)

        self.applicatie.refresh_from_db()
        self.assertEqual(self.applicatie.client_ids, ["id1"])
    def test_cannot_set_archiefstatus_without_archiefnominatie_and_archiefactiedatum(
            self):
        zaak = ZaakFactory.create(zaaktype=ZAAKTYPE)
        zaak_patch_url = get_operation_url('zaak_partial_update',
                                           uuid=zaak.uuid)

        data = {'archiefstatus': Archiefstatus.gearchiveerd}

        response = self.client.patch(zaak_patch_url, data, **ZAAK_WRITE_KWARGS)
        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST,
                         response.data)
    def test_add_resultaat_on_zaak_with_ander_datumkenmerk_causes_archiefactiedatum_to_remain_empty(
            self):
        """
        Add RESULTAAT that causes `archiefactiedatum` to remain empty. It needs to be manually set based on the
        information in the RESULTAATTYPE.
        """
        zaak = ZaakFactory.create()
        zaak_url = get_operation_url('zaak_read', uuid=zaak.uuid)

        resultaat_create_url = get_operation_url('resultaat_create')
        data = {
            'zaak': zaak_url,
            'resultaatType': RESULTAATTYPE,
            'toelichting': '',
        }

        responses = {
            RESULTAATTYPE: {
                'url': RESULTAATTYPE,
                'archiefactietermijn': 'P10Y',
                'archiefnominatie': Archiefnominatie.blijvend_bewaren,
                'brondatumArchiefprocedure': {
                    'afleidingswijze':
                    BrondatumArchiefprocedureAfleidingswijze.
                    ander_datumkenmerk,
                    'datumkenmerk': 'einddatum',
                    'registratie': 'LichtgevendeObjectenRegistratie',
                    'objecttype': 'Lantaarnpaal',
                    'procestermijn': None,
                }
            }
        }

        with mock_client(responses):
            response = self.client.post(resultaat_create_url, data)

        self.assertEqual(response.status_code, status.HTTP_201_CREATED,
                         response.data)

        zaak.refresh_from_db()
        self.assertIsNone(zaak.archiefactiedatum)
    def test_pagination_page_param(self):
        InformatieObjectTypeFactory.create_batch(2, concept=False)
        informatieobjecttype_list_url = get_operation_url('informatieobjecttype_list')

        response = self.client.get(informatieobjecttype_list_url, {'page': 1})

        self.assertEqual(response.status_code, status.HTTP_200_OK)

        response_data = response.json()
        self.assertEqual(response_data['count'], 2)
        self.assertIsNone(response_data['previous'])
        self.assertIsNone(response_data['next'])