Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add 'documenten.lezen' and 'zaken.lezen' scopes #179

Merged
merged 2 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions requirements/base.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ python-dateutil
pytz
raven
markdown
pyyaml==6.0.1

Django~=3.2.0
django-axes
Expand Down
3 changes: 2 additions & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,9 @@ pytz==2022.1
# via
# -r requirements/base.in
# django
pyyaml==6.0
pyyaml==6.0.1
# via
# -r requirements/base.in
# drf-spectacular
# gemma-zds-client
# oyaml
Expand Down
2 changes: 1 addition & 1 deletion requirements/ci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ pytz==2022.1
# via
# -r requirements/base.txt
# django
pyyaml==6.0
pyyaml==6.0.1
# via
# -r requirements/base.txt
# drf-spectacular
Expand Down
2 changes: 1 addition & 1 deletion requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ pytz==2022.1
# via
# -r requirements/base.txt
# django
pyyaml==6.0
pyyaml==6.0.1
# via
# -r requirements/base.txt
# drf-spectacular
Expand Down
2 changes: 1 addition & 1 deletion requirements/production.txt
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ pytz==2022.1
# via
# -r requirements/base.txt
# django
pyyaml==6.0
pyyaml==6.0.1
# via
# -r requirements/base.txt
# drf-spectacular
Expand Down
18 changes: 18 additions & 0 deletions src/ztc/api/scopes.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,24 @@
""",
)

SCOPE_DOCUMENTEN_READ = Scope(
"documenten.lezen",
description="""
**Laat toe om**:

* leesoperaties uit te voeren vanaf de Documenten API. Alle resources zijn beschikbaar.
""",
)

SCOPE_ZAKEN_READ = Scope(
"zaken.lezen",
description="""
**Laat toe om**:

* leesoperaties uit te voeren vanaf de Zaken API. Alle resources zijn beschikbaar.
""",
)

SCOPE_CATALOGI_WRITE = Scope(
"catalogi.schrijven",
description="""
Expand Down
24 changes: 24 additions & 0 deletions src/ztc/api/tests/test_zaken.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
SCOPE_CATALOGI_FORCED_WRITE,
SCOPE_CATALOGI_READ,
SCOPE_CATALOGI_WRITE,
SCOPE_DOCUMENTEN_READ,
SCOPE_ZAKEN_READ,
)
from .base import APITestCase

Expand Down Expand Up @@ -1645,3 +1647,25 @@ def test_partial_update_non_concept_zaaktype(self):

zaaktype.refresh_from_db()
self.assertEqual(zaaktype.aanleiding, "aangepast")


class ZaakTypeExpandDocumentsScopeTests(APITestCase, JWTAuthMixin):
heeft_alle_autorisaties = False
scopes = [SCOPE_DOCUMENTEN_READ]

def test_get_list_default_definitief(self):
ZaakTypeAPITests.test_get_list_default_definitief(self)

def test_get_detail(self):
ZaakTypeAPITests.test_get_detail(self)


class ZaakTypeExpandZaakScopeTests(APITestCase, JWTAuthMixin):
heeft_alle_autorisaties = False
scopes = [SCOPE_ZAKEN_READ]

def test_get_list_default_definitief(self):
ZaakTypeAPITests.test_get_list_default_definitief(self)

def test_get_detail(self):
ZaakTypeAPITests.test_get_detail(self)
6 changes: 4 additions & 2 deletions src/ztc/api/views/zaken.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
SCOPE_CATALOGI_FORCED_WRITE,
SCOPE_CATALOGI_READ,
SCOPE_CATALOGI_WRITE,
SCOPE_DOCUMENTEN_READ,
SCOPE_ZAKEN_READ,
)
from ..serializers import (
ZaakTypeCreateSerializer,
Expand Down Expand Up @@ -112,8 +114,8 @@ class ZaakTypeViewSet(
lookup_field = "uuid"
filterset_class = ZaakTypeFilter
required_scopes = {
"list": SCOPE_CATALOGI_READ,
"retrieve": SCOPE_CATALOGI_READ,
"list": SCOPE_CATALOGI_READ | SCOPE_DOCUMENTEN_READ | SCOPE_ZAKEN_READ,
"retrieve": SCOPE_CATALOGI_READ | SCOPE_DOCUMENTEN_READ | SCOPE_ZAKEN_READ,
"create": SCOPE_CATALOGI_WRITE,
"update": SCOPE_CATALOGI_WRITE | SCOPE_CATALOGI_FORCED_WRITE,
"partial_update": SCOPE_CATALOGI_WRITE | SCOPE_CATALOGI_FORCED_WRITE,
Expand Down