コード例 #1
0
ファイル: test_utils.py プロジェクト: ultrasound/edx-platform
    def test_multiple_saml_providers(self, second_config_enabled):
        """
        If multiple samlprovider records exist with the same organization
        an exception is raised
        """
        organization = OrganizationFactory.create(
            short_name=self.organization_key)
        provider = SAMLProviderConfigFactory.create(organization=organization)

        self.create_social_auth_entry(self.user, provider,
                                      self.external_user_id)

        # create a second active config for the same organization
        SAMLProviderConfigFactory.create(organization=organization,
                                         slug='foox',
                                         enabled=second_config_enabled)

        try:
            get_user_by_program_id(self.external_user_id, self.program_uuid)
        except ProviderConfigurationException:
            self.assertTrue(second_config_enabled,
                            'Unexpected error when second config is disabled')
        else:
            self.assertFalse(
                second_config_enabled,
                'Expected error was not raised when second config is enabled')
コード例 #2
0
 def test_catalog_program_does_not_exist(self):
     """
     Test ProgramDoesNotExistException is thrown if the program cache does
     not include the requested program uuid.
     """
     with pytest.raises(ProgramDoesNotExistException):
         get_user_by_program_id('school-id-1234', uuid4())
コード例 #3
0
ファイル: test_utils.py プロジェクト: edx/edx-platform
 def test_catalog_program_does_not_exist(self):
     """
     Test ProgramDoesNotExistException is thrown if the program cache does
     not include the requested program uuid.
     """
     with pytest.raises(ProgramDoesNotExistException):
         get_user_by_program_id('school-id-1234', uuid4())
コード例 #4
0
    def test_saml_provider_not_found(self):
        """
        Test an exception is thrown if no SAML provider exists for this program's organization
        """
        OrganizationFactory.create(short_name=self.organization_key)

        with pytest.raises(ProviderDoesNotExistException):
            get_user_by_program_id(self.external_user_id, self.program_uuid)
コード例 #5
0
ファイル: test_utils.py プロジェクト: edx/edx-platform
    def test_saml_provider_not_found(self):
        """
        Test an exception is thrown if no SAML provider exists for this program's organization
        """
        OrganizationFactory.create(short_name=self.organization_key)

        with pytest.raises(ProviderDoesNotExistException):
            get_user_by_program_id(self.external_user_id, self.program_uuid)
コード例 #6
0
ファイル: test_utils.py プロジェクト: edx/edx-platform
    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')
        provider = SAMLProviderConfigFactory.create(organization=organization)
        self.create_social_auth_entry(self.user, provider, self.external_user_id)

        with pytest.raises(OrganizationDoesNotExistException):
            get_user_by_program_id(self.external_user_id, self.program_uuid)
コード例 #7
0
ファイル: test_utils.py プロジェクト: jlrivera81/incr-228
    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')
        provider = SAMLProviderConfigFactory.create(organization=organization)
        self.create_social_auth_entry(self.user, provider, self.external_user_id)

        with pytest.raises(OrganizationDoesNotExistException):
            get_user_by_program_id(self.external_user_id, self.program_uuid)
コード例 #8
0
ファイル: test_utils.py プロジェクト: edx/edx-platform
    def test_multiple_active_saml_providers(self):
        """
        If multiple samlprovider records exist with the same organization
        an exception is raised
        """
        organization = OrganizationFactory.create(short_name=self.organization_key)
        provider = SAMLProviderConfigFactory.create(organization=organization)

        self.create_social_auth_entry(self.user, provider, self.external_user_id)

        # create a second active config for the same organization
        SAMLProviderConfigFactory.create(organization=organization, slug='foox')

        with pytest.raises(UserLookupException):
            get_user_by_program_id(self.external_user_id, self.program_uuid)
