You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

221 lines
13 KiB

7 years ago
7 years ago
7 years ago
  1. # -*- coding: utf-8 -*-
  2. ###################################################################################
  3. #
  4. # Copyright (C) 2017 MuK IT GmbH
  5. #
  6. # This program is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU Affero General Public License as
  8. # published by the Free Software Foundation, either version 3 of the
  9. # License, or (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU Affero General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU Affero General Public License
  17. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. #
  19. ###################################################################################
  20. import base64
  21. import unittest
  22. from odoo import _
  23. from odoo.tests import common
  24. from .. import controllers
  25. class MailParseTestCase(common.TransactionCase):
  26. at_install = False
  27. post_install = True
  28. def setUp(self):
  29. super(MailParseTestCase, self).setUp()
  30. self.attachment_model = self.env['ir.attachment'].sudo()
  31. self.sample_mail_attachment = self.attachment_model.create({
  32. 'name': 'SampleMail',
  33. 'datas': base64.encodestring("""
  34. Return-Path: <mlemos@acm.org>
  35. To: Manuel Lemos <mlemos@linux.local>
  36. Subject: Testing Manuel Lemos' MIME E-mail composing and sending PHP class: HTML message
  37. From: mlemos <mlemos@acm.org>
  38. Reply-To: mlemos <mlemos@acm.org>
  39. Sender: mlemos@acm.org
  40. X-Mailer: http://www.phpclasses.org/mimemessage $Revision: 1.63 $ (mail)
  41. MIME-Version: 1.0
  42. Content-Type: multipart/mixed; boundary="652b8c4dcb00cdcdda1e16af36781caf"
  43. Message-ID: <20050430192829.0489.mlemos@acm.org>
  44. Date: Sat, 30 Apr 2005 19:28:29 -0300
  45. --652b8c4dcb00cdcdda1e16af36781caf
  46. Content-Type: multipart/related; boundary="6a82fb459dcaacd40ab3404529e808dc"
  47. --6a82fb459dcaacd40ab3404529e808dc
  48. Content-Type: multipart/alternative; boundary="69c1683a3ee16ef7cf16edd700694a2f"
  49. --69c1683a3ee16ef7cf16edd700694a2f
  50. Content-Type: text/plain; charset=ISO-8859-1
  51. Content-Transfer-Encoding: quoted-printable
  52. This is an HTML message. Please use an HTML capable mail program to read
  53. this message.
  54. --69c1683a3ee16ef7cf16edd700694a2f
  55. Content-Type: text/html; charset=ISO-8859-1
  56. Content-Transfer-Encoding: quoted-printable
  57. <html>
  58. <head>
  59. <title>Testing Manuel Lemos' MIME E-mail composing and sending PHP class: H=
  60. TML message</title>
  61. <style type=3D"text/css"><!--
  62. body { color: black ; font-family: arial, helvetica, sans-serif ; backgroun=
  63. d-color: #A3C5CC }
  64. A:link, A:visited, A:active { text-decoration: underline }
  65. --></style>
  66. </head>
  67. <body>
  68. <table background=3D"cid:4c837ed463ad29c820668e835a270e8a.gif" width=3D"100=
  69. %">
  70. <tr>
  71. <td>
  72. <center><h1>Testing Manuel Lemos' MIME E-mail composing and sending PHP cla=
  73. ss: HTML message</h1></center>
  74. <hr>
  75. <P>Hello Manuel,<br><br>
  76. This message is just to let you know that the <a href=3D"http://www.phpclas=
  77. ses.org/mimemessage">MIME E-mail message composing and sending PHP class</a=
  78. > is working as expected.<br><br>
  79. <center><h2>Here is an image embedded in a message as a separate part:</h2>=
  80. </center>
  81. <center><img src=3D"cid:ae0357e57f04b8347f7621662cb63855.gif"></center>Than=
  82. k you,<br>
  83. mlemos</p>
  84. </td>
  85. </tr>
  86. </table>
  87. </body>
  88. </html>
  89. --69c1683a3ee16ef7cf16edd700694a2f--
  90. --6a82fb459dcaacd40ab3404529e808dc
  91. Content-Type: image/gif; name="logo.gif"
  92. Content-Transfer-Encoding: base64
  93. Content-Disposition: inline; filename="logo.gif"
  94. Content-ID: <ae0357e57f04b8347f7621662cb63855.gif>
  95. R0lGODlhlgAjAPMJAAAAAAAA/y8vLz8/P19fX19f339/f4+Pj4+Pz7+/v///////////////////
  96. /////yH5BAEA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1phccPv366mEvWEFSLnj+2QaonECwcJt/
  110. e1Zw3lJvVMmftBdVNQS3UngLCA85YHIQOy6JO9N4eZW7KJwtOUZmGwOMWqejwVW6RQzaikRHX3yI
  111. osKhDAq8wmnKSmdMwNidSOof9ZG2DoV0RfTVmLFtGmNk+CoZna0HQnPHS3AhRbIeDpqmR09E0bsu
  112. soeaw994z+rwQVInvqLenBftYjLOVphLFHhV9qsnez8AEUbQRgO737AxChjmyANxuEFHSGi7hFCV
  113. 4jxLst2N8sRJYU+SHiAKjlmCgz2IffbLI5aaQR71hnkxq1ZfHSfKata6YDCJDMAQwY7wOgzhjxgj
  114. VFQnKB5uX4mr9qJ79pann+VcfcSzsSCd2mw5scqRRvlQ6TgcUelYhu75iPE4JejrsJOFQAG01277
  115. 7bjnrvvuvPfu++/ABy887hfc6OPxyCevPDdAVoDA89BHL/301Fdv/fXYZ6/99tx3Pz0FEQAAOw==
  116. --6a82fb459dcaacd40ab3404529e808dc
  117. Content-Type: image/gif; name="background.gif"
  118. Content-Transfer-Encoding: base64
  119. Content-Disposition: inline; filename="background.gif"
  120. Content-ID: <4c837ed463ad29c820668e835a270e8a.gif>
  121. R0lGODlh+wHCAPMAAKPFzKLEy6HDyqHCyaDByJ/Ax56/xp2+xZ28xJy7w5u6wpq5wZm4wJm3v5i2
  122. vpe1vSwAAAAA+wHCAEME/hDISau9OOvNu/9gKI5kaZ5oqq5s675wLM90bd94ru987//AoHBILBqP
  123. yKRyyWw6n9CodEqtWq+gwSHReHgfjobY8X00FIc019tIHAYS7dqcQCDm3vC4fD4QAhUBBFsMZF8O
  124. hnkLCAYFW11tb1iTlJWWOXJdZZtmC24Eg3hgYntfbXainJ2fgBSZbG5wFAG0E6+RoAZ3CbwJCgya
  125. p3cMbAyevQcFAgMGCcRmxr1uyszOxQq+wF4MdcPFx7zJApfk5eYhr3SSGemRsu3dc+4iAqELhZwO
  126. 0X6hkHUHCBRoGtUg0RkEAAUeKhhGAcICBQIODIPooIEBzCTmKcjGYSNd/go3VvQo65zJkyhTqlzJ
  127. sqXLlzBjypxJs6bNmzhz6tzJs6fPn0CDCh1KtKjRo0iTKl3KtKnTp1CXBhhAwECaq1gPNCIwANDU
  128. qmkMcG311apWULmyZt3alcPXAma1FgAlgCxVq2LbRt3LF0Y7hwWoEjLEDZUmff8AOjMkTB5gwYu3
  129. JbhIQUDEZw+4+aE1aNc0R2vcDYjoDBgpBoUDj95yzzRqbH7qgW4t5vUnAfVAoj7NwOOf1QloN7Ad
  130. u1Xf41b+IlCNsa6rR7DWwTPccTnG5sYvCEKwgPGiZI64A9OsK/Q/BM/0YfuFz13VOwsULLhHps+f
  131. 98Hl0zeDRk0X9Qih/vLPWPjFN197aPyB3IJVBLDMdc5t4OB1A0QowYQQ0vIgdilgyGEgG1roYV0j
  132. GufhhyBSWGF2s2yIYosqWsjgjDTWaOONOOao44489ujjj0AGKeSQRBZp5JFIJqnkkkw26eSTUMJU
  133. llpYseXVXWGNdSGWZ6EVF5VWukUVXFdtRUCEU+bFYpRslqNcYKHgk1k8hxWWxjCM0VkdnINJRtkE
  134. lqH3hWZ/CKJYOBBBJxppu/FWh2qzNUrcmQRE6lpvt+UWUKPD9cbIb5bWhmlxbbL5JoUywiMddHRQ
  135. x591GWqwXXdsfJeoeMO5UZ4/AaaHKXv1xVKgfghuNuyB9fUHHYAA/u2CEIHlGbiffWuWyuSJMmKA
  136. bXbbbtuhi9kCUOIEJY57oYsraoduuOfGWO2J6Vor77z01mvvvfjmq+++/Pbr778AByzwwAQXbPDB
  137. CCfcZDobldLRVfLEEgerjQ1EEEemJMiioZEdkggYizSiqMQKl5wCw6qswg+rDTvc6h0Wq9KAJ5tV
  138. oGpJF9YysXn8lCfNL8HE88xw4EyzTDNDR4MMNUhfk40mhXkDTdHimHzjzRpgDcB0MEeHswf1sCZn
  139. GfrQDMrIAYZEkEEOJTQRQweBp5FIDTGCEUiHYWwRXHOPMpLdVgcu+OCEF2744YgnrvjijDfu+OOQ
  140. Ry755JRXbvnl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svc5jr3udCNrnSnS93qWve62M2udrfL
  154. 3e5697vgDa94x0ve8pr3vOhNr3rXy972uve98I2vfOdLXxrBS0Uv8lZGUaUh/OKXXRmAV7jMVV+X
  155. QLK4vD0TaoHLWq1UEsEJFu0FXknLh3iyM5EssEtQlrK98ZN5QbNqyl71pwqEza752MfZEqrhljg1
  156. pYMKkBh3FuKTXtUX+LupMkwcETNCA40D6QNiA3tfdunXAkdOEX+1Ba68tjiqLbVOnKp60oNAam6J
  157. fcyUvTYLAnDHOw8Jjx7Js71YTKWzxX1IV76iyayuWTCwDSIgKJxmqLI5zmp6sg5ZNdV7bkPGQWYh
  158. 0EzR/s8+A1THEt6hIrx6IbByRawKHKjfpEfExVREpUEdzKX3dJe5UaQ6UdT0p18VGCfPF2X8S4QD
  159. QgaamI24hi1TtTxZyuVZ6AzK6gBnIbE66DmhImlzxAYouUq0XQ+oUhG039P+rAZgG7u1erYFyy6W
  160. Tt85ddkmHak3PWVaWuePAC9F4Mh6dgdjB/A8tCqbscUxWLmumxp8jsa5A5RuY7xbwtHGtT+Phz69
  161. nGo0WC60DPt9u0AljxWG8kylh9hsRKw1jbiwx24cDsUKSRwYFPdIq2347NoWkSEAKnG++brnGes7
  162. sYH1QPVqVdDsOZZXUlN2WYO1soCA9JBoScjNQdvs/n3fKXaxYefOH9BDfD+Z5Db78Dv+WuWUd4Bj
  163. YwPDx1bNiI03BoO7yRi9CzJBBLlQdj5tTbKIOFQqikHjruN6Bovlw5GnXZxjtMXbZ01O2NnhdawL
  164. ASOFw8BIxpOSuutUYWfmBjW0U1S+gczhqy0Wzuhmd7Ur5RYW/01Tz3dKcpYVl/Isrs2jBSyZJ4H7
  165. LIq+4VYUL2NZaCMgQiY1LXSjFH09wWexvovGvvawX2q+d8/73vv+98APvvCHT/ziG//4yE++8pfP
  166. /OY7//nQj770p0/96lv/+tjPvva3z/3ue//74A+/+MdP/vKb//zoT7/6e3Lf/3KryTDKUPvdBQIB
  167. /q+JwOuPwYEhbFzcYDjDuPN/lARL/FdLRlcZwdUNnTRbGAZt+fcCHCYzGqd0NJZtrsYJFjFGJ2ZQ
  168. m1A2kcZiD+gXLKNsMMZsTQdiFvg/IJUID7RjldFjhAVkGaM/6lASRfYu8KcuS6aDO4hkOfh7p7Jl
  169. bBRlVxYSWSZlfVKDXfZltRJmADFmulJmb3BmBJhbb9YZp1RLV9hmwtUWdBZhnYeFCaZ7Rxdv/5Q8
  170. gKaCvNBrQ0hCZxhjLhgHXEV1PiQIjhBEkDZT6VFSmkFWhbBppMZBljZqVtZpIUGIqCNqevMYlhdf
  171. qEYKslZ10zZibbgQDkN1IndyTkcLxiFTulZI/muYRsrjbKA4bNYwNR1nPsn2K6J4PKdYbKXYbSM3
  172. bSQVeWdybWwIa9Rmi0b3FwUEKAcUU+MGTr4AivP2hGSgbqDIbjDobssIb1IlbzSEbslob894gGUY
  173. jYkxeyf3GABnhAK3jeTDYxE0J5uRcEtjdYUnaoMXHStGGxlnNxs4cYgARRt3Y8UobB5XVhhXjyTR
  174. e0jnbfoURkGzDh+wcquACmqFUDD3iiw0LZFmczhmWTknkZ9FdK5IDH0GdArWGaB4kUXHewEpbSZH
  175. kLX2AVA3dVPHamgjNQ8XZG0Ddl2XLF9HOmF3RPmTKGV3IGdXdWl3k2zXiPBVd3nXV3PHOkRpgk5A
  176. lYlgg2F8Fw3WlnZW9HiCB2Q0Y3ic8k2Kl5V4JQhUiXgWFgqUh1e9h3mcpy2epxdm+XnjQ1EiMHoQ
  177. pVtogiWuV3urBxGod4Xnw41huJfjKHvtg3t8GYKEWZiGeZiImZiKuZiM2ZiO+ZiQGZmSOZmUWZmW
  178. eZmYmZmauZmc2ZlCEQEAOw==
  179. --6a82fb459dcaacd40ab3404529e808dc--
  180. --652b8c4dcb00cdcdda1e16af36781caf
  181. Content-Type: text/plain; name="attachment.txt"
  182. Content-Transfer-Encoding: base64
  183. Content-Disposition: attachment; filename="attachment.txt"
  184. VGhpcyBpcyBqdXN0IGEgcGxhaW4gdGV4dCBhdHRhY2htZW50IGZpbGUgbmFtZWQgYXR0YWNobWVu
  185. dC50eHQgLg==
  186. --652b8c4dcb00cdcdda1e16af36781caf--
  187. """)
  188. })
  189. def tearDown(self):
  190. super(MailParseTestCase, self).tearDown()
  191. def test_parse_mail(self):
  192. pass
  193. # FIXME
  194. # self.assertTrue(controllers.main.MailParserController().parse_mail('/web/content/%s?download=true' % self.sample_mail_attachment.id))