@ -1,75 +0,0 @@
|
|||||||
import pytest
|
|
||||||
|
|
||||||
from django.test import TestCase
|
|
||||||
|
|
||||||
from core.tests.abstract.test_notes_viewset import NoteViewSetCommon
|
|
||||||
|
|
||||||
from core.models.notes import Notes
|
|
||||||
|
|
||||||
from config_management.models.groups import ConfigGroups
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class NotePermissionsAPI(
|
|
||||||
NoteViewSetCommon,
|
|
||||||
TestCase,
|
|
||||||
):
|
|
||||||
|
|
||||||
app_namespace = 'API'
|
|
||||||
|
|
||||||
url_name = '_api_v2_config_group_note'
|
|
||||||
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def setUpTestData(self):
|
|
||||||
"""Setup Test
|
|
||||||
|
|
||||||
1. Create an organization for user and item
|
|
||||||
. create an organization that is different to item
|
|
||||||
2. Create a team
|
|
||||||
3. create teams with each permission: view, add, change, delete
|
|
||||||
4. create a user per team
|
|
||||||
"""
|
|
||||||
|
|
||||||
super().setUpTestData()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
self.note_item = ConfigGroups.objects.create(
|
|
||||||
organization = self.organization,
|
|
||||||
name = 'history-device'
|
|
||||||
)
|
|
||||||
|
|
||||||
self.item = Notes.objects.create(
|
|
||||||
organization = self.organization,
|
|
||||||
note = 'a note',
|
|
||||||
usercreated = self.view_user,
|
|
||||||
config_group = self.note_item
|
|
||||||
)
|
|
||||||
|
|
||||||
self.other_org_item = Notes.objects.create(
|
|
||||||
organization = self.different_organization,
|
|
||||||
note = 'b note',
|
|
||||||
usercreated = self.view_user,
|
|
||||||
config_group = self.note_item
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
self.url_kwargs = {'config_group_id': self.note_item.id}
|
|
||||||
|
|
||||||
self.url_view_kwargs = {'config_group_id': self.note_item.id, 'pk': self.item.pk }
|
|
||||||
|
|
||||||
self.add_data = {'note': 'a note added', 'organization': self.organization.id}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_returned_data_from_user_and_global_organizations_only(self):
|
|
||||||
"""Check items returned
|
|
||||||
|
|
||||||
This test case is a over-ride of a test case with the same name.
|
|
||||||
This model is not a tenancy model making this test not-applicable.
|
|
||||||
|
|
||||||
Items returned from the query Must be from the users organization and
|
|
||||||
global ONLY!
|
|
||||||
"""
|
|
||||||
pass
|
|
@ -1,79 +0,0 @@
|
|||||||
import pytest
|
|
||||||
|
|
||||||
from django.test import TestCase
|
|
||||||
|
|
||||||
from core.tests.abstract.test_notes_viewset import NoteViewSetCommon
|
|
||||||
|
|
||||||
from core.models.notes import Notes
|
|
||||||
|
|
||||||
from itam.models.device import Device
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class DeviceNotePermissionsAPI(
|
|
||||||
NoteViewSetCommon,
|
|
||||||
TestCase,
|
|
||||||
):
|
|
||||||
|
|
||||||
app_namespace = 'API'
|
|
||||||
|
|
||||||
url_name = '_api_v2_device_note'
|
|
||||||
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def setUpTestData(self):
|
|
||||||
"""Setup Test
|
|
||||||
|
|
||||||
1. Create an organization for user and item
|
|
||||||
. create an organization that is different to item
|
|
||||||
2. Create a team
|
|
||||||
3. create teams with each permission: view, add, change, delete
|
|
||||||
4. create a user per team
|
|
||||||
"""
|
|
||||||
|
|
||||||
super().setUpTestData()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
self.note_item = Device.objects.create(
|
|
||||||
organization = self.organization,
|
|
||||||
name = 'history-device'
|
|
||||||
)
|
|
||||||
|
|
||||||
self.note_item_b = Device.objects.create(
|
|
||||||
organization = self.different_organization,
|
|
||||||
name = 'history-device-b'
|
|
||||||
)
|
|
||||||
|
|
||||||
self.item = Notes.objects.create(
|
|
||||||
organization = self.organization,
|
|
||||||
note = 'a note',
|
|
||||||
usercreated = self.view_user,
|
|
||||||
device = self.note_item
|
|
||||||
)
|
|
||||||
|
|
||||||
self.other_org_item = Notes.objects.create(
|
|
||||||
organization = self.different_organization,
|
|
||||||
note = 'b note',
|
|
||||||
usercreated = self.view_user,
|
|
||||||
device = self.note_item_b
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
self.url_kwargs = {'device_id': self.note_item.id}
|
|
||||||
|
|
||||||
self.url_view_kwargs = {'device_id': self.note_item.id, 'pk': self.item.pk }
|
|
||||||
|
|
||||||
self.add_data = {'note': 'a note added', 'organization': self.organization.id}
|
|
||||||
|
|
||||||
|
|
||||||
def test_returned_data_from_user_and_global_organizations_only(self):
|
|
||||||
"""Check items returned
|
|
||||||
|
|
||||||
This test case is a over-ride of a test case with the same name.
|
|
||||||
This model is not a tenancy model making this test not-applicable.
|
|
||||||
|
|
||||||
Items returned from the query Must be from the users organization and
|
|
||||||
global ONLY!
|
|
||||||
"""
|
|
||||||
pass
|
|
@ -1,79 +0,0 @@
|
|||||||
import pytest
|
|
||||||
|
|
||||||
from django.test import TestCase
|
|
||||||
|
|
||||||
from core.tests.abstract.test_notes_viewset import NoteViewSetCommon
|
|
||||||
|
|
||||||
from core.models.notes import Notes
|
|
||||||
|
|
||||||
from itam.models.operating_system import OperatingSystem
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class OperatingSystemNotePermissionsAPI(
|
|
||||||
NoteViewSetCommon,
|
|
||||||
TestCase,
|
|
||||||
):
|
|
||||||
|
|
||||||
app_namespace = 'API'
|
|
||||||
|
|
||||||
url_name = '_api_v2_operating_system_note'
|
|
||||||
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def setUpTestData(self):
|
|
||||||
"""Setup Test
|
|
||||||
|
|
||||||
1. Create an organization for user and item
|
|
||||||
. create an organization that is different to item
|
|
||||||
2. Create a team
|
|
||||||
3. create teams with each permission: view, add, change, delete
|
|
||||||
4. create a user per team
|
|
||||||
"""
|
|
||||||
|
|
||||||
super().setUpTestData()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
self.note_item = OperatingSystem.objects.create(
|
|
||||||
organization = self.organization,
|
|
||||||
name = 'history-device'
|
|
||||||
)
|
|
||||||
|
|
||||||
self.note_item_b = OperatingSystem.objects.create(
|
|
||||||
organization = self.organization,
|
|
||||||
name = 'history-device-b'
|
|
||||||
)
|
|
||||||
|
|
||||||
self.item = Notes.objects.create(
|
|
||||||
organization = self.organization,
|
|
||||||
note = 'a note',
|
|
||||||
usercreated = self.view_user,
|
|
||||||
operatingsystem = self.note_item
|
|
||||||
)
|
|
||||||
|
|
||||||
self.other_org_item = Notes.objects.create(
|
|
||||||
organization = self.different_organization,
|
|
||||||
note = 'b note',
|
|
||||||
usercreated = self.view_user,
|
|
||||||
operatingsystem = self.note_item_b
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
self.url_kwargs = {'operating_system_id': self.note_item.id}
|
|
||||||
|
|
||||||
self.url_view_kwargs = {'operating_system_id': self.note_item.id, 'pk': self.item.pk }
|
|
||||||
|
|
||||||
self.add_data = {'note': 'a note added', 'organization': self.organization.id}
|
|
||||||
|
|
||||||
|
|
||||||
def test_returned_data_from_user_and_global_organizations_only(self):
|
|
||||||
"""Check items returned
|
|
||||||
|
|
||||||
This test case is a over-ride of a test case with the same name.
|
|
||||||
This model is not a tenancy model making this test not-applicable.
|
|
||||||
|
|
||||||
Items returned from the query Must be from the users organization and
|
|
||||||
global ONLY!
|
|
||||||
"""
|
|
||||||
pass
|
|
@ -1,79 +0,0 @@
|
|||||||
import pytest
|
|
||||||
|
|
||||||
from django.test import TestCase
|
|
||||||
|
|
||||||
from core.tests.abstract.test_notes_viewset import NoteViewSetCommon
|
|
||||||
|
|
||||||
from core.models.notes import Notes
|
|
||||||
|
|
||||||
from itam.models.software import Software
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class SoftwareNotePermissionsAPI(
|
|
||||||
NoteViewSetCommon,
|
|
||||||
TestCase,
|
|
||||||
):
|
|
||||||
|
|
||||||
app_namespace = 'API'
|
|
||||||
|
|
||||||
url_name = '_api_v2_software_note'
|
|
||||||
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def setUpTestData(self):
|
|
||||||
"""Setup Test
|
|
||||||
|
|
||||||
1. Create an organization for user and item
|
|
||||||
. create an organization that is different to item
|
|
||||||
2. Create a team
|
|
||||||
3. create teams with each permission: view, add, change, delete
|
|
||||||
4. create a user per team
|
|
||||||
"""
|
|
||||||
|
|
||||||
super().setUpTestData()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
self.note_item = Software.objects.create(
|
|
||||||
organization = self.organization,
|
|
||||||
name = 'history-device'
|
|
||||||
)
|
|
||||||
|
|
||||||
self.note_item_b = Software.objects.create(
|
|
||||||
organization = self.different_organization,
|
|
||||||
name = 'history-device-b'
|
|
||||||
)
|
|
||||||
|
|
||||||
self.item = Notes.objects.create(
|
|
||||||
organization = self.organization,
|
|
||||||
note = 'a note',
|
|
||||||
usercreated = self.view_user,
|
|
||||||
software = self.note_item
|
|
||||||
)
|
|
||||||
|
|
||||||
self.other_org_item = Notes.objects.create(
|
|
||||||
organization = self.different_organization,
|
|
||||||
note = 'b note',
|
|
||||||
usercreated = self.view_user,
|
|
||||||
software = self.note_item_b
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
self.url_kwargs = {'software_id': self.note_item.id}
|
|
||||||
|
|
||||||
self.url_view_kwargs = {'software_id': self.note_item.id, 'pk': self.item.pk }
|
|
||||||
|
|
||||||
self.add_data = {'note': 'a note added', 'organization': self.organization.id}
|
|
||||||
|
|
||||||
|
|
||||||
def test_returned_data_from_user_and_global_organizations_only(self):
|
|
||||||
"""Check items returned
|
|
||||||
|
|
||||||
This test case is a over-ride of a test case with the same name.
|
|
||||||
This model is not a tenancy model making this test not-applicable.
|
|
||||||
|
|
||||||
Items returned from the query Must be from the users organization and
|
|
||||||
global ONLY!
|
|
||||||
"""
|
|
||||||
pass
|
|
@ -1,74 +0,0 @@
|
|||||||
import pytest
|
|
||||||
|
|
||||||
from django.test import TestCase
|
|
||||||
|
|
||||||
from core.tests.abstract.test_notes_viewset import NoteViewSetCommon
|
|
||||||
|
|
||||||
from core.models.notes import Notes
|
|
||||||
|
|
||||||
from itim.models.services import Service
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class ServiceNotePermissionsAPI(
|
|
||||||
NoteViewSetCommon,
|
|
||||||
TestCase,
|
|
||||||
):
|
|
||||||
|
|
||||||
app_namespace = 'API'
|
|
||||||
|
|
||||||
url_name = '_api_v2_service_note'
|
|
||||||
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def setUpTestData(self):
|
|
||||||
"""Setup Test
|
|
||||||
|
|
||||||
1. Create an organization for user and item
|
|
||||||
. create an organization that is different to item
|
|
||||||
2. Create a team
|
|
||||||
3. create teams with each permission: view, add, change, delete
|
|
||||||
4. create a user per team
|
|
||||||
"""
|
|
||||||
|
|
||||||
super().setUpTestData()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
self.note_item = Service.objects.create(
|
|
||||||
organization = self.organization,
|
|
||||||
name = 'history-device'
|
|
||||||
)
|
|
||||||
|
|
||||||
self.item = Notes.objects.create(
|
|
||||||
organization = self.organization,
|
|
||||||
note = 'a note',
|
|
||||||
usercreated = self.view_user,
|
|
||||||
service = self.note_item
|
|
||||||
)
|
|
||||||
|
|
||||||
self.other_org_item = Notes.objects.create(
|
|
||||||
organization = self.different_organization,
|
|
||||||
note = 'b note',
|
|
||||||
usercreated = self.view_user,
|
|
||||||
service = self.note_item
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
self.url_kwargs = {'service_id': self.note_item.id}
|
|
||||||
|
|
||||||
self.url_view_kwargs = {'service_id': self.note_item.id, 'pk': self.item.pk }
|
|
||||||
|
|
||||||
self.add_data = {'note': 'a note added', 'organization': self.organization.id}
|
|
||||||
|
|
||||||
|
|
||||||
def test_returned_data_from_user_and_global_organizations_only(self):
|
|
||||||
"""Check items returned
|
|
||||||
|
|
||||||
This test case is a over-ride of a test case with the same name.
|
|
||||||
This model is not a tenancy model making this test not-applicable.
|
|
||||||
|
|
||||||
Items returned from the query Must be from the users organization and
|
|
||||||
global ONLY!
|
|
||||||
"""
|
|
||||||
pass
|
|
Reference in New Issue
Block a user