コード例 #1
0
    def test_same_user_key_in_multiple_organizations(self):
        uox_program_enrollment = self._create_waiting_program_enrollment()

        second_organization = OrganizationFactory.create()
        SAMLProviderConfigFactory.create(organization=second_organization,
                                         slug='aiu')
        catalog_org = CatalogOrganizationFactory.create(
            key=second_organization.short_name)
        program_uuid = self._create_catalog_program(catalog_org)['uuid']

        # aiu enrollment with the same student key as our uox user
        aiu_program_enrollment = ProgramEnrollmentFactory.create(
            user=None,
            external_user_key=self.external_id,
            program_uuid=program_uuid)

        UserSocialAuth.objects.create(
            user=UserFactory.create(),
            uid='{0}:{1}'.format('not_used', self.external_id),
        )

        UserSocialAuth.objects.create(
            user=self.user,
            uid='{0}:{1}'.format(self.provider_slug, self.external_id),
        )
        self._assert_program_enrollment_user(uox_program_enrollment, self.user)

        aiu_user = UserFactory.create()
        UserSocialAuth.objects.create(
            user=aiu_user,
            uid='{0}:{1}'.format('aiu', self.external_id),
        )
        self._assert_program_enrollment_user(aiu_program_enrollment, aiu_user)
コード例 #2
0
 def test_empty_request(self):
     """
     Test that requesting no external keys does not cause an exception.
     """
     organization = OrganizationFactory.create(short_name=self.organization_key)
     SAMLProviderConfigFactory.create(organization=organization)
     actual = get_users_by_external_keys(self.program_uuid, set())
     assert actual == {}
コード例 #3
0
 def test_lms_organization_not_found(self):
     """
     Test an OrganizationDoesNotExistException is thrown if the LMS has no organization
     matching the catalog program's authoring_organization
     """
     organization = OrganizationFactory.create(short_name='some_other_org')
     SAMLProviderConfigFactory.create(organization=organization)
     with self.assertRaises(OrganizationDoesNotExistException):
         get_users_by_external_keys(self.program_uuid, [])
コード例 #4
0
    def setUp(self):
        super(TestOrganizationsView, self).setUp()

        self.user_password = "******"
        self.user = UserFactory(password=self.user_password)
        self.organization = OrganizationFactory.create()
        self.organization_list_url = reverse("v0:organization-list")
        self.client.login(username=self.user.username,
                          password=self.user_password)
コード例 #5
0
    def setUpClass(cls):
        super(SocialAuthEnrollmentCompletionSignalTest, cls).setUpClass()

        cls.external_id = '0000'
        cls.provider_slug = 'uox'
        cls.course_keys = [
            CourseKey.from_string('course-v1:edX+DemoX+Test_Course'),
            CourseKey.from_string('course-v1:edX+DemoX+Another_Test_Course'),
        ]
        cls.organization = OrganizationFactory.create(short_name='UoX')
        cls.user = UserFactory.create()

        for course_key in cls.course_keys:
            CourseOverviewFactory(id=course_key)
        cls.provider_config = SAMLProviderConfigFactory.create(
            organization=cls.organization, slug=cls.provider_slug)
コード例 #6
0
 def test_happy_path(self):
     """
     Test that get_users_by_external_keys returns the expected
     mapping of external keys to users.
     """
     organization = OrganizationFactory.create(short_name=self.organization_key)
     provider = SAMLProviderConfigFactory.create(organization=organization)
     self.create_social_auth_entry(self.user_0, provider, 'ext-user-0')
     self.create_social_auth_entry(self.user_1, provider, 'ext-user-1')
     self.create_social_auth_entry(self.user_2, provider, 'ext-user-2')
     requested_keys = {'ext-user-1', 'ext-user-2', 'ext-user-3'}
     actual = get_users_by_external_keys(self.program_uuid, requested_keys)
     # ext-user-0 not requested, ext-user-3 doesn't exist
     expected = {
         'ext-user-1': self.user_1,
         'ext-user-2': self.user_2,
         'ext-user-3': None,
     }
     assert actual == expected
コード例 #7
0
 def setUp(self):
     super(TestOrganizationModel, self).setUp()
     self.organization = OrganizationFactory.create()
コード例 #8
0
 def test_authenticated_user(self):
     """ Verify that the authenticated user gets data."""
     OrganizationFactory.create()
     response = self.client.get(self.organization_list_url)
     self.assertEqual(response.status_code, 200)
     self.assertEqual(len(response.data["results"]), 2)  # pylint: disable=no-member