parent
a0c3b26732
commit
03366d2a38
@ -1,5 +1,5 @@ |
||||
x-sender: <jsmith@somenet.foo> |
||||
x-receiver: <redmine@somenet.foo> |
||||
x-receiver: <openproject@somenet.foo> |
||||
Received: from [127.0.0.1] ([127.0.0.1]) by somenet.foo with Quick 'n Easy Mail Server SMTP (1.0.0.0); |
||||
Sun, 14 Dec 2008 16:18:06 GMT |
||||
Message-ID: <494531B9.1070709@somenet.foo> |
@ -1,7 +1,7 @@ |
||||
Content-Type: application/ms-tnef; name="winmail.dat" |
||||
Content-Transfer-Encoding: binary |
||||
From: John Smith <JSmith@somenet.foo> |
||||
To: "redmine@somenet.foo" <redmine@somenet.foo> |
||||
To: "openproject@somenet.foo" <redmine@somenet.foo> |
||||
Subject: =?iso-8859-1?Q?Testmail_from_Webmail:_=E4_=F6_=FC...?= |
||||
Date: Fri, 1 Jun 2012 14:39:38 +0200 |
||||
Message-ID: <87C31D42249DD0489D1A1444E3232DD7019D6183@foo.bar> |
@ -1,48 +0,0 @@ |
||||
Return-Path: <JSmith@somenet.foo> |
||||
Received: from osiris ([127.0.0.1]) |
||||
by OSIRIS |
||||
with hMailServer ; Sun, 22 Jun 2008 12:28:07 +0200 |
||||
Message-ID: <000501c8d452$a95cd7e0$0a00a8c0@osiris> |
||||
In-Reply-To: <openproject.issue-1-2.20060719210421@osiris> |
||||
From: "John Smith" <JSmith@somenet.foo> |
||||
To: <openproject@somenet.foo> |
||||
Subject: Re: update to issue 2 |
||||
Date: Sun, 22 Jun 2008 12:28:07 +0200 |
||||
MIME-Version: 1.0 |
||||
Content-Type: text/plain; |
||||
format=flowed; |
||||
charset="iso-8859-1"; |
||||
reply-type=original |
||||
Content-Transfer-Encoding: 7bit |
||||
X-Priority: 3 |
||||
X-MSMail-Priority: Normal |
||||
X-Mailer: Microsoft Outlook Express 6.00.2900.2869 |
||||
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 |
||||
|
||||
An update to the issue by the sender. |
||||
|
||||
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas imperdiet |
||||
turpis et odio. Integer eget pede vel dolor euismod varius. Phasellus |
||||
blandit eleifend augue. Nulla facilisi. Duis id diam. Class aptent taciti |
||||
sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. In |
||||
in urna sed tellus aliquet lobortis. Morbi scelerisque tortor in dolor. Cras |
||||
sagittis odio eu lacus. Aliquam sem tortor, consequat sit amet, vestibulum |
||||
id, iaculis at, lectus. Fusce tortor libero, congue ut, euismod nec, luctus |
||||
eget, eros. Pellentesque tortor enim, feugiat in, dignissim eget, tristique |
||||
sed, mauris --- Pellentesque habitant morbi tristique senectus et netus et |
||||
malesuada fames ac turpis egestas. Quisque sit amet libero. In hac habitasse |
||||
platea dictumst. |
||||
|
||||
>> > --- Reply above. Do not remove this line. --- |
||||
>> > |
||||
>> > Issue #6779 has been updated by Eric Davis. |
||||
>> > |
||||
>> > Subject changed from Projects with JSON to Project JSON API |
||||
>> > Status changed from New to Assigned |
||||
>> > Assignee set to Eric Davis |
||||
>> > Priority changed from Low to Normal |
||||
>> > Estimated time deleted (1.00) |
||||
>> > |
||||
>> > Looks like the JSON api for projects was missed. I'm going to be |
||||
>> > reviewing the existing APIs and trying to clean them up over the next |
||||
>> > few weeks. |
@ -1,48 +0,0 @@ |
||||
Return-Path: <JSmith@somenet.foo> |
||||
Received: from osiris ([127.0.0.1]) |
||||
by OSIRIS |
||||
with hMailServer ; Sun, 22 Jun 2008 12:28:07 +0200 |
||||
Message-ID: <000501c8d452$a95cd7e0$0a00a8c0@osiris> |
||||
In-Reply-To: <openproject.issue-1-2.20060719210421@osiris> |
||||
From: "John Smith" <JSmith@somenet.foo> |
||||
To: <openproject@somenet.foo> |
||||
Subject: Re: update to issue 2 |
||||
Date: Sun, 22 Jun 2008 12:28:07 +0200 |
||||
MIME-Version: 1.0 |
||||
Content-Type: text/plain; |
||||
format=flowed; |
||||
charset="iso-8859-1"; |
||||
reply-type=original |
||||
Content-Transfer-Encoding: 7bit |
||||
X-Priority: 3 |
||||
X-MSMail-Priority: Normal |
||||
X-Mailer: Microsoft Outlook Express 6.00.2900.2869 |
||||
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 |
||||
|
||||
An update to the issue by the sender. |
||||
|
||||
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas imperdiet |
||||
turpis et odio. Integer eget pede vel dolor euismod varius. Phasellus |
||||
blandit eleifend augue. Nulla facilisi. Duis id diam. Class aptent taciti |
||||
sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. In |
||||
in urna sed tellus aliquet lobortis. Morbi scelerisque tortor in dolor. Cras |
||||
sagittis odio eu lacus. Aliquam sem tortor, consequat sit amet, vestibulum |
||||
id, iaculis at, lectus. Fusce tortor libero, congue ut, euismod nec, luctus |
||||
eget, eros. Pellentesque tortor enim, feugiat in, dignissim eget, tristique |
||||
sed, mauris --- Pellentesque habitant morbi tristique senectus et netus et |
||||
malesuada fames ac turpis egestas. Quisque sit amet libero. In hac habitasse |
||||
platea dictumst. |
||||
|
||||
> --- Reply above. Do not remove this line. --- |
||||
> |
||||
> Issue #6779 has been updated by Eric Davis. |
||||
> |
||||
> Subject changed from Projects with JSON to Project JSON API |
||||
> Status changed from New to Assigned |
||||
> Assignee set to Eric Davis |
||||
> Priority changed from Low to Normal |
||||
> Estimated time deleted (1.00) |
||||
> |
||||
> Looks like the JSON api for projects was missed. I'm going to be |
||||
> reviewing the existing APIs and trying to clean them up over the next |
||||
> few weeks. |
@ -1,18 +0,0 @@ |
||||
Return-Path: <john.doe@somenet.foo> |
||||
Received: from osiris ([127.0.0.1]) |
||||
by OSIRIS |
||||
with hMailServer ; Sun, 22 Jun 2008 12:28:07 +0200 |
||||
Message-ID: <000501c8d452$a95cd7e0$0a00a8c0@osiris> |
||||
From: "John Doe" <john.doe@somenet.foo> |
||||
To: <redmine@somenet.foo> |
||||
Subject: Ticket by unknown user |
||||
Date: Sun, 22 Jun 2008 12:28:07 +0200 |
||||
MIME-Version: 1.0 |
||||
Content-Type: text/plain; |
||||
format=flowed; |
||||
charset="iso-8859-1"; |
||||
reply-type=original |
||||
Content-Transfer-Encoding: 7bit |
||||
|
||||
This is a ticket submitted by an unknown user. |
||||
|
@ -1,60 +0,0 @@ |
||||
Return-Path: <JSmith@somenet.foo> |
||||
Received: from osiris ([127.0.0.1]) |
||||
by OSIRIS |
||||
with hMailServer ; Sun, 22 Jun 2008 12:28:07 +0200 |
||||
Message-ID: <000501c8d452$a95cd7e0$0a00a8c0@osiris> |
||||
From: "John Smith" <JSmith@somenet.foo> |
||||
To: <openproject@somenet.foo> |
||||
Subject: New ticket on a given project |
||||
Date: Sun, 22 Jun 2008 12:28:07 +0200 |
||||
MIME-Version: 1.0 |
||||
Content-Type: text/plain; |
||||
format=flowed; |
||||
charset="iso-8859-1"; |
||||
reply-type=original |
||||
Content-Transfer-Encoding: 7bit |
||||
X-Priority: 3 |
||||
X-MSMail-Priority: Normal |
||||
X-Mailer: Microsoft Outlook Express 6.00.2900.2869 |
||||
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 |
||||
|
||||
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas imperdiet |
||||
turpis et odio. Integer eget pede vel dolor euismod varius. Phasellus |
||||
blandit eleifend augue. Nulla facilisi. Duis id diam. Class aptent taciti |
||||
sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. In |
||||
in urna sed tellus aliquet lobortis. Morbi scelerisque tortor in dolor. Cras |
||||
sagittis odio eu lacus. Aliquam sem tortor, consequat sit amet, vestibulum |
||||
id, iaculis at, lectus. Fusce tortor libero, congue ut, euismod nec, luctus |
||||
eget, eros. Pellentesque tortor enim, feugiat in, dignissim eget, tristique |
||||
sed, mauris --- Pellentesque habitant morbi tristique senectus et netus et |
||||
malesuada fames ac turpis egestas. Quisque sit amet libero. In hac habitasse |
||||
platea dictumst. |
||||
|
||||
--- This line starts with a delimiter and should not be stripped |
||||
|
||||
This paragraph is before delimiters. |
||||
|
||||
BREAK |
||||
|
||||
This paragraph is between delimiters. |
||||
|
||||
--- |
||||
|
||||
This paragraph is after the delimiter so it shouldn't appear. |
||||
|
||||
Nulla et nunc. Duis pede. Donec et ipsum. Nam ut dui tincidunt neque |
||||
sollicitudin iaculis. Duis vitae dolor. Vestibulum eget massa. Sed lorem. |
||||
Nullam volutpat cursus erat. Cras felis dolor, lacinia quis, rutrum et, |
||||
dictum et, ligula. Sed erat nibh, gravida in, accumsan non, placerat sed, |
||||
massa. Sed sodales, ante fermentum ultricies sollicitudin, massa leo |
||||
pulvinar dui, a gravida orci mi eget odio. Nunc a lacus. |
||||
|
||||
Project: onlinestore |
||||
Status: Resolved |
||||
due date: 2010-12-31 |
||||
Start Date:2010-01-01 |
||||
Assigned to: John Smith |
||||
version: alpha |
||||
estimated hours: 2.5 |
||||
done ratio: 30 |
||||
|
@ -1,143 +0,0 @@ |
||||
#-- copyright |
||||
# OpenProject is an open source project management software. |
||||
# Copyright (C) 2012-2022 the OpenProject GmbH |
||||
# |
||||
# This program is free software; you can redistribute it and/or |
||||
# modify it under the terms of the GNU General Public License version 3. |
||||
# |
||||
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: |
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang |
||||
# Copyright (C) 2010-2013 the ChiliProject Team |
||||
# |
||||
# This program is free software; you can redistribute it and/or |
||||
# modify it under the terms of the GNU General Public License |
||||
# as published by the Free Software Foundation; either version 2 |
||||
# of the License, or (at your option) any later version. |
||||
# |
||||
# This program is distributed in the hope that it will be useful, |
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
# GNU General Public License for more details. |
||||
# |
||||
# You should have received a copy of the GNU General Public License |
||||
# along with this program; if not, write to the Free Software |
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
||||
# |
||||
# See COPYRIGHT and LICENSE files for more details. |
||||
#++ |
||||
require_relative '../legacy_spec_helper' |
||||
|
||||
describe MailHandler, type: :model, with_settings: { report_incoming_email_errors: false } do |
||||
fixtures :all |
||||
|
||||
FIXTURES_PATH = File.dirname(__FILE__) + '/../fixtures/mail_handler' |
||||
|
||||
it 'adds work package with japanese keywords' do |
||||
type = ::Type.create!(name: '開発') |
||||
Project.find(1).types << type |
||||
issue = submit_email('japanese_keywords_iso_2022_jp.eml', issue: { project: 'ecookbook' }, allow_override: 'type') |
||||
assert_kind_of WorkPackage, issue |
||||
assert_equal type, issue.type |
||||
end |
||||
|
||||
it 'adds work package with iso 8859 1 subject' do |
||||
issue = submit_email( |
||||
'subject_as_iso-8859-1.eml', |
||||
issue: { project: 'ecookbook' } |
||||
) |
||||
assert_kind_of WorkPackage, issue |
||||
assert_equal 'Testmail from Webmail: ä ö ü...', issue.subject |
||||
end |
||||
|
||||
it 'strips tags of html only emails' do |
||||
issue = submit_email('ticket_html_only.eml', issue: { project: 'ecookbook' }) |
||||
assert issue.is_a?(WorkPackage) |
||||
assert !issue.new_record? |
||||
issue.reload |
||||
assert_equal 'HTML email', issue.subject |
||||
assert_equal 'This is a html-only email.', issue.description |
||||
end |
||||
|
||||
it 'emails with long subject line' do |
||||
issue = submit_email('ticket_with_long_subject.eml') |
||||
assert issue.is_a?(WorkPackage) |
||||
assert_equal issue.subject, |
||||
'New ticket on a given project with a very long subject line which exceeds 255 chars and should not be ignored but chopped off. And if the subject line is still not long enough, we just add more text. And more text. Wow, this is really annoying. Especially, if you have nothing to say...'[ |
||||
0, 255] |
||||
end |
||||
|
||||
it 'news user from attributes should return valid user' do |
||||
to_test = { |
||||
# [address, name] => [login, firstname, lastname] |
||||
['jsmith@example.net', nil] => ['jsmith@example.net', 'jsmith', '-'], |
||||
['jsmith@example.net', 'John'] => ['jsmith@example.net', 'John', '-'], |
||||
['jsmith@example.net', 'John Smith'] => ['jsmith@example.net', 'John', 'Smith'], |
||||
['jsmith@example.net', 'John Paul Smith'] => ['jsmith@example.net', 'John', 'Paul Smith'], |
||||
['jsmith@example.net', |
||||
'AVeryLongFirstnameThatNoLongerExceedsTheMaximumLength Smith'] => ['jsmith@example.net', |
||||
'AVeryLongFirstnameThatNoLongerExceedsTheMaximumLength', 'Smith'], |
||||
['jsmith@example.net', |
||||
'John AVeryLongLastnameThatNoLongerExceedsTheMaximumLength'] => ['jsmith@example.net', 'John', |
||||
'AVeryLongLastnameThatNoLongerExceedsTheMaximumLength'] |
||||
} |
||||
|
||||
to_test.each do |attrs, expected| |
||||
user = MailHandler.new_user_from_attributes(attrs.first, attrs.last) |
||||
|
||||
assert user.valid?, user.errors.full_messages.to_s |
||||
assert_equal attrs.first, user.mail |
||||
assert_equal expected[0], user.login |
||||
assert_equal expected[1], user.firstname |
||||
assert_equal expected[2], user.lastname |
||||
end |
||||
end |
||||
|
||||
context 'with min password length', |
||||
with_legacy_settings: { password_min_length: 15 } do |
||||
it 'news user from attributes should respect minimum password length' do |
||||
user = MailHandler.new_user_from_attributes('jsmith@example.net') |
||||
assert user.valid? |
||||
assert user.password.length >= 15 |
||||
end |
||||
end |
||||
|
||||
it 'news user from attributes should use default login if invalid' do |
||||
user = MailHandler.new_user_from_attributes('foo&bar@example.net') |
||||
assert user.valid? |
||||
assert user.login =~ /^user[a-f0-9]+$/ |
||||
assert_equal 'foo&bar@example.net', user.mail |
||||
end |
||||
|
||||
it 'news user with utf8 encoded fullname should be decoded' do |
||||
assert_difference 'User.count' do |
||||
issue = submit_email( |
||||
'fullname_of_sender_as_utf8_encoded.eml', |
||||
issue: { project: 'ecookbook' }, |
||||
unknown_user: 'create' |
||||
) |
||||
end |
||||
|
||||
user = User.order('id DESC').first |
||||
assert_equal 'foo@example.org', user.mail |
||||
str1 = "\xc3\x84\xc3\xa4" |
||||
str2 = "\xc3\x96\xc3\xb6" |
||||
str1.force_encoding('UTF-8') if str1.respond_to?(:force_encoding) |
||||
str2.force_encoding('UTF-8') if str2.respond_to?(:force_encoding) |
||||
assert_equal str1, user.firstname |
||||
assert_equal str2, user.lastname |
||||
end |
||||
|
||||
private |
||||
|
||||
def submit_email(filename, options = {}) |
||||
raw = IO.read(File.join(FIXTURES_PATH, filename)) |
||||
yield raw if block_given? |
||||
MailHandler.receive(raw, options) |
||||
end |
||||
|
||||
def assert_issue_created(issue) |
||||
assert issue.is_a?(WorkPackage) |
||||
assert !issue.new_record? |
||||
issue.reload |
||||
end |
||||
end |
Loading…
Reference in new issue