コード例 #9
0
ファイル: test_utils.py プロジェクト: edx/edx-platform
    def test_catalog_program_missing_org(self):
        """
        Test OrganizationDoesNotExistException is thrown if the cached program does not
        have an authoring organization.
        """
        program = ProgramFactory.create(
            uuid=self.program_uuid,
            authoring_organizations=[]
        )
        cache.set(PROGRAM_CACHE_KEY_TPL.format(uuid=self.program_uuid), program, None)

        organization = OrganizationFactory.create(short_name=self.organization_key)
        provider = SAMLProviderConfigFactory.create(organization=organization)
        self.create_social_auth_entry(self.user, provider, self.external_user_id)

        with pytest.raises(OrganizationDoesNotExistException):
            get_user_by_program_id(self.external_user_id, self.program_uuid)
コード例 #10
0
ファイル: test_utils.py プロジェクト: jlrivera81/incr-228
    def test_catalog_program_missing_org(self):
        """
        Test OrganizationDoesNotExistException is thrown if the cached program does not
        have an authoring organization.
        """
        program = ProgramFactory.create(
            uuid=self.program_uuid,
            authoring_organizations=[]
        )
        cache.set(PROGRAM_CACHE_KEY_TPL.format(uuid=self.program_uuid), program, None)

        organization = OrganizationFactory.create(short_name=self.organization_key)
        provider = SAMLProviderConfigFactory.create(organization=organization)
        self.create_social_auth_entry(self.user, provider, self.external_user_id)

        with pytest.raises(OrganizationDoesNotExistException):
            get_user_by_program_id(self.external_user_id, self.program_uuid)
コード例 #11
0
    def test_multiple_active_saml_providers(self):
        """
        If multiple samlprovider records exist with the same organization
        an exception is raised
        """
        organization = OrganizationFactory.create(
            short_name=self.organization_key)
        provider = SAMLProviderConfigFactory.create(organization=organization)

        self.create_social_auth_entry(self.user, provider,
                                      self.external_user_id)

        # create a second active config for the same organization
        SAMLProviderConfigFactory.create(organization=organization,
                                         slug='foox')

        with pytest.raises(UserLookupException):
            get_user_by_program_id(self.external_user_id, self.program_uuid)
コード例 #12
0
ファイル: test_utils.py プロジェクト: edx/edx-platform
    def test_social_auth_user_not_created(self):
        """
        None should be returned if no lms user exists for an external id
        """
        organization = OrganizationFactory.create(short_name=self.organization_key)
        SAMLProviderConfigFactory.create(organization=organization)

        user = get_user_by_program_id(self.external_user_id, self.program_uuid)
        self.assertIsNone(user)
コード例 #13
0
ファイル: test_utils.py プロジェクト: jlrivera81/incr-228
    def test_social_auth_user_not_created(self):
        """
        None should be returned if no lms user exists for an external id
        """
        organization = OrganizationFactory.create(short_name=self.organization_key)
        SAMLProviderConfigFactory.create(organization=organization)

        user = get_user_by_program_id(self.external_user_id, self.program_uuid)
        self.assertIsNone(user)
コード例 #14
0
ファイル: test_utils.py プロジェクト: edx/edx-platform
    def test_get_user_success(self):
        """
        Test lms user is successfully found
        """
        organization = OrganizationFactory.create(short_name=self.organization_key)
        provider = SAMLProviderConfigFactory.create(organization=organization)
        self.create_social_auth_entry(self.user, provider, self.external_user_id)

        user = get_user_by_program_id(self.external_user_id, self.program_uuid)
        self.assertEquals(user, self.user)
コード例 #15
0
ファイル: test_utils.py プロジェクト: jlrivera81/incr-228
    def test_get_user_success(self):
        """
        Test lms user is successfully found
        """
        organization = OrganizationFactory.create(short_name=self.organization_key)
        provider = SAMLProviderConfigFactory.create(organization=organization)
        self.create_social_auth_entry(self.user, provider, self.external_user_id)

        user = get_user_by_program_id(self.external_user_id, self.program_uuid)
        self.assertEquals(user, self.user)