def test_user_creation(self):
        setRoles(self.portal, TEST_USER_ID, ('Manager',))

        # create a folder for covalent-members:
        members = helpers.create_memberfolder(self.portal)

        # create a user:
        utilities.add_member_object(members, member_id='m1',
            fullname=u"Hörbert M@ier", email="*****@*****.**")
        self.assertIn('m1', members)

        m1 = members['m1']
        message = self.mailhost.messages[0]
        expectedMessageText = '\n'.join([
            "Hello H=C3=B6rbert M@ier!",
            '',
            "Please follow this link to activate your account on Plone site:",
            m1.absolute_url() + '/activate?activation_code=3D' + m1.activation_code,
            '', '', ])

        self.assertEqual(message.get_charset(), 'utf-8')
        self.assertIsInstance(message['To'], basestring)
        self.assertEqual(message['To'], u'Hörbert M[at]ier <*****@*****.**>')
        self.assertIsInstance(message['From'], basestring)
        self.assertEqual(message['From'], u'Plone site <>')
        self.assertEqual(unicode(message['Subject']),
            u"You've been invited to Plone site")
        self.assertEqual(message.get_payload(), expectedMessageText)
    def test_user_activation(self):
        setRoles(self.portal, TEST_USER_ID, ('Manager',))

        # create a folder for covalent-members:
        members = helpers.create_memberfolder(self.portal)

        # create a user:
        member = utilities.add_member_object(members, member_id='member',
            fullname=u"Hörbert M@ier", email="*****@*****.**")

        logout()

        password = '******'
        utilities.add_plone_member(member, 'secret')
        utilities.activate_member_object(member)

        plone_member = self.portal.acl_users.authenticate(member.id, password,
            self.portal.REQUEST)
        self.assertEqual(plone_member.getId(), member.id)

        portal_membership = getToolByName(self.portal, 'portal_membership')
        plone_member = portal_membership.getMemberById(member.id)
        self.assertEqual(plone_member.getId(), member.id)

        self.assertEqual(unicode(plone_member.getProperty('fullname'), 'utf-8'),
            member.title)
        self.assertEqual(plone_member.getProperty('email'), member.emailAddress)

        login(self.portal, member.id)
Beispiel #3
0
    def test_user_import_from_excel_file(self):
        setRoles(self.portal, TEST_USER_ID, ('Manager',))

        # create a folder for covalent-members:
        members = helpers.create_memberfolder(self.portal)

        # extract members from file:
        excel_file_path = helpers.absolute_dir("assets/covalent_batch.xls")
        excel_file = open(excel_file_path, "r+b")
        filedata = mmap.mmap(excel_file.fileno(), 0)

        user_infos = member_import.extract_memberdata(filedata)

        filedata.close()
        excel_file.close()

        # add covalent-members:
        utilities.add_members(members, user_infos)

        # inspect our covalent-members:
        for properties in user_infos:
            memberId = properties['id']
            self.assertIn(memberId, members)
            member = members[memberId]
            self.assertEqual(member.title, properties['title'])
            self.assertEqual(member.emailAddress, properties['emailAddress'])
Beispiel #4
0
    def test_user_import_from_plone(self):
        setRoles(self.portal, TEST_USER_ID, ('Manager',))

        # create a few plone members:
        ploneMembers = [
            {'username': '******', 'fullname': u'M. Membrane',
                'email': '*****@*****.**', },
            {'username': '******', 'fullname': u'Inge Onken',
                'email': '*****@*****.**', },
            {'username': '******', 'fullname': u'Onkel Töm',
                'email': '*****@*****.**', }, ]

        for properties in ploneMembers:
            memberId = properties['username']
            self.portal.portal_registration.addMember(
                memberId, 'password', properties=properties)

        # create a folder for covalent-members:
        members = helpers.create_memberfolder(self.portal)

        # import members:
        utilities.import_plone_users(members)

        # inspect our covalent-members:
        for properties in ploneMembers:
            memberId = properties['username']
            self.assertIn(memberId, members)
            member = members[memberId]
            self.assertEqual(member.title, properties['fullname'])
            self.assertEqual(member.emailAddress, properties['email'])
    def test_user_creation(self):
        """
        Test user creation by Site Admin with automatic approval.
        """

        setRoles(self.portal, TEST_USER_ID, ('Site Administrator',))

        # create a folder for covalent-members:
        members = helpers.create_memberfolder(self.portal)

        # create a user:
        utilities.add_member_object(members, member_id='m2',
            fullname=u"Ilse Pambrowski", email="*****@*****.**")
        self.assertIn('m2', members)

        member = members['m2']

        pw = getToolByName(self.portal, 'portal_workflow')
        self.assertEqual(pw.getInfoFor(member, 'review_state'), 'pending')
        self.assertEqual(member.title, u"Ilse Pambrowski")
        self.assertEqual(member.emailAddress, "*****@*****.**")

        message = self.mailhost.messages[0]

        expectedMessageTpl = """Hello {name}!

You have been invited to the {site_title} site.

Please follow this link to activate your account on the {site_title} site:

{url}/activate?activation_code={activation_code}

This activation link is valid for {activation_period} days.

Your username is: {userId}

"""
        registry = getUtility(IRegistry)
        activation_period = registry['cnrd.vctypes.memberActivationTimeout']

        tplParams = {
            'url': member.absolute_url(),
            'activation_code': member.activation_code,
            'activation_period': activation_period,
            'userId': 'm2',
            'site_title': 'Plone site',
            'name': 'Ilse Pambrowski'
        }
        expectedMessageText = expectedMessageTpl.format(**tplParams)

        self.assertEqual(message.get_charset(), 'utf-8')
        self.assertIsInstance(message['To'], basestring)
        self.assertEqual(message['To'], u'Ilse Pambrowski <*****@*****.**>')
        self.assertIsInstance(message['From'], basestring)
        self.assertEqual(message['From'], u'Plone site <>')
        self.assertEqual(unicode(message['Subject']),
            u"You've been invited to Plone site")
        self.assertEqual(message.get_payload(None, True), expectedMessageText)
