Index: /main/waeup.cas/trunk/waeup/cas/tests/test_authenticators.py
===================================================================
--- /main/waeup.cas/trunk/waeup/cas/tests/test_authenticators.py	(revision 10523)
+++ /main/waeup.cas/trunk/waeup/cas/tests/test_authenticators.py	(revision 10524)
@@ -186,5 +186,5 @@
                     'type': 'applicant'}
         if username in (
-            'fault1', 'fault2', 'fault3', 'fault4') and password == 'biz':
+            'fault1', 'fault2', 'fault3', 'fault4', 'fault7') and password == 'biz':
             return {'type': 'student'}
         if username == 'fault5' and password == 'biz':
@@ -206,5 +206,6 @@
                         lastname='Charles',
                         )
-        if username in ('fault1', 'fault2', 'fault3', 'fault4', 'fault5'):
+        if username in ('fault1', 'fault2', 'fault3',
+                        'fault4', 'fault5', 'fault7'):
             return dict(email='ff@ff.ff',
                         firstname='John',
@@ -233,4 +234,6 @@
         if arg[0]['username'] in ('school1-fault4', 'school1-fault5'):
             raise xmlrpclib.Fault('faultCode', 'Username already exists')
+        if arg[0]['username'] == 'school1-fault7':
+            raise xmlrpclib.Fault('faultCode', 'Email address already exists')
         return None
 
@@ -250,6 +253,6 @@
 
 class KofaAuthenticatorsIntegrationTests(unittest.TestCase):
-    # A test case where a fake Kofa server is started before tests (and
-    # shut down afterwards).
+    # A test case where a fake Kofa server and a fake Moodle server
+    # are started before tests (and shut down afterwards).
 
     kofa_server = None
@@ -319,4 +322,7 @@
             xmlrpclib.Fault, proxy.core_user_create_users,
             [{'username': 'school1-fault1'}])
+        self.assertRaises(
+            xmlrpclib.Fault, proxy.core_user_create_users,
+            [{'username': 'school1-fault7'}])
         # test core_user_get_users
         result = proxy.core_user_get_users(
@@ -358,4 +364,8 @@
         result8 = auth.check_credentials('SCHOOL1-fault6', 'biz')
         assert result8 == (False, 'User not eligible')
+        result9 = auth.check_credentials('SCHOOL1-fault7', 'biz')
+        assert result9 == (False,
+                    'Another Moodle user is using the same email address.'
+                    ' Email addresses can\'t be used twice in Moodle.')
 
         # exceptions are raised in the following cases
@@ -372,2 +382,15 @@
         result7a = auth.check_credentials('SCHOOL1-fault5', 'biz')
         assert result7a == (True, '')
+
+        # If marker is an empty sring school markers are neither
+        # checked nor removed.
+        BACKENDS3['inst1']['marker'] = ''
+        auth = KofaMoodleAuthenticator(auth_backends=str(BACKENDS3))
+        result10s = auth.check_credentials('bird', 'bebop')
+        assert result10s == (True, '')
+        result10a = auth.check_credentials('pig', 'pog')
+        assert result10a == (True, '')
+        result11s = auth.check_credentials('SCHOOL1-bird', 'bebop')
+        assert result11s == (False, 'Invalid username or password')
+        result11a = auth.check_credentials('SCHOOL1-pig', 'pog')
+        assert result11a == (False, 'Invalid username or password')
