Skip to content

Commit

Permalink
feat: Add 'documenten.lezen' and 'zaken.lezen' scopes (#179)
Browse files Browse the repository at this point in the history
* feat: Add 'documenten.lezen' and 'zaken.lezen' scopes

This commit introduces two new scopes, 'documenten.lezen' and 'zaken.lezen', to the catalogi-api. These scopes inherit the same permissions as the existing 'catalogi.lezen' scope. The addition of these scopes is necessary to accommodate the new expand model, which involves requesting information from the catalogi-api through the documenten-api and zaken-api.

Issue #2262
  • Loading branch information
MatthijsBekendam authored Aug 22, 2023
1 parent a62a60a commit 982f5c8
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 6 deletions.
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

0 comments on commit 982f5c8

Please sign in to comment.