Beispiel #6
0
    def test_get_member_by_id(self):
        setRoles(self.portal, TEST_USER_ID, ('Manager',))

        # create a folder for covalent-members:
        members = helpers.create_memberfolder(self.portal)

        # create a user:
        member = utilities.add_member_object(members, member_id='member',
            fullname=u"Hörbert M@ier", email="*****@*****.**")

        self.assertEqual(member, utilities.get_member_by_id(member.id))
        self.assertEqual(None, utilities.get_member_by_id('no_such_id'))
    def test_user_self_registration(self):
        """
        Test user self registration by anonymous user.
        """

        # create a folder for covalent-members (temporarily become Manager):
        setRoles(self.portal, TEST_USER_ID, ('Manager',))
        members = helpers.create_memberfolder(self.portal)

        # create a user (become Anonymous):
        setRoles(self.portal, TEST_USER_ID, ('Anonymous', 'Registrator'))
        utilities.add_member_object(members, member_id='m1',
            fullname=u"Hörbert M@ier", email="*****@*****.**")
        self.assertIn('m1', members)

        member = members['m1']

        pw = getToolByName(self.portal, 'portal_workflow')
        self.assertEqual(pw.getInfoFor(member, 'review_state'), 'new')
        self.assertEqual(member.title, u"Hörbert M@ier")
        self.assertEqual(member.emailAddress, "*****@*****.**")

        message = self.mailhost.messages[0]

        expectedMessageTpl = """Hello!

{name} registered with username {userId} for the {site_title} site.

Please follow this link to review the new user: {expectedMemberUrl}

The membership of {name} has to be approved before he/she can start using the site.

You are receiving this e-mail because you are registered as site administrator of the {site_title} site.
"""

        tplParams = {
            'expectedMemberUrl': member.absolute_url(),
            'userId': 'm1',
            'site_title': 'Plone site',
            'name': 'Hörbert M@ier'
        }
        expectedMessageText = expectedMessageTpl.format(**tplParams)

        self.assertEqual(message.get_charset(), 'utf-8')
        self.assertIsInstance(message['To'], basestring)
        self.assertEqual(message['To'], u' <*****@*****.**>')
        self.assertIsInstance(message['From'], basestring)
        self.assertEqual(message['From'], u'Plone site <>')
        self.assertEqual(unicode(message['Subject']),
            u"Please approve or reject new member Hörbert M@ier")
        self.assertEqual(message.get_payload(None, True), expectedMessageText)
    def test_edit_member(self):
        driver = self.driver
        pat.setRoles(self.portal, pat.TEST_USER_ID, ('Manager',))
        members = helpers.create_memberfolder(self.portal)
        member = utilities.add_member_object(members, member_id='m1',
            fullname=u"Hörbert M@ier", email="*****@*****.**")

        login(driver, self.portal, username=testing.SITE_ADMIN,
            password=testing.PASSWORD)
        open(driver, '/'.join([self.portal.absolute_url(), members.id, member.id, "edit"]))

        email = driver.find_element_by_id(
            "form-widgets-ICovalentMember-emailAddress")
        email.clear()
        email.send_keys("*****@*****.**")

        driver.find_element_by_id("form-buttons-save").click()
    def test_user_import_from_excel_file_acceptance(self):
        driver = self.driver

        # create a folder for covalent-members:
        pat.setRoles(self.portal, pat.TEST_USER_ID, ('Manager',))
        members = helpers.create_memberfolder(self.portal)

        # log in as a manager:
        login(driver, self.portal, username=testing.MANAGER,
            password=testing.PASSWORD)

        open(driver, members.absolute_url() + "/import")

        fileUpload = driver.find_element_by_name("form.widgets.file")
        filename = helpers.absolute_dir("assets/covalent_batch.xls")
        fileUpload.send_keys(filename)
        driver.find_element_by_id("form-buttons-save").click()

        # TODO: assert

        driver.find_element_by_name("confirm").click()
    def test_member_folder_creation(self):
        setRoles(self.portal, TEST_USER_ID, ("Manager",))

        # create a folder for covalent-members:
        members = helpers.create_memberfolder(self.portal)
        self.assertIn(members.id, self.portal)