Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Metagenomics
metagenedb
Commits
4947602d
Commit
4947602d
authored
Jun 27, 2019
by
Kenzo-Hugo Hillion
♻
Browse files
Make permissions for any for the moment and fix tests
parent
bb3cf668
Pipeline
#12858
passed with stage
in 1 minute and 5 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
backend/metagenedb/apps/catalog/views/gene.py
View file @
4947602d
from
rest_framework
import
status
from
rest_framework.decorators
import
api_view
from
rest_framework.decorators
import
(
api_view
,
authentication_classes
,
permission_classes
)
from
rest_framework.response
import
Response
from
django.core.paginator
import
Paginator
,
EmptyPage
,
PageNotAnInteger
...
...
@@ -8,6 +12,8 @@ from metagenedb.apps.catalog.serializers import GeneSerializer
@
api_view
([
'GET'
])
@
authentication_classes
(())
@
permission_classes
(())
def
gene_list
(
request
):
"""
List genes
...
...
backend/metagenedb/apps/catalog/
model
s/test_
views
.py
→
backend/metagenedb/apps/catalog/
view
s/test_
gene
.py
View file @
4947602d
...
...
@@ -11,15 +11,15 @@ class TestGenes(TestCase):
def
test_get_genes_no_auth
(
self
):
"""
Unauthenticated users should
not
be able to access genes
via APIListView
Unauthenticated users should be able to access genes
"""
url
=
reverse
(
'genes'
)
resp
=
self
.
client
.
get
(
url
)
self
.
assertEqual
(
resp
.
status_code
,
status
.
HTTP_
401_UNAUTHORIZED
)
self
.
assertEqual
(
resp
.
status_code
,
status
.
HTTP_
200_OK
)
def
test_get_genes_auth
(
self
):
"""
Authenticated users should be able to access genes
via APIListView
Authenticated users should be able to access genes
"""
jwt_payload_handler
=
api_settings
.
JWT_PAYLOAD_HANDLER
...
...
backend/metagenedb/settings/django.py
View file @
4947602d
...
...
@@ -98,11 +98,11 @@ CORS_ORIGIN_WHITELIST = (
REST_FRAMEWORK
=
{
'DEFAULT_PERMISSION_CLASSES'
:
(
#
'rest_framework.permissions.
IsAuthenticated
',
'rest_framework.permissions.
AllowAny
'
,
),
'DEFAULT_AUTHENTICATION_CLASSES'
:
(
#
'rest_framework_jwt.authentication.JSONWebTokenAuthentication',
#
'rest_framework.authentication.SessionAuthentication',
'rest_framework_jwt.authentication.JSONWebTokenAuthentication'
,
'rest_framework.authentication.SessionAuthentication'
,
# 'rest_framework.authentication.BasicAuthentication',
),
}
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment