Exemplo n.º 1
0
class TestShibbolethRemoteUserMiddleware(TestCase):
    def setUp(self):
        self.request_factory = RequestFactory()
        self.smw = SessionMiddleware()
        self.amw = AuthenticationMiddleware()
        self.rmw = RemoteUserMiddleware()
        self.srmw = middleware.ShibbolethRemoteUserMiddleware()

    def _process_request_through_middleware(self, request):
        self.smw.process_request(request)
        self.amw.process_request(request)
        self.rmw.process_request(request)
        return self.srmw.process_request(request)

    def test_no_remote_user(self):
        test_request = self.request_factory.get('/')
        self._process_request_through_middleware(test_request)
        #shouldn't have done anything - just return because no REMOTE_USER
        self.assertTrue('shib' not in test_request.session)
        self.assertFalse(test_request.user.is_authenticated())

    def test_remote_user_empty(self):
        test_request = self.request_factory.get('/', REMOTE_USER='')
        response = self._process_request_through_middleware(test_request)
        self.assertTrue('shib' not in test_request.session)
        self.assertFalse(test_request.user.is_authenticated())
Exemplo n.º 2
0
def login_krbv(**kwargs):
    """
    .. function:: XML-RPC Auth.login_krbv()

        Login into Kiwi TCMS deployed with Kerberos.

        :return: Session ID
        :rtype: str
    """

    # Get the current request
    request = kwargs.get(REQUEST_KEY)

    middleware = RemoteUserMiddleware()
    middleware.process_request(request)

    return request.session.session_key
Exemplo n.º 3
0
def login_krbv(request):
    """
    Description: Login into the Nitrate deployed with mod_auth_kerb

    Returns:     String: Session ID.
    
    Example:
    $ kinit
    Password for [email protected]:

    $ python
    >>> Auth.login_krbv()
    """
    from django.contrib.auth.middleware import RemoteUserMiddleware

    middleware = RemoteUserMiddleware()
    user = middleware.process_request(request)

    return request.session.session_key
Exemplo n.º 4
0
def login_krbv(request):
    """
    Description: Login into the Nitrate deployed with mod_auth_kerb

    Returns:     String: Session ID.

    Example:
    $ kinit
    Password for [email protected]:

    $ python
    >>> Auth.login_krbv()
    """
    from django.contrib.auth.middleware import RemoteUserMiddleware

    middleware = RemoteUserMiddleware()
    middleware.process_request(request)

    return request.session.session_key
Exemplo n.º 5
0
def login_krbv(request):
    """Login into the Nitrate deployed with mod_auth_kerb

    :return: Session ID.
    :rtype: str

    Example::

        $ kinit
        Password for [email protected]:

        $ python
        >>> Auth.login_krbv()
    """
    from django.contrib.auth.middleware import RemoteUserMiddleware

    middleware = RemoteUserMiddleware()
    middleware.process_request(request)

    return request.session.session_key
Exemplo n.º 6
0
def login_krbv(request):
    """Login into the Nitrate deployed with mod_auth_kerb

    :return: Session ID.
    :rtype: str

    Example::

        $ kinit
        Password for [email protected]:

        $ python
        Auth.login_krbv()
    """
    from django.contrib.auth.middleware import RemoteUserMiddleware

    middleware = RemoteUserMiddleware()
    middleware.process_request(request)

    return request.session.session_key
Exemplo n.º 7
0
 def setUp(self):
     self.request_factory = RequestFactory()
     self.smw = SessionMiddleware()
     self.amw = AuthenticationMiddleware()
     self.rmw = RemoteUserMiddleware()
     self.srmw = middleware.ShibbolethRemoteUserMiddleware()
Exemplo n.º 8
0
 def process_request(self, request):
     if settings.DEBUG and os.getenv('REMOTE_USER'):
         request.META[self.header] = os.getenv('REMOTE_USER')
     return RemoteUserMiddleware.process_request(self, request)