def test_address_resolves_to_dossier(self):
        intid = self.intids.queryId(self.dossier)
        email_address = "%s@%s" % (intid, self.mail_domain)

        adapter = IEmailAddress(self.request)
        obj = adapter.get_object_for_email(email_address)
        self.assertEquals(self.dossier, obj)
Пример #2
0
    def get_destination(self):
        emailaddress = IEmailAddress(self.request)
        destination = emailaddress.get_object_for_email(self.recipient())

        if destination is None:
            raise exceptions.DestinationDoesNotExist(self.recipient())
        return destination
    def test_mail_in_address_for_dossier(self):
        intid = self.intids.queryId(self.dossier)
        expected = "%s@%s" % (intid, self.mail_domain)

        adapter = IEmailAddress(self.request)
        mail_address = adapter.get_email_for_object(self.dossier)
        self.assertEquals(expected, mail_address)
Пример #4
0
class TestUUIDResolver(TestCase):

    layer = FTW_MAIL_FUNCTIONAL_TESTING

    def setUp(self):
        self.portal = self.layer.get('portal')

        setRoles(self.portal, TEST_USER_ID, ['Manager', 'Member'])

        self.subfolder = create(Builder('folder'))

        self.request = TestRequest()
        self.emailaddress = IEmailAddress(self.request)

    def test_verify_adapter(self):
        verifyClass(IEmailAddress, UUIDEmailAddress)

    def test_get_object_for_email(self):
        email = "*****@*****.**" % IUUID(self.subfolder)

        self.assertEquals(self.subfolder,
                          self.emailaddress.get_object_for_email(email))

    def test_get_email_for_object(self):
        email = "*****@*****.**" % IUUID(self.subfolder)
        self.assertEquals(
            email,
            self.emailaddress.get_email_for_object(self.subfolder))

    def test_get_email_for_object_with_different_domain(self):
        email = "*****@*****.**" % IUUID(self.subfolder)
        self.assertEquals(
            email,
            self.emailaddress.get_email_for_object(self.subfolder,
                                                   'otherdomain.org'))
Пример #5
0
    def setUp(self):
        self.portal = self.layer.get('portal')

        setRoles(self.portal, TEST_USER_ID, ['Manager', 'Member'])

        self.subfolder = create(Builder('folder'))

        self.request = TestRequest()
        self.emailaddress = IEmailAddress(self.request)
Пример #6
0
    def setUp(self):
        super(TestInboundMail, self).setUp()

        self.portal = self.layer['portal']
        setRoles(self.portal, TEST_USER_ID, ['Manager', ])

        wftool = getToolByName(self.portal, 'portal_workflow')
        wftool.setChainForPortalTypes(('Folder',),
                                      ('simple_publication_workflow',))

        self.folder = create(Builder('folder'))

        here = os.path.dirname(__file__)
        self.ascii = open(os.path.join(here, 'mails', 'ascii_7bit.txt'), 'r').read()
        self.resent = open(os.path.join(here, 'mails', 'resent.txt'), 'r').read()
        # setup recipient and sender email addresses for test user
        mtool = getToolByName(self.portal, 'portal_membership')
        user = mtool.getAuthenticatedMember()
        user.setMemberProperties(dict(email='*****@*****.**'))

        emailaddress = IEmailAddress(TestRequest())
        self.mail_to = emailaddress.get_email_for_object(self.folder)

        logout()
Пример #7
0
    def test_dossier_attributes(self):
        site_id = api.portal.get().id
        path_segments = [
            s for s in self.dossier.getPhysicalPath() if s != site_id
        ]
        path_segments.append('attributes')
        dossier_attributes_path = '/'.join(path_segments)
        attributes = self.api.get(dossier_attributes_path).json()

        # Catch future changes to the API
        self.assertEqual(1, len(attributes.keys()))

        self.assertIn('email', attributes)

        dossier_email = IEmailAddress(self.request).get_email_for_object(
            self.dossier)
        self.assertEqual(dossier_email, attributes['email'])
Пример #8
0
    def test_attach_to_outlook_payload_with_file_and_open_dossier(
            self, browser):  # noqa
        self.enable_attach_to_outlook()
        payload = self.get_oc_url_jwt_decoded(self.doc_with_file_wf_open,
                                              'attach')

        self.assertIn('documents', payload)
        self.assertIn(api.content.get_uuid(self.doc_with_file_wf_open),
                      payload['documents'])

        self.assertIn('action', payload)
        self.assertEqual('attach', payload['action'])

        # Test we can actually fetch an action payload based on the JWT payload
        response = self.get_oc_payload_response(payload)
        self.assertEqual(200, response.status_code)

        payload = response.json()
        self.assertEqual(1, len(payload))
        payload = payload[0]

        self.assertIn('bcc', payload)
        bcc = IEmailAddress(self.request).get_email_for_object(
            self.open_dossier)
        self.assertEqual(bcc, payload['bcc'])

        self.assertIn('title', payload)
        self.assertEqual(self.doc_with_file_wf_open.title_or_id(),
                         payload['title'])

        # Test there is also a journal entry from the attach action
        browser.login()
        browser.open(self.doc_with_file_wf_open,
                     view='tabbedview_view-journal')
        journal_entry = browser.css('.listing').first.lists()[1]
        self.assertEqual(journal_entry[1],
                         'Dokument mit Mailprogramm versendet')

        # Test there is also a journal entry in the dossier
        browser.login()
        browser.open(self.open_dossier, view='tabbedview_view-journal')
        journal_entry = browser.css('.listing').first.lists()[1]
        self.assertEqual(journal_entry[1],
                         'Dokument im Dossier mit Mailprogramm versendet')
Пример #9
0
 def render(self):
     payload = {}
     payload['email'] = IEmailAddress(self.request).get_email_for_object(
         self.context)
     return json.dumps(payload)
Пример #10
0
 def render(self):
     payload = {}
     if api.user.has_permission('Modify portal content', obj=self.context):
         payload['email'] = IEmailAddress(
             self.request).get_email_for_object(self.context)
     return json.dumps(payload)
Пример #11
0
 def email(self):
     """Gets Email and display it in Byline"""
     mail_address = IEmailAddress(self.request
         ).get_email_for_object(self.context)
     return mail_address
Пример #12
0
 def email(self):
     email = IEmailAddress(self.request)
     return email.get_email_for_object(self.context)