Пример #1
0
    def test_loginFailure(self):
        params = {
            'username': '******',
            'password': '******',
            'server':self.server_id
        }        
        request = fakeRequest(method="post", params=params)
        
        form = LoginForm(data=request.REQUEST.copy())        
        if form.is_valid():
            blitz = settings.SERVER_LIST.get(pk=form.cleaned_data['server']) 
            request.session['server'] = blitz.id
            request.session['host'] = blitz.host
            request.session['port'] = blitz.port
            request.session['username'] = form.cleaned_data['username'].strip()
            request.session['password'] = form.cleaned_data['password'].strip()
            request.session['ssl'] = form.cleaned_data['ssl']

            conn = webgateway_views.getBlitzConnection(request, useragent="TEST.webadmin")
            if conn is not None:
                self.fail('This user does not exist. Login failure error!')
                webgateway_views._session_logout(request, request.session.get('server'))

        else:
            errors = form.errors.as_text()
            self.fail(errors)            
Пример #2
0
    def test_loginFromForm(self):
        params = {
            'username': '******',
            'password': self.root_password,
            'server':self.server_id,
            'ssl':'on'
        }        
        request = fakeRequest(method="post", params=params)
        
        form = LoginForm(data=request.REQUEST.copy())        
        if form.is_valid():
            
            blitz = settings.SERVER_LIST.get(pk=form.cleaned_data['server']) 
            request.session['server'] = blitz.id
            request.session['host'] = blitz.host
            request.session['port'] = blitz.port
            request.session['username'] = form.cleaned_data['username'].strip()
            request.session['password'] = form.cleaned_data['password'].strip()
            request.session['ssl'] = form.cleaned_data['ssl']

            conn = webgateway_views.getBlitzConnection(request, useragent="TEST.webadmin")
            if conn is None:
                self.fail('Cannot connect')            
            webgateway_views._session_logout(request, request.session.get('server'))
            if conn.isConnected() and conn.keepAlive():
                self.fail('Connection was not closed')
            
        else:
            errors = form.errors.as_text()
            self.fail(errors)
Пример #3
0
 def doLogin (self, user):
     r = fakeRequest()
     q = QueryDict('', mutable=True)
     q.update({'username': user.name, 'password': user.passwd})
     r.REQUEST.dicts += (q,)
     self.gateway = views.getBlitzConnection(r, 1, group=user.groupname, try_super=user.admin)
     if self.gateway is None:
         # If the login framework was customized (using this app outside omeroweb) the above fails
         super(WGTest, self).doLogin(user)
         self.gateway.user = views.UserProxy(self.gateway)
Пример #4
0
    def test_loginFromRequest(self):
        params = {
            'username': '******',
            'password': self.root_password,
            'server':self.server_id,
            'ssl':'on'
        }        
        request = fakeRequest(method="post", path="/webadmin/login", params=params)
        
        blitz = settings.SERVER_LIST.get(pk=request.REQUEST.get('server')) 
        request.session['server'] = blitz.id
        request.session['host'] = blitz.host
        request.session['port'] = blitz.port
        request.session['username'] = request.REQUEST.get('username').encode('utf-8').strip()
        request.session['password'] = request.REQUEST.get('password').encode('utf-8').strip()
        request.session['ssl'] = (True, False)[request.REQUEST.get('ssl') is None]

        conn = webgateway_views.getBlitzConnection(request, useragent="TEST.webadmin")
        if conn is None:
            self.fail('Cannot connect')
        webgateway_views._session_logout(request, request.session.get('server'))
        if conn.isConnected() and conn.keepAlive():
            self.fail('Connection was not closed')