Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arkindex
Backend
Commits
292aae37
Commit
292aae37
authored
4 years ago
by
Eva Bardou
Browse files
Options
Downloads
Patches
Plain Diff
Add IsVerifiedOrReadOnly permission on EntityDetails class
parent
fb55e78b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1160
Add IsVerifiedOrReadOnly permission on EntityDetails class
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
arkindex/documents/api/entities.py
+2
-1
2 additions, 1 deletion
arkindex/documents/api/entities.py
arkindex/documents/tests/test_entities_api.py
+30
-3
30 additions, 3 deletions
arkindex/documents/tests/test_entities_api.py
with
32 additions
and
4 deletions
arkindex/documents/api/entities.py
+
2
−
1
View file @
292aae37
...
...
@@ -38,7 +38,7 @@ from arkindex.documents.serializers.entities import (
)
from
arkindex.project.elastic
import
ESEntity
from
arkindex.project.mixins
import
ACLMixin
,
CorpusACLMixin
from
arkindex.project.permissions
import
IsVerified
from
arkindex.project.permissions
import
IsVerified
,
IsVerifiedOrReadOnly
from
arkindex.project.triggers
import
reindex_start
from
arkindex.users.models
import
Role
...
...
@@ -79,6 +79,7 @@ class EntityDetails(ACLMixin, RetrieveUpdateDestroyAPIView):
"""
Get all information about an entity
"""
permission_classes
=
(
IsVerifiedOrReadOnly
,
)
serializer_class
=
EntitySerializer
openapi_overrides
=
{
'
tags
'
:
[
'
entities
'
],
...
...
This diff is collapsed.
Click to expand it.
arkindex/documents/tests/test_entities_api.py
+
30
−
3
View file @
292aae37
...
...
@@ -745,7 +745,14 @@ class TestEntitiesAPI(FixtureAPITestCase):
Entity
.
objects
.
get
(
id
=
self
.
entity
.
id
)
self
.
assertFalse
(
entity_mock
.
get
.
called
)
def
test_delete_entity_not_verified
(
self
):
def
test_delete_entity_requires_login
(
self
):
response
=
self
.
client
.
delete
(
reverse
(
'
api:entity-details
'
,
kwargs
=
{
'
pk
'
:
str
(
self
.
entity_bis
.
id
)}))
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_403_FORBIDDEN
)
def
test_delete_entity_requires_verified
(
self
):
self
.
user
.
verified_email
=
False
self
.
user
.
save
()
self
.
client
.
force_login
(
self
.
user
)
response
=
self
.
client
.
delete
(
reverse
(
'
api:entity-details
'
,
kwargs
=
{
'
pk
'
:
str
(
self
.
entity_bis
.
id
)}))
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_403_FORBIDDEN
)
...
...
@@ -797,14 +804,34 @@ class TestEntitiesAPI(FixtureAPITestCase):
description
=
f
'
Indexation of entity
{
self
.
entity_bis
.
id
}
'
,
))
def
test_validated_entity_not_verified
(
self
):
def
test_validated_entity_requires_login
(
self
):
response
=
self
.
client
.
patch
(
reverse
(
'
api:entity-details
'
,
kwargs
=
{
'
pk
'
:
self
.
entity_bis
.
id
}),
{
'
validated
'
:
True
},
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_403_FORBIDDEN
)
def
test_unvalidated_entity_requires_login
(
self
):
response
=
self
.
client
.
patch
(
reverse
(
'
api:entity-details
'
,
kwargs
=
{
'
pk
'
:
self
.
entity_bis
.
id
}),
{
'
validated
'
:
False
},
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_403_FORBIDDEN
)
def
test_validated_entity_requires_verified
(
self
):
self
.
user
.
verified_email
=
False
self
.
user
.
save
()
self
.
client
.
force_login
(
self
.
user
)
response
=
self
.
client
.
patch
(
reverse
(
'
api:entity-details
'
,
kwargs
=
{
'
pk
'
:
self
.
entity_bis
.
id
}),
{
'
validated
'
:
True
},
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_403_FORBIDDEN
)
def
test_unvalidated_entity_not_verified
(
self
):
def
test_unvalidated_entity_requires_verified
(
self
):
self
.
user
.
verified_email
=
False
self
.
user
.
save
()
self
.
client
.
force_login
(
self
.
user
)
response
=
self
.
client
.
patch
(
reverse
(
'
api:entity-details
'
,
kwargs
=
{
'
pk
'
:
self
.
entity_bis
.
id
}),
{
'
validated
'
:
False
},
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment