Add a test for login with missing parameter (username or password or both)
This commit is contained in:
		@@ -132,6 +132,37 @@ class LoginTestCase(TestCase, BaseServicePattern, CanLogin):
 | 
			
		||||
        # The LoginTicket is conssumed and should no longer be valid
 | 
			
		||||
        self.assertTrue(params['lt'] not in client.session['lt'])
 | 
			
		||||
 | 
			
		||||
    def test_login_post_missing_params(self):
 | 
			
		||||
        """Test a login attempt with missing POST parameters (username or password or both)"""
 | 
			
		||||
        # we get a client who fetch a frist time the login page and the login form default
 | 
			
		||||
        # parameters
 | 
			
		||||
        client, params = get_login_page_params()
 | 
			
		||||
        # we set only set username
 | 
			
		||||
        params["username"] = settings.CAS_TEST_USER
 | 
			
		||||
        # we post a login attempt
 | 
			
		||||
        response = client.post('/login', params)
 | 
			
		||||
        # as the LT is not valid, login should fail
 | 
			
		||||
        self.assert_login_failed(client, response)
 | 
			
		||||
 | 
			
		||||
        # we get a client who fetch a frist time the login page and the login form default
 | 
			
		||||
        # parameters
 | 
			
		||||
        client, params = get_login_page_params()
 | 
			
		||||
        # we set only set password
 | 
			
		||||
        params["password"] = settings.CAS_TEST_PASSWORD
 | 
			
		||||
        # we post a login attempt
 | 
			
		||||
        response = client.post('/login', params)
 | 
			
		||||
        # as the LT is not valid, login should fail
 | 
			
		||||
        self.assert_login_failed(client, response)
 | 
			
		||||
 | 
			
		||||
        # we get a client who fetch a frist time the login page and the login form default
 | 
			
		||||
        # parameters
 | 
			
		||||
        client, params = get_login_page_params()
 | 
			
		||||
        # we set neither username nor password
 | 
			
		||||
        # we post a login attempt
 | 
			
		||||
        response = client.post('/login', params)
 | 
			
		||||
        # as the LT is not valid, login should fail
 | 
			
		||||
        self.assert_login_failed(client, response)
 | 
			
		||||
 | 
			
		||||
    def test_login_view_post_goodpass_goodlt_warn(self):
 | 
			
		||||
        """Test a successul login requesting to be warned before creating services tickets"""
 | 
			
		||||
        # get a client and initial login params
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user