Django

Code

Changeset 5677

Show
Ignore:
Timestamp:
07/12/07 10:26:37 (1 year ago)
Author:
russellm
Message:

Fixed #4526 -- Modified the test Client login method to fail when a user is inactive. Thanks, marcin@elksoft.pl.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/test/client.py

    r5609 r5677  
    226226 
    227227        Returns True if login is possible; False if the provided credentials 
    228         are incorrect, or if the Sessions framework is not available. 
     228        are incorrect, or the user is inactive, or if the Sessions framework is 
     229        not available. 
    229230        """ 
    230231        user = authenticate(**credentials) 
    231         if user and 'django.contrib.sessions' in settings.INSTALLED_APPS: 
     232        if user and user.is_active and 'django.contrib.sessions' in settings.INSTALLED_APPS: 
    232233            obj = Session.objects.get_new_session_object() 
    233234 
  • django/trunk/tests/modeltests/test_client/fixtures/testdata.json

    r4659 r5677  
    1717            "date_joined": "2006-12-17 07:03:31" 
    1818        } 
     19    }, 
     20    { 
     21        "pk": "2",  
     22        "model": "auth.user",  
     23        "fields": { 
     24            "username": "inactive",  
     25            "first_name": "Inactive",  
     26            "last_name": "User",  
     27            "is_active": false,  
     28            "is_superuser": false,  
     29            "is_staff": false,  
     30            "last_login": "2006-12-17 07:03:31",  
     31            "groups": [],  
     32            "user_permissions": [],  
     33            "password": "sha1$6efc0$f93efe9fd7542f25a7be94871ea45aa95de57161",  
     34            "email": "testclient@example.com",  
     35            "date_joined": "2006-12-17 07:03:31" 
     36        } 
    1937    } 
    2038] 
  • django/trunk/tests/modeltests/test_client/models.py

    r5609 r5677  
    229229        self.failIf(login) 
    230230 
     231    def test_view_with_inactive_login(self): 
     232        "Request a page that is protected with @login, but use an inactive login" 
     233 
     234        login = self.client.login(username='inactive', password='password') 
     235        self.failIf(login) 
     236 
    231237    def test_session_modifying_view(self): 
    232238        "Request a page that modifies the session"