Exemplo n.º 1
0
    def test_customer_uuid_for_request_sso_provider_id_customer_exists(self, mock_partial_pipeline):
        mock_idp = EnterpriseCustomerIdentityProviderFactory.create()
        mock_customer = mock_idp.enterprise_customer
        mock_request = mock.Mock(
            GET={'tpa_hint': mock_idp.provider_id},
            COOKIES={},
            session={},
        )

        actual_uuid = enterprise_customer_uuid_for_request(mock_request)

        expected_uuid = mock_customer.uuid
        assert expected_uuid == actual_uuid
        mock_partial_pipeline.assert_called_once_with(mock_request)
        assert ENTERPRISE_CUSTOMER_KEY_NAME not in mock_request.session
Exemplo n.º 2
0
    def test_unlink_enterprise_user_from_idp_no_customer_user(self, mock_customer_from_request, mock_registry):
        customer_idp = EnterpriseCustomerIdentityProviderFactory.create(
            provider_id='the-provider',
        )
        customer = customer_idp.enterprise_customer
        mock_customer_from_request.return_value = {
            'uuid': customer.uuid,
        }
        mock_registry.get_enabled_by_backend_name.return_value = [
            mock.Mock(provider_id='the-provider')
        ]
        request = mock.Mock()

        unlink_enterprise_user_from_idp(request, self.user, idp_backend_name='the-backend-name')

        assert 0 == EnterpriseCustomerUser.objects.filter(user_id=self.user.id).count()
Exemplo n.º 3
0
    def test_is_enterprise_customer_user(self):
        """
        Verify that if user is an enterprise learner.
        """
        # Create users from factory

        user = UserFactory(username='******', email='*****@*****.**')
        other_user = UserFactory(username='******', email='*****@*****.**')
        customer_idp = EnterpriseCustomerIdentityProviderFactory.create(
            provider_id='the-provider',
        )
        customer = customer_idp.enterprise_customer
        EnterpriseCustomerUserFactory.create(
            enterprise_customer=customer,
            user_id=user.id,
        )

        assert is_enterprise_customer_user('the-provider', user)
        assert not is_enterprise_customer_user('the-provider', other_user)