Index: /main/waeup.cas/trunk/waeup/cas/authenticators.py
===================================================================
--- /main/waeup.cas/trunk/waeup/cas/authenticators.py	(revision 10517)
+++ /main/waeup.cas/trunk/waeup/cas/authenticators.py	(revision 10518)
@@ -241,3 +241,6 @@
                     userdata = proxy.get_student_moodle_data(username)
                     return self._create_user(username, userdata, moodle)
-        return (False, 'Invalid username or password.')
+                if principal['type'] == 'applicant':
+                    userdata = proxy.get_applicant_moodle_data(username)
+                    return self._create_user(username, userdata, moodle)
+        return (False, 'Invalid username or password or user not eligible.')
Index: /main/waeup.cas/trunk/waeup/cas/tests/test_authenticators.py
===================================================================
--- /main/waeup.cas/trunk/waeup/cas/tests/test_authenticators.py	(revision 10517)
+++ /main/waeup.cas/trunk/waeup/cas/tests/test_authenticators.py	(revision 10518)
@@ -167,5 +167,7 @@
             self._check_credentials, 'check_student_credentials')
         self.register_function(
-            self._get_student_moodle_data, 'get_student_moodle_data')
+            self._get_moodle_data, 'get_student_moodle_data')
+        self.register_function(
+            self._get_moodle_data, 'get_applicant_moodle_data')
 
     def _check_credentials(self, username, password):
@@ -186,7 +188,9 @@
             'fault1', 'fault2', 'fault3', 'fault4') and password == 'biz':
             return {'type': 'student'}
+        if username == 'fault5' and password == 'biz':
+            return {'type': 'applicant'}
         return None
 
-    def _get_student_moodle_data(self, username):
+    def _get_moodle_data(self, username):
         # fake waeup.kofa get_student_moodle_data method.
         if username == 'bird':
@@ -200,5 +204,5 @@
                         lastname='Charles',
                         )
-        if username in ('fault1', 'fault2', 'fault3', 'fault4'):
+        if username in ('fault1', 'fault2', 'fault3', 'fault4', 'fault5'):
             return dict(email='ff@ff.ff',
                         firstname='John',
@@ -225,5 +229,5 @@
         if arg[0]['username'] == 'fault1':
             raise xmlrpclib.Fault('faultCode', 'faultString')
-        if arg[0]['username'] == 'fault4':
+        if arg[0]['username'] in ('fault4', 'fault5'):
             raise xmlrpclib.Fault('faultCode', 'Username already exists')
         return None
@@ -295,4 +299,10 @@
             'firstname': 'Ray',
             }
+        result = proxy.get_applicant_moodle_data('pig')
+        assert result == {
+            'lastname': 'Charles',
+            'email': 'bb@bb.bb',
+            'firstname': 'Ray',
+            }
         return
 
@@ -323,5 +333,5 @@
         return
 
-    def test_check_credentials_1(self):
+    def test_check_credentials_KofaAuthenticator(self):
         # we get real responses when querying Kofa instances
         auth = KofaAuthenticator(auth_backends=str(BACKENDS2))
@@ -333,21 +343,29 @@
         assert result3 == (False, 'Invalid username or password.')
 
-    def test_check_credentials_2(self):
+    def test_check_credentials_KofaMoodleAuthenticator(self):
         # we get real responses when querying Kofa instances
         auth = KofaMoodleAuthenticator(auth_backends=str(BACKENDS3))
-        result1 = auth.check_credentials('SCHOOL1-bird', 'bebop')
-        assert result1 == (True, '')
-        result2 = auth.check_credentials('SCHOOL1-foo', 'bar')
-        assert result2 == (False, 'Invalid username or password.')
-        result3 = auth.check_credentials('SCHOOL2-bar', 'baz')
-        assert result3 == (False, 'Invalid username or password.')
+        result1s = auth.check_credentials('SCHOOL1-bird', 'bebop')
+        assert result1s == (True, '')
+        result1a  = auth.check_credentials('SCHOOL1-pig', 'pog')
+        assert result1a == (True, '')
+        result2s = auth.check_credentials('SCHOOL1-foo', 'bar')
+        assert result2s == (
+            False, 'Invalid username or password or user not eligible.')
+        result3s = auth.check_credentials('SCHOOL2-bar', 'baz')
+        assert result3s == (
+            False, 'Invalid username or password or user not eligible.')
+
         # exceptions are raised in the follwoing cases
-        result4 = auth.check_credentials('SCHOOL1-fault1', 'biz')
-        assert result4 == (False, 'faultString')
-        result5 = auth.check_credentials('SCHOOL1-fault2', 'biz')
-        assert result5 == (False, 'faultString')
-        result6 = auth.check_credentials('SCHOOL1-fault3', 'biz')
-        assert result6 == (False, 'faultString')
+        result4s = auth.check_credentials('SCHOOL1-fault1', 'biz')
+        assert result4s == (False, 'faultString')
+        result5s = auth.check_credentials('SCHOOL1-fault2', 'biz')
+        assert result5s == (False, 'faultString')
+        result6s = auth.check_credentials('SCHOOL1-fault3', 'biz')
+        assert result6s == (False, 'faultString')
+
         # no exception if user exists
-        result7 = auth.check_credentials('SCHOOL1-fault4', 'biz')
-        assert result7 == (True, '')
+        result7s = auth.check_credentials('SCHOOL1-fault4', 'biz')
+        assert result7s == (True, '')
+        result7a = auth.check_credentials('SCHOOL1-fault5', 'biz')
+        assert result7a == (True, '')
