This repository has been archived by the owner on Nov 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
35 changed files
with
81 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,4 +55,4 @@ jobs: | |
--env POSTGRES_PASSWORD=inspire | ||
--env POSTGRES_HOST=127.0.0.1 | ||
${{ inputs.image }} | ||
run pytest | ||
run pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,4 @@ repos: | |
rev: "3.9.2" | ||
hooks: | ||
- id: flake8 | ||
args: ["--config=backend/setup.cfg"] | ||
args: ["--config=.flake8"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
from django.contrib.auth.models import Group | ||
|
||
|
||
admin_group, created = Group.objects.get_or_create(name='admin') | ||
curator_group, created = Group.objects.get_or_create(name='curator') | ||
admin_group, created = Group.objects.get_or_create(name="admin") | ||
curator_group, created = Group.objects.get_or_create(name="curator") |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
from django.contrib.auth import get_user_model | ||
from django.contrib.auth.models import Group | ||
from django.test import TestCase | ||
from rest_framework.response import Response | ||
from rest_framework.test import APIRequestFactory, force_authenticate | ||
from rest_framework.views import APIView | ||
from rest_framework.response import Response | ||
from django.test import TestCase | ||
from management.permissions import IsAdminOrCuratorUser | ||
from django.contrib.auth import get_user_model | ||
|
||
from backoffice.management.permissions import IsAdminOrCuratorUser | ||
|
||
User = get_user_model() | ||
|
||
|
@@ -19,27 +19,27 @@ def get(self, request): | |
|
||
class PermissionCheckTests(TestCase): | ||
def setUp(self): | ||
self.user = User.objects.create_user(email='[email protected]', password='testpassword') | ||
self.admin_group, _ = Group.objects.get_or_create(name='admin') | ||
self.curator_group, _ = Group.objects.get_or_create(name='curator') | ||
self.user = User.objects.create_user(email="[email protected]", password="testpassword") | ||
|
||
self.admin_group, _ = Group.objects.get_or_create(name="admin") | ||
self.curator_group, _ = Group.objects.get_or_create(name="curator") | ||
|
||
def test_user_in_required_group(self): | ||
self.user.groups.add(self.admin_group) | ||
|
||
factory = APIRequestFactory() | ||
request = factory.get('/mock/') | ||
request = factory.get("/mock/") | ||
force_authenticate(request, user=self.user) | ||
|
||
view = MockView.as_view() | ||
response = view(request) | ||
self.assertEqual(response.status_code, 200) | ||
|
||
def test_user_not_in_required_group(self): | ||
factory = APIRequestFactory() | ||
request = factory.get('/mock/') | ||
request = factory.get("/mock/") | ||
force_authenticate(request, user=self.user) | ||
|
||
view = MockView.as_view() | ||
response = view(request) | ||
self.assertEqual(response.status_code, 403) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,6 @@ | |
|
||
from backoffice.users.models import User as UserType | ||
|
||
|
||
User = get_user_model() | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
from rest_framework import serializers | ||
from workflows.models import Workflow | ||
|
||
from backoffice.workflows.models import Workflow | ||
|
||
|
||
class WorkflowSerializer(serializers.ModelSerializer): | ||
class Meta: | ||
model = Workflow | ||
fields = '__all__' | ||
fields = "__all__" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,29 @@ | ||
from rest_framework.test import APIClient | ||
from django.apps import apps | ||
from django.contrib.auth import get_user_model | ||
from django.contrib.auth.models import Group | ||
from django.test import TestCase | ||
from django.apps import apps | ||
from rest_framework.test import APIClient | ||
|
||
User = get_user_model() | ||
Workflow = apps.get_model(app_label='workflows', model_name='Workflow') | ||
Workflow = apps.get_model(app_label="workflows", model_name="Workflow") | ||
|
||
|
||
class TestWorkflowViewSet(TestCase): | ||
endpoint = '/api/workflows/' | ||
endpoint = "/api/workflows/" | ||
|
||
def setUp(self): | ||
self.curator_group = Group.objects.create(name="curator") | ||
self.admin_group = Group.objects.create(name="admin") | ||
|
||
self.curator = User.objects.create_user(email='[email protected]', password='12345') | ||
self.admin = User.objects.create_user(email='[email protected]', password='12345') | ||
self.user = User.objects.create_user(email='[email protected]', password='12345') | ||
self.curator = User.objects.create_user(email="[email protected]", password="12345") | ||
self.admin = User.objects.create_user(email="[email protected]", password="12345") | ||
self.user = User.objects.create_user(email="[email protected]", password="12345") | ||
|
||
self.curator.groups.add(self.curator_group) | ||
self.admin.groups.add(self.admin_group) | ||
|
||
self.api_client = APIClient() | ||
self.workflow = Workflow.objects.create(data={}, status='APPROVAL', core=True, is_update=False) | ||
self.workflow = Workflow.objects.create(data={}, status="APPROVAL", core=True, is_update=False) | ||
|
||
def test_list_curator(self): | ||
self.api_client.force_authenticate(user=self.curator) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
from django.contrib import admin | ||
from django.urls import include, path | ||
|
||
|
||
urlpatterns = [ | ||
path("workflows/", include("workflows.urls")), | ||
path("admin/", admin.site.urls), | ||
] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.