Example #1
0
    def test_use_email_as_login_enabled(self):
        """Test generating user_id with no custom login name generator and
        with the use_email_as_login security setting enabled.
        """
        form = BaseRegistrationForm(self.portal, {})
        data = {'username': '******', 'email': '*****@*****.**'}
        self.security_settings.use_email_as_login = True

        self.assertEqual(form.generate_login_name(data), '*****@*****.**')
        self.assertEqual(data.get('login_name'), '*****@*****.**')
    def test_use_email_as_login_enabled(self):
        """Test generating user_id with no custom login name generator and
        with the use_email_as_login security setting enabled.
        """
        form = BaseRegistrationForm(self.portal, {})
        data = {'username': '******', 'email': '*****@*****.**'}
        self.security_settings.use_email_as_login = True

        self.assertEqual(form.generate_login_name(data), '*****@*****.**')
        self.assertEqual(data.get('login_name'), '*****@*****.**')
Example #3
0
    def test_custom_generator(self):
        """Test if a custom login name generator overrides the default
        behavior.
        """
        sm = getSiteManager(context=self.portal)
        form = BaseRegistrationForm(self.portal, {})
        data = {'useme': 'me me me', 'username': '******'}

        sm.registerUtility(lambda data: data['useme'],
                           provided=ILoginNameGenerator)

        self.assertEqual(form.generate_login_name(data), 'me me me')
        self.assertEqual(data.get('login_name'), 'me me me')
Example #4
0
    def test_custom_generator_empty(self):
        """Test that the username is used if a custom login name generator
        returns an empty value.
        """
        sm = getSiteManager(context=self.portal)
        form = BaseRegistrationForm(self.portal, {})
        data = {'useme': '', 'username': '******'}

        sm.registerUtility(lambda data: data['useme'],
                           provided=ILoginNameGenerator)

        self.assertEqual(form.generate_login_name(data), 'Frank')
        self.assertEqual(data.get('login_name'), 'Frank')
    def test_custom_generator_empty(self):
        """Test that the username is used if a custom login name generator
        returns an empty value.
        """
        sm = getSiteManager(context=self.portal)
        form = BaseRegistrationForm(self.portal, {})
        data = {'useme': '', 'username': '******'}

        sm.registerUtility(
            lambda data: data['useme'], provided=ILoginNameGenerator)

        self.assertEqual(form.generate_login_name(data), 'Frank')
        self.assertEqual(data.get('login_name'), 'Frank')
    def test_custom_generator(self):
        """Test if a custom login name generator overrides the default
        behavior.
        """
        sm = getSiteManager(context=self.portal)
        form = BaseRegistrationForm(self.portal, {})
        data = {'useme': 'me me me', 'username': '******'}

        sm.registerUtility(
            lambda data: data['useme'], provided=ILoginNameGenerator)

        self.assertEqual(form.generate_login_name(data), 'me me me')
        self.assertEqual(data.get('login_name'), 'me me me')
 def generateLoginName(self, data):
     """Generate login name, optionally registering function first"""
     form = BaseRegistrationForm(self.portal, {})
     return form.generate_login_name(data)