Exemple #1
0
 def setUpTestData(cls):
     super().setUpTestData()
     org1 = OrganizationFactory(key='org1')
     OrganizationGroupFactory(organization=org1, name='org1a')
     OrganizationGroupFactory(organization=org1, name='org1b')
     org2 = OrganizationFactory(key='org2')
     OrganizationGroupFactory(organization=org2, name='org2a')
     OrganizationGroupFactory(organization=org2, name='org2b')
     OrganizationFactory(key='org3')
     GroupFactory(name='normal_group')
    def setUpTestData(cls):
        super().setUpTestData()

        cls.org = OrganizationFactory()
        cls.program = DiscoveryProgramFactory(managing_organization=cls.org)

        cls.request = RequestFactory().get('/api/v1/programs')
        cls.request.user = AnonymousUser()
Exemple #3
0
 def setUpTestData(cls):
     super().setUpTestData()
     cls.user = UserFactory()
     cls.org = OrganizationFactory(name='Test Organization')
     cls.program = ProgramFactory(
         managing_organization=cls.org,
     )
     cls.program2 = ProgramFactory(
         managing_organization=cls.org,
     )
Exemple #4
0
 def setUpTestData(cls):
     super().setUpTestData()
     cls.org = OrganizationFactory()
     cls.other_org = OrganizationFactory()
     cls.org_read_reports_group = OrganizationGroupFactory(
         name=f'{cls.org.key}_ReadOrganizationReports',
         organization=cls.org,
         role=OrganizationReadReportRole.name)
     cls.org_read_enrollments = OrganizationGroupFactory(
         name=f'{cls.org.key}_ReadEnrollments',
         organization=cls.org,
         role=OrganizationReadEnrollmentsRole.name)
     cls.other_org_read_reports_group = OrganizationGroupFactory(
         name=f'{cls.other_org.key}_ReadOrganizationReports',
         organization=cls.other_org,
         role=OrganizationReadReportRole.name)
     cls.other_org_read_enrollments = OrganizationGroupFactory(
         name=f'{cls.other_org.key}_ReadEnrollments',
         organization=cls.other_org,
         role=OrganizationReadEnrollmentsRole.name)
Exemple #5
0
 def test_roles_are_org_specific(self):
     organization2 = OrganizationFactory()
     permission = perm.ReadMetadataRole.permissions[0]
     self.assertFalse(self.user.has_perm(permission, self.organization))
     self.assertFalse(self.user.has_perm(permission, organization2))
     org_group = OrganizationGroup.objects.create(
         role=perm.ReadMetadataRole.name,
         organization=self.organization,
     )
     self.user.groups.add(org_group)  # pylint: disable=no-member
     self.assertTrue(self.user.has_perm(permission, self.organization))
     self.assertFalse(self.user.has_perm(permission, organization2))
Exemple #6
0
    def setUpClass(cls):
        super().setUpClass()
        cls.admin_user = UserFactory()
        assign_perm(perms.WRITE_ENROLLMENTS, cls.admin_user)

        cls.org = OrganizationFactory(name='Test Organization')
        cls.program = ProgramFactory(managing_organization=cls.org, )
        cls.org_admin_group = OrganizationGroupFactory(
            organization=cls.org, role=perms.ReadWriteEnrollmentsRole.name)
        cls.org_admin = UserFactory()
        cls.org_admin.groups.add(cls.org_admin_group)  # pylint: disable=no-member

        cls.no_perms_user = UserFactory()
Exemple #7
0
    def setUpTestData(cls):
        super().setUpTestData()
        cls.org = OrganizationFactory()
        cls.other_org = OrganizationFactory()
        cls.english_uuid = '11111111-2222-3333-4444-555555555555'
        cls.german_uuid = '22222222-2222-3333-4444-555555555555'
        cls.russian_uuid = '33333333-2222-3333-4444-555555555555'
        cls.arabic_uuid = '44444444-2222-3333-4444-555555555555'

        cls.english_program = ProgramFactory(key='masters-in-english',
                                             discovery_uuid=cls.english_uuid,
                                             managing_organization=cls.org)
        cls.german_program = ProgramFactory(
            key='masters-in-german',
            discovery_uuid=cls.german_uuid,
            managing_organization=cls.other_org)
        cls.english_discovery_program = cls.discovery_dict(
            cls.org.key, cls.english_uuid, 'english-slug')
        cls.german_discovery_program = cls.discovery_dict(
            cls.other_org.key, cls.german_uuid, 'german-slug')
        cls.russian_discovery_program = cls.discovery_dict(
            cls.other_org.key, cls.russian_uuid, 'russian-slug')
        cls.arabic_discovery_program = cls.discovery_dict(
            cls.org.key, cls.arabic_uuid, 'arabic-slug')
Exemple #8
0
    def test_org_group_recalculates_permissions(self):
        org1 = self.organization
        org2 = OrganizationFactory()
        metdata_permission = perm.READ_METADATA
        write_permission = perm.WRITE_ENROLLMENTS

        # Scenario 1: read/write on org1
        org_group = OrganizationGroup.objects.create(
            role=perm.ReadWriteEnrollmentsRole.name,
            organization=org1,
        )
        self.user.groups.add(org_group)  # pylint: disable=no-member
        self.assertTrue(self.user.has_perm(metdata_permission, org1))
        self.assertTrue(self.user.has_perm(write_permission, org1))
        self.assertFalse(self.user.has_perm(metdata_permission, org2))
        self.assertFalse(self.user.has_perm(write_permission, org2))

        # Scenario 2: metadata only on org1
        org_group.role = perm.ReadEnrollmentsRole.name
        org_group.save()
        self.assertTrue(self.user.has_perm(metdata_permission, org1))
        self.assertFalse(self.user.has_perm(write_permission, org1))
        self.assertFalse(self.user.has_perm(metdata_permission, org2))
        self.assertFalse(self.user.has_perm(write_permission, org2))

        # Scenario 3: metadata only on org2
        org_group.organization = org2
        org_group.save()
        self.assertFalse(self.user.has_perm(metdata_permission, org1))
        self.assertFalse(self.user.has_perm(write_permission, org1))
        self.assertTrue(self.user.has_perm(metdata_permission, org2))
        self.assertFalse(self.user.has_perm(write_permission, org2))

        # Scenario 4: read/write on org2
        org_group.role = perm.ReadWriteEnrollmentsRole.name
        org_group.save()
        self.assertFalse(self.user.has_perm(metdata_permission, org1))
        self.assertFalse(self.user.has_perm(write_permission, org1))
        self.assertTrue(self.user.has_perm(metdata_permission, org2))
        self.assertTrue(self.user.has_perm(write_permission, org2))
Exemple #9
0
 def setUpTestData(cls):
     super().setUpTestData()
     cls.user = UserFactory()
     org = OrganizationFactory(name='STEM Institute')
     cls.program = ProgramFactory(managing_organization=org)
Exemple #10
0
 def setUpTestData(cls):
     super().setUpTestData()
     cls.org = OrganizationFactory()
     cls.program = ProgramFactory(managing_organization=cls.org)
Exemple #11
0
 def setUp(self):
     super(OrganizationGroupTests, self).setUp()
     self.organization = OrganizationFactory()
     self.user = UserFactory()
Exemple #12
0
 def setUp(self):
     super(PendingUserOrganizationGroupTests, self).setUp()
     self.organization = OrganizationFactory()
     self.organization_group = OrganizationGroupFactory(organization=self.organization)